OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BASE_WIN_SCOPED_PROPVARIANT_H_ | |
6 #define BASE_WIN_SCOPED_PROPVARIANT_H_ | |
7 | |
8 #include <propidl.h> | |
9 | |
grt (UTC plus 2)
2013/01/10 03:24:05
#include "base/base_export.h"
(for BASE_EXPORT)
#i
gab
2013/01/10 15:30:42
Oh oops, good catch!
| |
10 namespace base { | |
11 namespace win { | |
12 | |
13 // A PROPVARIANT that is automatically initialized and cleared upon respective | |
14 // construction and destruction of this class. | |
15 class ScopedPropVariant { | |
grt (UTC plus 2)
2013/01/10 03:24:05
class BASE_EXPORT ScopedPropVariant {
gab
2013/01/10 15:30:42
This won't link, as discussed this is probably bec
| |
16 public: | |
17 ScopedPropVariant() { | |
18 PropVariantInit(&pv_); | |
19 } | |
20 ~ScopedPropVariant() { | |
21 HRESULT result = PropVariantClear(&pv_); | |
22 DCHECK_EQ(result, S_OK); | |
gab
2013/01/09 20:43:40
I could simply call Reset() here, but I felt it mi
grt (UTC plus 2)
2013/01/10 03:24:05
My opinion: call Reset().
gab
2013/01/10 15:30:42
Done.
| |
23 } | |
24 | |
25 PROPVARIANT* Receive() { | |
26 DCHECK_EQ(pv_.vt, VT_EMPTY); | |
27 return &pv_; | |
28 } | |
29 | |
30 void Reset() { | |
31 HRESULT result = PropVariantClear(&pv_); | |
32 DCHECK_EQ(result, S_OK); | |
33 } | |
34 | |
35 // Allow direct read-only access to the members of |pv_| with the -> operator. | |
36 const PROPVARIANT* operator->() const { return &pv_; } | |
37 | |
38 const PROPVARIANT* operator&() const { return &pv_; } | |
39 | |
40 private: | |
41 PROPVARIANT pv_; | |
42 }; | |
grt (UTC plus 2)
2013/01/10 03:24:05
DISALLOW_COPY_AND_ASSIGN(ScopedPropVariant);
also
gab
2013/01/10 15:30:42
Done.
| |
43 | |
44 } // namespace win | |
45 } // namespace base | |
46 | |
47 #endif // BASE_WIN_SCOPED_PROPVARIANT_H_ | |
OLD | NEW |