Changeset 13580 in vbox for trunk/include
- Timestamp:
- Oct 27, 2008 2:04:18 PM (16 years ago)
- Location:
- trunk/include
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/ErrorInfo.h
r8309 r13580 362 362 */ 363 363 ErrorInfoKeeper (bool aIsNull = false) 364 : ErrorInfo (false), mForgot ( false)364 : ErrorInfo (false), mForgot (aIsNull) 365 365 { 366 366 if (!aIsNull) … … 371 371 * Destroys this instance and automatically calls #restore() which will 372 372 * either restore error info fetched by the constructor or do nothing 373 * if #forget() was called before destruction. */ 373 * if #forget() was called before destruction. 374 */ 374 375 ~ErrorInfoKeeper() { if (!mForgot) restore(); } 375 376 … … 383 384 { 384 385 setNull(); 386 mForgot = false; 385 387 init (true /* aKeepObj */); 386 388 } … … 388 390 /** 389 391 * Restores error info fetched by the constructor and forgets it 390 * afterwards. 392 * afterwards. Does nothing if the error info was forgotten by #forget(). 391 393 * 392 394 * @return COM result of the restore operation. -
trunk/include/VBox/com/Guid.h
r9738 r13580 65 65 Guid (const Guid &that) { uuid = that.uuid; } 66 66 Guid (const RTUUID &that) { uuid = that; } 67 Guid (const GUID &that) { ::memcpy (&uuid, &that, sizeof (GUID)); } 67 68 Guid (const GUID &that) 69 { 70 AssertCompileSize (GUID, sizeof (RTUUID)); 71 ::memcpy (&uuid, &that, sizeof (GUID)); 72 } 73 68 74 Guid (const char *that) 69 75 { -
trunk/include/VBox/com/array.h
r11379 r13580 153 153 * supported and therefore cannot be used as element types. 154 154 * 155 * In order to pass input BSTR array parameters delcared using the 156 * ComSafeArrayIn (INPTR BSTR, aParam) macro to the SafeArray<> constructor 157 * using the ComSafeArrayInArg() macro, you should use INPTR BSTR as the 158 * SafeArray<> template argument, not just BSTR. 155 * Note that for GUID arrays you should use SafeGUIDArray and 156 * SafeConstGUIDArray, customized SafeArray<> specializations. 157 * 158 * Also note that in order to pass input BSTR array parameters delcared 159 * using the ComSafeArrayIn (INPTR BSTR, aParam) macro to the SafeArray<> 160 * constructor using the ComSafeArrayInArg() macro, you should use INPTR BSTR 161 * as the SafeArray<> template argument, not just BSTR. 159 162 * 160 163 * Arrays of interface pointers are also supported but they require to use a … … 183 186 */ 184 187 #define ComSafeArrayAsInParam(aArray) \ 185 (aArray).size(), (aArray).__asInParam_Arr ( aArray.raw())188 (aArray).size(), (aArray).__asInParam_Arr ((aArray).raw()) 186 189 187 190 /** … … 214 217 215 218 /** 216 * Contains various helper constants for SafeArray. 219 * Provides various helpers for SafeArray. 220 * 221 * @param T Type of array elements. 217 222 */ 218 223 template <typename T> … … 221 226 protected: 222 227 228 /** Initializes memory for aElem. */ 223 229 static void Init (T &aElem) { aElem = 0; } 230 231 /** Initializes memory occupied by aElem. */ 224 232 static void Uninit (T &aElem) { aElem = 0; } 233 234 /** Creates a deep copy of aFrom and stores it in aTo. */ 225 235 static void Copy (const T &aFrom, T &aTo) { aTo = aFrom; } 226 236 … … 248 258 249 259 static void Init (PRUnichar * &aElem) { aElem = NULL; } 260 250 261 static void Uninit (PRUnichar * &aElem) 251 262 { … … 300 311 }; 301 312 313 template<> 314 struct SafeArrayTraits <nsID *> 315 { 316 protected: 317 318 static void Init (nsID * &aElem) { aElem = NULL; } 319 320 static void Uninit (nsID * &aElem) 321 { 322 if (aElem) 323 { 324 ::nsMemory::Free (aElem); 325 aElem = NULL; 326 } 327 } 328 329 static void Copy (const nsID * aFrom, nsID * &aTo) 330 { 331 if (aFrom) 332 { 333 aTo = (nsID *) ::nsMemory::Alloc (sizeof (nsID)); 334 if (aTo) 335 *aTo = *aFrom; 336 } 337 else 338 aTo = NULL; 339 } 340 341 /* This specification is also reused for SafeConstGUIDArray, so provide a 342 * no-op Init() and Uninit() which are necessary for SafeArray<> but should 343 * be never called in context of SafeConstGUIDArray. */ 344 345 static void Init (const nsID * &aElem) { NOREF (aElem); AssertFailed(); } 346 static void Uninit (const nsID * &aElem) { NOREF (aElem); AssertFailed(); } 347 348 public: 349 350 /** Magic to workaround strict rules of par. 4.4.4 of the C++ standard. */ 351 static const nsID **__asInParam_Arr (nsID **aArr) 352 { 353 return const_cast <const nsID **> (aArr); 354 } 355 static const nsID **__asInParam_Arr (const nsID **aArr) { return aArr; } 356 }; 357 302 358 #else /* defined (VBOX_WITH_XPCOM) */ 303 359 … … 305 361 306 362 /** 307 * Contains various helper constants for SafeArray. 363 * Provides various helpers for SafeArray. 364 * 365 * @param T Type of array elements. 366 * 367 * Specializations of this template must provide the following methods: 368 * 369 // Returns the VARTYPE of COM SafeArray elements to be used for T 370 static VARTYPE VarType(); 371 372 // Returns the number of VarType() elements necessary for aSize 373 // elements of T 374 static ULONG VarCount (size_t aSize); 375 376 // Returns the number of elements of T that occupy the given number of 377 // VarType() elements (opposite to VarCount (size_t aSize)). 378 static size_t Size (ULONG aVarCount); 379 380 // Creates a deep copy of aFrom and stores it in aTo 381 static void Copy (ULONG aFrom, ULONG &aTo); 308 382 */ 309 383 template <typename T> 310 384 struct SafeArrayTraits 311 385 { 312 // Arbitrary types are not supported 386 // Arbitrary types are not supported -- no helpers 313 387 }; 314 388 … … 319 393 320 394 static VARTYPE VarType() { return VT_I4; } 395 static ULONG VarCount (size_t aSize) { return (ULONG) aSize; } 396 static size_t Size (ULONG aVarCount) { return (size_t) aVarCount; } 397 321 398 static void Copy (LONG aFrom, LONG &aTo) { aTo = aFrom; } 322 399 }; … … 328 405 329 406 static VARTYPE VarType() { return VT_UI4; } 407 static ULONG VarCount (size_t aSize) { return (ULONG) aSize; } 408 static size_t Size (ULONG aVarCount) { return (size_t) aVarCount; } 409 330 410 static void Copy (ULONG aFrom, ULONG &aTo) { aTo = aFrom; } 331 411 }; … … 337 417 338 418 static VARTYPE VarType() { return VT_I8; } 419 static ULONG VarCount (size_t aSize) { return (ULONG) aSize; } 420 static size_t Size (ULONG aVarCount) { return (size_t) aVarCount; } 421 339 422 static void Copy (LONG64 aFrom, LONG64 &aTo) { aTo = aFrom; } 340 423 }; … … 346 429 347 430 static VARTYPE VarType() { return VT_UI8; } 431 static ULONG VarCount (size_t aSize) { return (ULONG) aSize; } 432 static size_t Size (ULONG aVarCount) { return (size_t) aVarCount; } 433 348 434 static void Copy (ULONG64 aFrom, ULONG64 &aTo) { aTo = aFrom; } 349 435 }; … … 355 441 356 442 static VARTYPE VarType() { return VT_BSTR; } 443 static ULONG VarCount (size_t aSize) { return (ULONG) aSize; } 444 static size_t Size (ULONG aVarCount) { return (size_t) aVarCount; } 357 445 358 446 static void Copy (BSTR aFrom, BSTR &aTo) … … 360 448 aTo = aFrom ? ::SysAllocString ((const OLECHAR *) aFrom) : NULL; 361 449 } 450 }; 451 452 template<> 453 struct SafeArrayTraits <GUID> 454 { 455 protected: 456 457 /* Use the 64-bit unsigned integer type for GUID */ 458 static VARTYPE VarType() { return VT_UI8; } 459 460 /* GUID is 128 bit, so we need two VT_UI8 */ 461 static ULONG VarCount (size_t aSize) 462 { 463 AssertCompileSize (GUID, 16); 464 return (ULONG) (aSize * 2); 465 } 466 467 static size_t Size (ULONG aVarCount) { return (size_t) aVarCount / 2; } 468 469 static void Copy (GUID aFrom, GUID &aTo) { aTo = aFrom; } 362 470 }; 363 471 … … 418 526 * Weakly attaches this instance to the existing array passed in a method 419 527 * parameter declared using the ComSafeArrayIn macro. When using this call, 420 * always wrap the parameter name in the ComSafeArray OutArg macro call like528 * always wrap the parameter name in the ComSafeArrayInArg macro call like 421 529 * this: 422 530 * <pre> … … 460 568 m.isWeak = true; 461 569 462 AssertReturnVoid ( accessRaw() != NULL);570 AssertReturnVoid (m.arr == NULL || accessRaw() != NULL); 463 571 464 572 #endif /* defined (VBOX_WITH_XPCOM) */ … … 466 574 467 575 /** 468 * Creates a deep copy of the g oven standard C++ container.576 * Creates a deep copy of the given standard C++ container. 469 577 * 470 578 * @param aCntr Container object to copy. … … 479 587 AssertReturnVoid (!isNull()); 480 588 481 int i = 0;589 size_t i = 0; 482 590 for (typename C <T>::const_iterator it = aCntr.begin(); 483 591 it != aCntr.end(); ++ it, ++ i) … … 526 634 #else 527 635 if (m.arr) 528 return m.arr->rgsabound [0].cElements;636 return Size (m.arr->rgsabound [0].cElements); 529 637 return 0; 530 638 #endif … … 576 684 #else 577 685 578 SAFEARRAYBOUND bound = { (ULONG)aNewSize, 0 };686 SAFEARRAYBOUND bound = { VarCount (aNewSize), 0 }; 579 687 m.arr = SafeArrayCreate (VarType(), 1, &bound); 580 688 AssertReturn (m.arr != NULL, false); … … 678 786 679 787 /** 680 * Transfers the ownership of this array's data to a method parameter788 * Transfers the ownership of this array's data to the specified location 681 789 * declared using the ComSafeArrayOut macro and makes this array a null 682 790 * array. When using this call, always wrap the parameter name in the … … 686 794 * </pre> 687 795 * 796 * Detaching the null array is also possible in which case the location will 797 * receive NULL. 798 * 688 799 * @note Since the ownership of the array data is transferred to the 689 800 * caller of the method, he is responsible to free the array data when it is 690 801 * no more necessary. 691 802 * 692 * @param aArg Output method parameterto detach to.803 * @param aArg Location to detach to. 693 804 */ 694 805 virtual SafeArray &detachTo (ComSafeArrayOut (T, aArg)) … … 842 953 #if defined (VBOX_WITH_XPCOM) 843 954 955 /** 956 * Version of com::SafeArray for arrays of GUID. 957 * 958 * In MS COM, GUID arrays store GUIDs by value and therefore input arrays are 959 * represented using |GUID *| and out arrays -- using |GUID **|. In XPCOM, 960 * GUID arrays store pointers to nsID so that input arrays are |const nsID **| 961 * and out arrays are |nsID ***|. Due to this difference, it is impossible to 962 * work with arrays of GUID on both platforms by simply using com::SafeArray 963 * <GUID>. This class is intended to provide some leve of cross-platform 964 * behavior. 965 * 966 * The basic usage pattern is basically similar to com::SafeArray<> except that 967 * you use ComSafeGUIDArrayIn* and ComSafeGUIDArrayOut* macros instead of 968 * ComSafeArrayIn* and ComSafeArrayOut*. Another important nuance is that the 969 * raw() array type is different (nsID **, or GUID ** on XPCOM and GUID * on MS 970 * COM) so it is recommended to use operator[] instead that always returns a 971 * GUID by value. 972 * 973 * Note that due to const modifiers, you cannot use SafeGUIDArray for input GUID 974 * arrays. Please use SafeConstGUIDArray for this instead. 975 * 976 * Other than mentioned above, the functionality of this class is equivalent to 977 * com::SafeArray<>. See the description of that template and its methods for 978 * more information. 979 * 980 * Output GUID arrays are handled by a separate class, SafeGUIDArrayOut, since 981 * this class cannot handle them because of const modifiers. 982 */ 983 class SafeGUIDArray : public SafeArray <nsID *> 984 { 985 public: 986 987 typedef SafeArray <nsID *> Base; 988 989 class nsIDRef 990 { 991 public: 992 993 nsIDRef (nsID * &aVal) : mVal (aVal) {} 994 995 operator const nsID &() const { return mVal ? *mVal : *Empty; } 996 operator nsID() const { return mVal ? *mVal : *Empty; } 997 998 const nsID *operator&() const { return mVal ? mVal : Empty; } 999 1000 nsIDRef &operator= (const nsID &aThat) 1001 { 1002 if (mVal == NULL) 1003 Copy (&aThat, mVal); 1004 else 1005 *mVal = aThat; 1006 return *this; 1007 } 1008 1009 private: 1010 1011 nsID * &mVal; 1012 1013 static const nsID *Empty; 1014 1015 friend class SafeGUIDArray; 1016 }; 1017 1018 /** See SafeArray<>::SafeArray(). */ 1019 SafeGUIDArray() {} 1020 1021 /** See SafeArray<>::SafeArray (size_t). */ 1022 SafeGUIDArray (size_t aSize) : Base (aSize) {} 1023 1024 /** 1025 * Array access operator that returns an array element by reference. As a 1026 * special case, the return value of this operator on XPCOM is a nsID (GUID) 1027 * reference, instead of a nsID pointer (the actual SafeArray template 1028 * argument), for compatibility with the MS COM version. 1029 * 1030 * The rest is equivalent to SafeArray<>::operator[]. 1031 */ 1032 nsIDRef operator[] (size_t aIdx) 1033 { 1034 Assert (m.arr != NULL); 1035 Assert (aIdx < size()); 1036 return nsIDRef (m.arr [aIdx]); 1037 } 1038 1039 /** 1040 * Const version of #operator[] that returns an array element by value. 1041 */ 1042 const nsID &operator[] (size_t aIdx) const 1043 { 1044 Assert (m.arr != NULL); 1045 Assert (aIdx < size()); 1046 return m.arr [aIdx] ? *m.arr [aIdx] : *nsIDRef::Empty; 1047 } 1048 }; 1049 1050 /** 1051 * Version of com::SafeArray for const arrays of GUID. 1052 * 1053 * This class is used to work with input GUID array parameters in method 1054 * implementaitons. See SafeGUIDArray for more details. 1055 */ 1056 class SafeConstGUIDArray : public SafeArray <const nsID *, 1057 SafeArrayTraits <nsID *> > 1058 { 1059 public: 1060 1061 typedef SafeArray <const nsID *, SafeArrayTraits <nsID *> > Base; 1062 1063 /** See SafeArray<>::SafeArray(). */ 1064 SafeConstGUIDArray() {} 1065 1066 /* See SafeArray<>::SafeArray (ComSafeArrayIn (T, aArg)). */ 1067 SafeConstGUIDArray (ComSafeGUIDArrayIn (aArg)) 1068 : Base (ComSafeGUIDArrayInArg (aArg)) {} 1069 1070 /** 1071 * Array access operator that returns an array element by reference. As a 1072 * special case, the return value of this operator on XPCOM is nsID (GUID) 1073 * instead of nsID *, for compatibility with the MS COM version. 1074 * 1075 * The rest is equivalent to SafeArray<>::operator[]. 1076 */ 1077 const nsID &operator[] (size_t aIdx) const 1078 { 1079 AssertReturn (m.arr != NULL, **((const nsID * *) NULL)); 1080 AssertReturn (aIdx < size(), **((const nsID * *) NULL)); 1081 return *m.arr [aIdx]; 1082 } 1083 1084 private: 1085 1086 /* These are disabled because of const */ 1087 bool reset (size_t aNewSize) { NOREF (aNewSize); return false; } 1088 }; 1089 1090 #else /* defined (VBOX_WITH_XPCOM) */ 1091 1092 typedef SafeArray <GUID> SafeGUIDArray; 1093 typedef SafeArray <const GUID, SafeArrayTraits <GUID> > SafeConstGUIDArray; 1094 1095 #endif /* defined (VBOX_WITH_XPCOM) */ 1096 1097 //////////////////////////////////////////////////////////////////////////////// 1098 1099 #if defined (VBOX_WITH_XPCOM) 1100 844 1101 template <class I> 845 1102 struct SafeIfaceArrayTraits … … 883 1140 884 1141 static VARTYPE VarType() { return VT_UNKNOWN; } 1142 static ULONG VarCount (size_t aSize) { return (ULONG) aSize; } 1143 static size_t Size (ULONG aVarCount) { return (size_t) aVarCount; } 885 1144 886 1145 static void Copy (I * aFrom, I * &aTo) -
trunk/include/VBox/com/defs.h
r11390 r13580 71 71 #ifndef VBOX_COM_NO_ATL 72 72 # include <atlbase.h> 73 #include <atlcom.h> 73 74 #endif 74 75 … … 85 86 #define SUCCEEDED_WARNING(rc) (SUCCEEDED (rc) && (rc) != S_OK) 86 87 87 /* input pointer argument to method*/88 /** Input pointer argument prefix in the interface method declaration. */ 88 89 #define INPTR 89 90 90 /* makes the name of the getter interface function (n must be capitalized)*/91 /** Makes the name of the getter interface function (n must be capitalized). */ 91 92 #define COMGETTER(n) get_##n 92 /* makes the name of the setter interface function (n must be capitalized)*/93 /** Makes the name of the setter interface function (n must be capitalized). */ 93 94 #define COMSETTER(n) put_##n 94 95 95 /* a type for an input GUID parameter in the interface method declaration*/96 /** Type for an input GUID parameter in the interface method declaration. */ 96 97 #define GUIDPARAM GUID 97 /* a type for an output GUID parameter in the interface method declaration*/98 /** Type for an output GUID parameter in the interface method declaration. */ 98 99 #define GUIDPARAMOUT GUID* 99 100 … … 120 121 * which makes it impossible to use it for reading safearray data. 121 122 */ 122 #define ComSafeArrayInIsNull(aArg) ( aArg == NULL || *aArg== NULL)123 #define ComSafeArrayInIsNull(aArg) ((aArg) == NULL || *(aArg) == NULL) 123 124 124 125 /** … … 155 156 * which makes it impossible to use it for returning a safearray. 156 157 */ 157 #define ComSafeArrayOutIsNull(aArg) ( aArg== NULL)158 #define ComSafeArrayOutIsNull(aArg) ((aArg) == NULL) 158 159 159 160 /** … … 166 167 */ 167 168 #define ComSafeArrayOutArg(aArg) aArg 169 170 /** 171 * Version of ComSafeArrayIn for GUID. 172 * @param aArg Parameter name to wrap. 173 */ 174 #define ComSafeGUIDArrayIn(aArg) SAFEARRAY **aArg 175 176 /** 177 * Version of ComSafeArrayInIsNull for GUID. 178 * @param aArg Parameter name to wrap. 179 */ 180 #define ComSafeGUIDArrayInIsNull(aArg) ComSafeArrayInIsNull (aArg) 181 182 /** 183 * Version of ComSafeArrayInArg for GUID. 184 * @param aArg Parameter name to wrap. 185 */ 186 #define ComSafeGUIDArrayInArg(aArg) ComSafeArrayInArg (aArg) 187 188 /** 189 * Version of ComSafeArrayOut for GUID. 190 * @param aArg Parameter name to wrap. 191 */ 192 #define ComSafeGUIDArrayOut(aArg) SAFEARRAY **aArg 193 194 /** 195 * Version of ComSafeArrayOutIsNull for GUID. 196 * @param aArg Parameter name to wrap. 197 */ 198 #define ComSafeGUIDArrayOutIsNull(aArg) ComSafeArrayOutIsNull (aArg) 199 200 /** 201 * Version of ComSafeArrayOutArg for GUID. 202 * @param aArg Parameter name to wrap. 203 */ 204 #define ComSafeGUIDArrayOutArg(aArg) ComSafeArrayOutArg (aArg) 168 205 169 206 /** … … 230 267 #define TRUE PR_TRUE 231 268 232 /* makes the name of the getter interface function (n must be capitalized) */ 269 /** Input pointer argument prefix in the interface method declaration. */ 270 #define INPTR const 271 272 /** Makes the name of the getter interface function (n must be capitalized). */ 233 273 #define COMGETTER(n) Get##n 234 /* makes the name of the setter interface function (n must be capitalized)*/274 /** Makes the name of the setter interface function (n must be capitalized). */ 235 275 #define COMSETTER(n) Set##n 236 276 237 /* a type to define a raw GUID variable (better to use the Guid class) */ 277 /** 278 * Type to define a raw GUID variable (for members use the com::Guid class 279 * instead). 280 */ 238 281 #define GUID nsID 239 /* a type for an input GUID parameter in the interface method declaration*/282 /** Type for an input GUID parameter in the interface method declaration. */ 240 283 #define GUIDPARAM nsID & 241 /* a type for an output GUID parameter in the interface method declaration*/284 /** Type for an output GUID parameter in the interface method declaration. */ 242 285 #define GUIDPARAMOUT nsID ** 243 286 244 287 /* safearray input parameter macros */ 245 288 #define ComSafeArrayIn(aType, aArg) PRUint32 aArg##Size, aType *aArg 246 #define ComSafeArrayInIsNull(aArg) ( aArg== NULL)289 #define ComSafeArrayInIsNull(aArg) ((aArg) == NULL) 247 290 #define ComSafeArrayInArg(aArg) aArg##Size, aArg 248 291 249 292 /* safearray output parameter macros */ 250 293 #define ComSafeArrayOut(aType, aArg) PRUint32 *aArg##Size, aType **aArg 251 #define ComSafeArrayOutIsNull(aArg) ( aArg== NULL)294 #define ComSafeArrayOutIsNull(aArg) ((aArg) == NULL) 252 295 #define ComSafeArrayOutArg(aArg) aArg##Size, aArg 296 297 /* safearray input parameter macros for GUID */ 298 #define ComSafeGUIDArrayIn(aArg) PRUint32 aArg##Size, const nsID **aArg 299 #define ComSafeGUIDArrayInIsNull(aArg) ComSafeArrayInIsNull (aArg) 300 #define ComSafeGUIDArrayInArg(aArg) ComSafeArrayInArg (aArg) 301 302 /* safearray output parameter macros for GUID */ 303 #define ComSafeGUIDArrayOut(aArg) PRUint32 *aArg##Size, nsID ***aArg 304 #define ComSafeGUIDArrayOutIsNull(aArg) ComSafeArrayOutIsNull (aArg) 305 #define ComSafeGUIDArrayOutArg(aArg) ComSafeArrayOutArg (aArg) 253 306 254 307 /* CLSID and IID for compatibility with Win32 */ … … 257 310 258 311 /* OLE error codes */ 259 #define S_OK NS_OK312 #define S_OK ((nsresult) NS_OK) 260 313 #define E_UNEXPECTED NS_ERROR_UNEXPECTED 261 314 #define E_NOTIMPL NS_ERROR_NOT_IMPLEMENTED … … 290 343 virtual ~CComObject() { this->FinalRelease(); } 291 344 }; 292 293 /* input pointer argument to method */294 #define INPTR const295 345 296 346 /* helper functions */ … … 403 453 404 454 /** 455 * "First worst" result type. 456 * 457 * Variables of this class are used instead of HRESULT variables when it is 458 * desirable to memorize the "first worst" result code instead of the last 459 * assigned one. In other words, an assignment operation to a variable of this 460 * class will succeed only if the result code to assign has worse severity. The 461 * following table demonstrate this (the first column lists the previous result 462 * code stored in the variable, the first row lists the new result code being 463 * assigned, 'A' means the assignment will take place, '> S_OK' means a warning 464 * result code): 465 * 466 * {{{ 467 * FAILED > S_OK S_OK 468 * FAILED - - - 469 * > S_OK A - - 470 * S_OK A A - 471 * 472 * }}} 473 * 474 * On practice, you will need to use a FWResult variable when you call some COM 475 * method B after another COM method A fails and want to return the result code 476 * of A even if B also fails, but want to return the failed result code of B if 477 * A issues a warning or succeeds. 478 */ 479 class FWResult 480 { 481 482 public: 483 484 /** 485 * Constructs a new variable. Note that by default this constructor sets the 486 * result code to E_FAIL to make sure a failure is returned to the caller if 487 * the variable is never assigned another value (which is considered as the 488 * improper use of this class). 489 */ 490 FWResult (HRESULT aRC = E_FAIL) : mRC (aRC) {} 491 492 FWResult &operator= (HRESULT aRC) 493 { 494 if ((FAILED (aRC) && !FAILED (mRC)) || 495 (mRC == S_OK && aRC != S_OK)) 496 mRC = aRC; 497 498 return *this; 499 } 500 501 operator HRESULT() const { return mRC; } 502 503 HRESULT *operator&() { return &mRC; } 504 505 private: 506 507 HRESULT mRC; 508 }; 509 510 /** 405 511 * "Last worst" result type. 406 512 * … … 411 517 * severity. The following table demonstrate this (the first column lists the 412 518 * previous result code stored in the variable, the first row lists the new 413 * result code being assigned, 'A' means the assignment will take place): 519 * assigned, 'A' means the assignment will take place, '> S_OK' means a warning 520 * result code): 414 521 * 415 522 * {{{ … … 420 527 * 421 528 * }}} 529 * 530 * On practice, you will need to use a LWResult variable when you call some COM 531 * method B after COM method A fails and want to return the result code of B 532 * if B also fails, but still want to return the failed result code of A if B 533 * issues a warning or succeeds. 422 534 */ 423 535 class LWResult -
trunk/include/VBox/com/string.h
r9332 r13580 243 243 static const Bstr Null; 244 244 245 pr ivate:245 protected: 246 246 247 247 void safe_assign (const BSTR str) … … 273 273 BSTR bstr; 274 274 275 friend class Utf8Str; / / to access our raw_copy()275 friend class Utf8Str; /* to access our raw_copy() */ 276 276 }; 277 277 278 / / symmetric compare operators278 /* symmetric compare operators */ 279 279 inline bool operator== (const BSTR l, const Bstr &r) { return r.operator== (l); } 280 280 inline bool operator!= (const BSTR l, const Bstr &r) { return r.operator!= (l); } … … 479 479 static const Utf8Str Null; 480 480 481 pr ivate:481 protected: 482 482 483 483 void safe_assign (const char *s) … … 517 517 char *str; 518 518 519 friend class Bstr; / / to access our raw_copy()519 friend class Bstr; /* to access our raw_copy() */ 520 520 }; 521 521 … … 628 628 }; 629 629 630 /** 631 * THe BstrFmt class is a shortcut to <tt>Bstr (Utf8StrFmt (...))</tt>. 632 */ 633 class BstrFmt : public Bstr 634 { 635 public: 636 637 /** 638 * Constructs a new string given the format string and the list of the 639 * arguments for the format string. 640 * 641 * @param aFormat printf-like format string (in UTF-8 encoding). 642 * @param ... List of the arguments for the format string. 643 */ 644 explicit BstrFmt (const char *aFormat, ...) 645 { 646 va_list args; 647 va_start (args, aFormat); 648 raw_copy (bstr, Utf8StrFmtVA (aFormat, args)); 649 va_end (args); 650 } 651 }; 652 653 /** 654 * THe BstrFmtVA class is a shortcut to <tt>Bstr (Utf8StrFmtVA (...))</tt>. 655 */ 656 class BstrFmtVA : public Bstr 657 { 658 public: 659 660 /** 661 * Constructs a new string given the format string and the list of the 662 * arguments for the format string. 663 * 664 * @param aFormat printf-like format string (in UTF-8 encoding). 665 * @param aArgs List of arguments for the format string 666 */ 667 BstrFmtVA (const char *aFormat, va_list aArgs) 668 { 669 raw_copy (bstr, Utf8StrFmtVA (aFormat, aArgs)); 670 } 671 }; 672 630 673 } /* namespace com */ 631 674 -
trunk/include/VBox/settings.h
r12653 r13580 250 250 * Shut up MSVC complaining that auto_ptr[_ref] template instantiations (as a 251 251 * result of private data member declarations of some classes below) need to 252 * be exported too to in order to be accessible by clients. I don't252 * be exported too to in order to be accessible by clients. 253 253 * 254 254 * The alternative is to instantiate a template before the data member 255 255 * declaration with the VBOXSETTINGS_CLASS prefix, but the standard disables 256 * explicit instantiations in a foreign namespace. However, a declaration256 * explicit instantiations in a foreign namespace. In other words, a declaration 257 257 * like: 258 258 * … … 261 261 * right before the member declaration makes MSVC happy too, but this is not a 262 262 * valid C++ construct (and G++ spits it out). So, for now we just disable the 263 * warning and will come back to this problem one da tlater.263 * warning and will come back to this problem one day later. 264 264 * 265 265 * We also disable another warning (4275) saying that a DLL-exported class -
trunk/include/iprt/log.h
r12147 r13580 621 621 #ifdef LOG_USE_C99 622 622 # define LogTraceMsg(a) \ 623 _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, ">>>>> %s (%d): %M" LOG_FN_FMT, __FILE__, __LINE__, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )623 _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, ">>>>> %s (%d): " LOG_FN_FMT ": %M", __FILE__, __LINE__, __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) 624 624 #else 625 625 # define LogTraceMsg(a) \ 626 do { LogFlow((">>>>> %s (%d): " LOG_FN_FMT , __FILE__, __LINE__, __PRETTY_FUNCTION__)); LogFlow(a); } while (0)626 do { LogFlow((">>>>> %s (%d): " LOG_FN_FMT ": ", __FILE__, __LINE__, __PRETTY_FUNCTION__)); LogFlow(a); } while (0) 627 627 #endif 628 628
Note:
See TracChangeset
for help on using the changeset viewer.