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..deaf25bac122b30185893891ef1332b8314a86ee |
--- /dev/null |
+++ b/base/win/scoped_propvariant.h |
@@ -0,0 +1,40 @@ |
+// 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> |
+ |
+namespace base { |
+namespace win { |
+ |
+// A PROPVARIANT that is automatically initialized and cleared upon respective |
+// construction and destruction of this class. |
+class ScopedPropVariant { |
grt (UTC plus 2)
2013/01/09 14:30:10
it'd be nice if this scoper was safe to use. as it
grt (UTC plus 2)
2013/01/09 16:06:16
A Reset() method that calls PropVariantClear would
gab
2013/01/09 20:43:39
Ah good point, done.
gab
2013/01/09 20:43:39
Done.
|
+ public: |
+ ScopedPropVariant() { |
+ PropVariantInit(&pv_); |
+ } |
+ ~ScopedPropVariant() { |
+ PropVariantClear(&pv_); |
+ } |
+ |
+ PROPVARIANT* operator&() { |
+ return &pv_; |
+ } |
+ |
+ // Allow direct read-only access to the members of |pv_| with the -> operator. |
+ const PROPVARIANT* operator->() const { |
grt (UTC plus 2)
2013/01/09 14:30:10
a conversion function would be a nice fit:
oper
gab
2013/01/09 20:43:39
This doesn't work directly: i.e. pv_app_it.vt stil
grt (UTC plus 2)
2013/01/10 03:24:05
Doh!
gab
2013/01/10 15:30:42
Ok change removed operator->, added get() method.
|
+ return &pv_; |
+ } |
+ |
+ private: |
+ PROPVARIANT pv_; |
+}; |
+ |
+} // namespace win |
+} // namespace base |
+ |
+#endif // BASE_WIN_SCOPED_PROPVARIANT_H_ |