Index: base/win/scoped_propvariant.h |
diff --git a/base/win/scoped_propvariant.h b/base/win/scoped_propvariant.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f94128ca00fe51669eeda3a8e141f2df61ab7389 |
--- /dev/null |
+++ b/base/win/scoped_propvariant.h |
@@ -0,0 +1,53 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef BASE_WIN_SCOPED_PROPVARIANT_H_ |
+#define BASE_WIN_SCOPED_PROPVARIANT_H_ |
+ |
+#include <propidl.h> |
+ |
+#include "base/basictypes.h" |
+#include "base/logging.h" |
+ |
+namespace base { |
+namespace win { |
+ |
+// A PROPVARIANT that is automatically initialized and cleared upon respective |
+// construction and destruction of this class. |
+class ScopedPropVariant { |
+ public: |
+ ScopedPropVariant() { |
+ PropVariantInit(&pv_); |
+ } |
+ ~ScopedPropVariant() { |
grt (UTC plus 2)
2013/01/10 16:05:20
nit: empty line before this
gab
2013/01/10 18:11:38
Done.
|
+ Reset(); |
+ } |
+ |
+ PROPVARIANT* Receive() { |
grt (UTC plus 2)
2013/01/10 16:05:20
i can haz doc comment?
gab
2013/01/10 18:11:38
Done.
|
+ DCHECK_EQ(pv_.vt, VT_EMPTY); |
+ return &pv_; |
+ } |
+ |
+ void Reset() { |
grt (UTC plus 2)
2013/01/10 16:05:20
here, too?
gab
2013/01/10 18:11:38
Done.
|
+ HRESULT result = PropVariantClear(&pv_); |
+ DCHECK_EQ(result, S_OK); |
+ } |
+ |
+ const PROPVARIANT& get() const { return pv_; } |
+ |
+ const PROPVARIANT* operator&() const { return &pv_; } |
+ |
+ private: |
+ PROPVARIANT pv_; |
+ |
+ // Comparison operators for ScopedPropVariant are not supported at this point. |
+ bool operator==(const ScopedPropVariant&) const; |
+ bool operator!=(const ScopedPropVariant&) const; |
+ DISALLOW_COPY_AND_ASSIGN(ScopedPropVariant); |
+}; |
+ |
+} // namespace win |
+} // namespace base |
+ |
+#endif // BASE_WIN_SCOPED_PROPVARIANT_H_ |