| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_WIN_SCOPED_VARIANT_H_ | 5 #ifndef BASE_WIN_SCOPED_VARIANT_H_ |
| 6 #define BASE_WIN_SCOPED_VARIANT_H_ | 6 #define BASE_WIN_SCOPED_VARIANT_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <oleauto.h> | 9 #include <oleauto.h> |
| 10 #include <stdint.h> |
| 10 | 11 |
| 11 #include "base/base_export.h" | 12 #include "base/base_export.h" |
| 12 #include "base/basictypes.h" | 13 #include "base/macros.h" |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 namespace win { | 16 namespace win { |
| 16 | 17 |
| 17 // Scoped VARIANT class for automatically freeing a COM VARIANT at the | 18 // Scoped VARIANT class for automatically freeing a COM VARIANT at the |
| 18 // end of a scope. Additionally provides a few functions to make the | 19 // end of a scope. Additionally provides a few functions to make the |
| 19 // encapsulated VARIANT easier to use. | 20 // encapsulated VARIANT easier to use. |
| 20 // Instead of inheriting from VARIANT, we take the containment approach | 21 // Instead of inheriting from VARIANT, we take the containment approach |
| 21 // in order to have more control over the usage of the variant and guard | 22 // in order to have more control over the usage of the variant and guard |
| 22 // against memory leaks. | 23 // against memory leaks. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 84 |
| 84 // Retrieves the pointer address. | 85 // Retrieves the pointer address. |
| 85 // Used to receive a VARIANT as an out argument (and take ownership). | 86 // Used to receive a VARIANT as an out argument (and take ownership). |
| 86 // The function DCHECKs on the current value being empty/null. | 87 // The function DCHECKs on the current value being empty/null. |
| 87 // Usage: GetVariant(var.receive()); | 88 // Usage: GetVariant(var.receive()); |
| 88 VARIANT* Receive(); | 89 VARIANT* Receive(); |
| 89 | 90 |
| 90 void Set(const wchar_t* str); | 91 void Set(const wchar_t* str); |
| 91 | 92 |
| 92 // Setters for simple types. | 93 // Setters for simple types. |
| 93 void Set(int8 i8); | 94 void Set(int8_t i8); |
| 94 void Set(uint8 ui8); | 95 void Set(uint8_t ui8); |
| 95 void Set(int16 i16); | 96 void Set(int16_t i16); |
| 96 void Set(uint16 ui16); | 97 void Set(uint16_t ui16); |
| 97 void Set(int32 i32); | 98 void Set(int32_t i32); |
| 98 void Set(uint32 ui32); | 99 void Set(uint32_t ui32); |
| 99 void Set(int64 i64); | 100 void Set(int64_t i64); |
| 100 void Set(uint64 ui64); | 101 void Set(uint64_t ui64); |
| 101 void Set(float r32); | 102 void Set(float r32); |
| 102 void Set(double r64); | 103 void Set(double r64); |
| 103 void Set(bool b); | 104 void Set(bool b); |
| 104 | 105 |
| 105 // Creates a copy of |var| and assigns as this instance's value. | 106 // Creates a copy of |var| and assigns as this instance's value. |
| 106 // Note that this is different from the Reset() method that's used to | 107 // Note that this is different from the Reset() method that's used to |
| 107 // free the current value and assume ownership. | 108 // free the current value and assume ownership. |
| 108 void Set(const VARIANT& var); | 109 void Set(const VARIANT& var); |
| 109 | 110 |
| 110 // COM object setters | 111 // COM object setters |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // Use the Compare method instead. | 156 // Use the Compare method instead. |
| 156 bool operator==(const ScopedVariant& var) const; | 157 bool operator==(const ScopedVariant& var) const; |
| 157 bool operator!=(const ScopedVariant& var) const; | 158 bool operator!=(const ScopedVariant& var) const; |
| 158 DISALLOW_COPY_AND_ASSIGN(ScopedVariant); | 159 DISALLOW_COPY_AND_ASSIGN(ScopedVariant); |
| 159 }; | 160 }; |
| 160 | 161 |
| 161 } // namespace win | 162 } // namespace win |
| 162 } // namespace base | 163 } // namespace base |
| 163 | 164 |
| 164 #endif // BASE_WIN_SCOPED_VARIANT_H_ | 165 #endif // BASE_WIN_SCOPED_VARIANT_H_ |
| OLD | NEW |