| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_SCOPED_BSTR_WIN_H_ | 5 #ifndef BASE_SCOPED_BSTR_WIN_H_ |
| 6 #define BASE_SCOPED_BSTR_WIN_H_ | 6 #define BASE_SCOPED_BSTR_WIN_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" // needed to pick up OS_WIN | |
| 9 | |
| 10 #include "base/logging.h" | |
| 11 | |
| 12 #include <windows.h> | 8 #include <windows.h> |
| 13 #include <oleauto.h> | 9 #include <oleauto.h> |
| 14 | 10 |
| 11 #include "base/logging.h" |
| 12 |
| 15 // Manages a BSTR string pointer. | 13 // Manages a BSTR string pointer. |
| 16 // The class interface is based on scoped_ptr. | 14 // The class interface is based on scoped_ptr. |
| 17 class ScopedBstr { | 15 class ScopedBstr { |
| 18 public: | 16 public: |
| 19 ScopedBstr() : bstr_(NULL) { | 17 ScopedBstr() : bstr_(NULL) { |
| 20 } | 18 } |
| 21 | 19 |
| 22 // Constructor to create a new BSTR. | 20 // Constructor to create a new BSTR. |
| 23 // NOTE: Do not pass a BSTR to this constructor expecting ownership to | 21 // NOTE: Do not pass a BSTR to this constructor expecting ownership to |
| 24 // be transferred - even though it compiles! ;-) | 22 // be transferred - even though it compiles! ;-) |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // (e.g. if the BSTR is used inside a loop or more than one place), | 132 // (e.g. if the BSTR is used inside a loop or more than one place), |
| 135 // use StackBstrVar to declare a variable. | 133 // use StackBstrVar to declare a variable. |
| 136 // Example: | 134 // Example: |
| 137 // StackBstrVar(L"my_property", myprop); | 135 // StackBstrVar(L"my_property", myprop); |
| 138 // for (int i = 0; i < objects.length(); ++i) | 136 // for (int i = 0; i < objects.length(); ++i) |
| 139 // ProcessValue(objects[i].GetProp(myprop)); // GetProp accepts BSTR | 137 // ProcessValue(objects[i].GetProp(myprop)); // GetProp accepts BSTR |
| 140 #define StackBstrVar(str, var) \ | 138 #define StackBstrVar(str, var) \ |
| 141 StackBstrT<sizeof(str)> var(str) | 139 StackBstrT<sizeof(str)> var(str) |
| 142 | 140 |
| 143 #endif // BASE_SCOPED_BSTR_WIN_H_ | 141 #endif // BASE_SCOPED_BSTR_WIN_H_ |
| OLD | NEW |