Changeset 15051 in vbox for trunk/include/VBox
- Timestamp:
- Dec 5, 2008 5:20:00 PM (16 years ago)
- Location:
- trunk/include/VBox/com
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/Guid.h
r13624 r15051 119 119 bool operator< (const GUID &guid) const { return ::RTUuidCompare (&uuid, (PRTUUID) &guid) < 0; } 120 120 121 /* to pass instances as GUIDPARAMparameters to interface methods */121 /* to pass instances as IN_GUID parameters to interface methods */ 122 122 operator const GUID &() const { return *(GUID *) &uuid; } 123 123 … … 133 133 #if !defined (VBOX_WITH_XPCOM) 134 134 135 /* to assign instances to GUIDPARAMOUTparameters from within the135 /* to assign instances to OUT_GUID parameters from within the 136 136 * interface method */ 137 137 const Guid &cloneTo (GUID *pguid) const … … 141 141 } 142 142 143 /* to pass instances as GUIDPARAMOUTparameters to interface methods */143 /* to pass instances as OUT_GUID parameters to interface methods */ 144 144 GUID *asOutParam() { return (GUID *) &uuid; } 145 145 146 146 #else 147 147 148 /* to assign instances to GUIDPARAMOUTparameters from within the148 /* to assign instances to OUT_GUID parameters from within the 149 149 * interface method */ 150 150 const Guid &cloneTo (nsID **ppguid) const … … 171 171 }; 172 172 173 /* to pass instances as GUIDPARAMOUTparameters to interface methods */173 /* to pass instances as OUT_GUID parameters to interface methods */ 174 174 GuidOutParam asOutParam() { return GuidOutParam (*this); } 175 175 176 176 #endif 177 177 178 /* to directly test GUIDPARAMinterface method's parameters */178 /* to directly test IN_GUID interface method's parameters */ 179 179 static bool isEmpty (const GUID &guid) 180 180 { -
trunk/include/VBox/com/VirtualBoxErrorInfo.h
r13580 r15051 86 86 // IVirtualBoxErrorInfo properties 87 87 STDMETHOD(COMGETTER(ResultCode)) (HRESULT *aResultCode); 88 STDMETHOD(COMGETTER(InterfaceID)) ( GUIDPARAMOUTaIID);88 STDMETHOD(COMGETTER(InterfaceID)) (OUT_GUID aIID); 89 89 STDMETHOD(COMGETTER(Component)) (BSTR *aComponent); 90 90 STDMETHOD(COMGETTER(Text)) (BSTR *aText); -
trunk/include/VBox/com/array.h
r15048 r15051 155 155 * 156 156 * Also note that in order to pass input BSTR array parameters declared 157 * using the ComSafeArrayIn (IN PTRBSTR, aParam) macro to the SafeArray<>158 * constructor using the ComSafeArrayInArg() macro, you should use IN PTRBSTR157 * using the ComSafeArrayIn (IN_BSTR, aParam) macro to the SafeArray<> 158 * constructor using the ComSafeArrayInArg() macro, you should use IN_BSTR 159 159 * as the SafeArray<> template argument, not just BSTR. 160 160 * -
trunk/include/VBox/com/defs.h
r13908 r15051 91 91 #define SUCCEEDED_WARNING(rc) (SUCCEEDED (rc) && (rc) != S_OK) 92 92 93 /** Input pointer argument prefix in the interface method declaration. */ 94 #define INPTR 93 /** Immutable BSTR string */ 94 typedef const OLECHAR *CBSTR; 95 96 /** Input BSTR argument the interface method declaration. */ 97 #define IN_BSTR BSTR 98 99 /** Input GUID argument the interface method declaration. */ 100 #define IN_GUID GUID 101 /** Output GUID argument the interface method declaration. */ 102 #define OUT_GUID GUID* 95 103 96 104 /** Makes the name of the getter interface function (n must be capitalized). */ … … 98 106 /** Makes the name of the setter interface function (n must be capitalized). */ 99 107 #define COMSETTER(n) put_##n 100 101 /** Type for an input GUID parameter in the interface method declaration. */102 #define GUIDPARAM GUID103 /** Type for an output GUID parameter in the interface method declaration. */104 #define GUIDPARAMOUT GUID*105 108 106 109 /** … … 265 268 #define ULONG64 PRUint64 266 269 267 #define BSTR PRUnichar * 268 #define LPBSTR BSTR * 270 #define FALSE PR_FALSE 271 #define TRUE PR_TRUE 272 269 273 #define OLECHAR wchar_t 270 274 271 #define FALSE PR_FALSE 272 #define TRUE PR_TRUE 273 274 /** Input pointer argument prefix in the interface method declaration. */ 275 #define INPTR const 275 /* note: typedef to semantically match BSTR on Win32 */ 276 typedef PRUnichar *BSTR; 277 typedef const PRUnichar *CBSTR; 278 typedef BSTR *LPBSTR; 279 280 /** Input BSTR argument the interface method declaration. */ 281 #define IN_BSTR CBSTR 282 283 /** 284 * Type to define a raw GUID variable (for members use the com::Guid class 285 * instead). 286 */ 287 #define GUID nsID 288 /** Input GUID argument the interface method declaration. */ 289 #define IN_GUID const nsID & 290 /** Output GUID argument the interface method declaration. */ 291 #define OUT_GUID nsID ** 276 292 277 293 /** Makes the name of the getter interface function (n must be capitalized). */ … … 279 295 /** Makes the name of the setter interface function (n must be capitalized). */ 280 296 #define COMSETTER(n) Set##n 281 282 /**283 * Type to define a raw GUID variable (for members use the com::Guid class284 * instead).285 */286 #define GUID nsID287 /** Type for an input GUID parameter in the interface method declaration. */288 #define GUIDPARAM nsID &289 /** Type for an output GUID parameter in the interface method declaration. */290 #define GUIDPARAMOUT nsID **291 297 292 298 /* safearray input parameter macros */ -
trunk/include/VBox/com/string.h
r13856 r15051 76 76 77 77 typedef BSTR String; 78 typedef constBSTR ConstString;78 typedef CBSTR ConstString; 79 79 80 80 Bstr () : bstr (NULL) {} 81 81 82 82 Bstr (const Bstr &that) : bstr (NULL) { raw_copy (bstr, that.bstr); } 83 Bstr (const BSTR that) : bstr (NULL) { raw_copy (bstr, that); } 83 Bstr (CBSTR that) : bstr (NULL) { raw_copy (bstr, that); } 84 85 #if defined (VBOX_WITH_XPCOM) 84 86 Bstr (const wchar_t *that) : bstr (NULL) 85 87 { 86 88 AssertCompile (sizeof (wchar_t) == sizeof (OLECHAR)); 87 raw_copy (bstr, (const BSTR) that); 88 } 89 raw_copy (bstr, (CBSTR) that); 90 } 91 #endif 89 92 90 93 Bstr (const Utf8Str &that); … … 97 100 98 101 Bstr &operator = (const Bstr &that) { safe_assign (that.bstr); return *this; } 99 Bstr &operator = ( constBSTR that) { safe_assign (that); return *this; }102 Bstr &operator = (CBSTR that) { safe_assign (that); return *this; } 100 103 101 104 Bstr &operator = (const Utf8Str &that); … … 140 143 } 141 144 142 int compare (const BSTR str) const 145 int compare (CBSTR str) const 146 { 147 return ::RTUtf16Cmp ((PRTUTF16) bstr, (PRTUTF16) str); 148 } 149 150 int compare (BSTR str) const 143 151 { 144 152 return ::RTUtf16Cmp ((PRTUTF16) bstr, (PRTUTF16) str); … … 147 155 bool operator == (const Bstr &that) const { return !compare (that.bstr); } 148 156 bool operator != (const Bstr &that) const { return !!compare (that.bstr); } 149 bool operator == (const BSTR that) const { return !compare (that); } 157 bool operator == (CBSTR that) const { return !compare (that); } 158 bool operator == (BSTR that) const { return !compare (that); } 159 160 #if defined (VBOX_WITH_XPCOM) 150 161 bool operator != (const wchar_t *that) const 151 162 { 152 163 AssertCompile (sizeof (wchar_t) == sizeof (OLECHAR)); 153 return !!compare (( constBSTR) that);164 return !!compare ((CBSTR) that); 154 165 } 155 166 bool operator == (const wchar_t *that) const 156 167 { 157 168 AssertCompile (sizeof (wchar_t) == sizeof (OLECHAR)); 158 return !compare ((const BSTR) that); 159 } 160 bool operator != (const BSTR that) const { return !!compare (that); } 169 return !compare ((CBSTR) that); 170 } 171 #endif 172 173 bool operator != (CBSTR that) const { return !!compare (that); } 174 bool operator != (BSTR that) const { return !!compare (that); } 161 175 bool operator < (const Bstr &that) const { return compare (that.bstr) < 0; } 162 bool operator < (const BSTR that) const { return compare (that) < 0; } 176 bool operator < (CBSTR that) const { return compare (that) < 0; } 177 bool operator < (BSTR that) const { return compare (that) < 0; } 178 #if defined (VBOX_WITH_XPCOM) 163 179 bool operator < (const wchar_t *that) const 164 180 { 165 181 AssertCompile (sizeof (wchar_t) == sizeof (OLECHAR)); 166 return compare ((const BSTR) that) < 0; 167 } 168 169 int compareIgnoreCase (const BSTR str) const 182 return compare ((CBSTR) that) < 0; 183 } 184 #endif 185 186 int compareIgnoreCase (CBSTR str) const 170 187 { 171 188 return ::RTUtf16LocaleICmp (bstr, str); … … 179 196 size_t length() const { return isNull() ? 0 : ::RTUtf16Len ((PRTUTF16) bstr); } 180 197 181 /** Intended to to pass instances as |BSTR| input parameters to methods. */ 182 operator const BSTR () const { return bstr; } 183 184 /** The same as operator const BSTR(), but for situations where the compiler 185 cannot typecast implicitly (for example, in printf() argument list). */ 186 const BSTR raw() const { return bstr; } 198 /** Intended to to pass instances as |CBSTR| input parameters to methods. */ 199 operator CBSTR () const { return bstr; } 200 201 /** 202 * Intended to to pass instances as |BSTR| input parameters to methods. 203 * Note that we have to provide this mutable BSTR operator since in MS COM 204 * input BSTR parameters of interface methods are not const. 205 */ 206 operator BSTR () { return bstr; } 207 208 /** 209 * The same as operator CBSTR(), but for situations where the compiler 210 * cannot typecast implicitly (for example, in printf() argument list). 211 */ 212 CBSTR raw() const { return bstr; } 187 213 188 214 /** … … 245 271 protected: 246 272 247 void safe_assign ( constBSTR str)273 void safe_assign (CBSTR str) 248 274 { 249 275 if (bstr != str) … … 254 280 } 255 281 256 inline static void raw_copy (BSTR &ls, constBSTR rs)282 inline static void raw_copy (BSTR &ls, CBSTR rs) 257 283 { 258 284 if (rs) … … 277 303 278 304 /* symmetric compare operators */ 279 inline bool operator== (const BSTR l, const Bstr &r) { return r.operator== (l); } 280 inline bool operator!= (const BSTR l, const Bstr &r) { return r.operator!= (l); } 305 inline bool operator== (CBSTR l, const Bstr &r) { return r.operator== (l); } 306 inline bool operator!= (CBSTR l, const Bstr &r) { return r.operator!= (l); } 307 inline bool operator== (BSTR l, const Bstr &r) { return r.operator== (l); } 308 inline bool operator!= (BSTR l, const Bstr &r) { return r.operator!= (l); } 281 309 282 310 //////////////////////////////////////////////////////////////////////////////// … … 309 337 310 338 Utf8Str (const Bstr &that) : str (NULL) { raw_copy (str, that); } 311 Utf8Str ( constBSTR that) : str (NULL) { raw_copy (str, that); }339 Utf8Str (CBSTR that) : str (NULL) { raw_copy (str, that); } 312 340 313 341 /** Shortcut that calls #alloc(aSize) right after object creation. */ … … 325 353 return *this; 326 354 } 327 Utf8Str &operator = ( constBSTR that)355 Utf8Str &operator = (CBSTR that) 328 356 { 329 357 setNull(); … … 500 528 } 501 529 502 inline static void raw_copy (char *&ls, constBSTR rs)530 inline static void raw_copy (char *&ls, CBSTR rs) 503 531 { 504 532 if (rs)
Note:
See TracChangeset
for help on using the changeset viewer.