Changeset 6076 in vbox for trunk/include/VBox/com
- Timestamp:
- Dec 14, 2007 7:23:03 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 26769
- Location:
- trunk/include/VBox/com
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/Guid.h
r5999 r6076 1 /* $Id$ */ 2 1 3 /** @file 2 4 * MS COM / XPCOM Abstraction Layer: … … 34 36 #include "VBox/com/string.h" 35 37 38 #include <iprt/cpputils.h> 36 39 #include <iprt/uuid.h> 37 40 … … 51 54 Guid (const RTUUID &that) { uuid = that; } 52 55 Guid (const GUID &that) { ::memcpy (&uuid, &that, sizeof (GUID)); } 53 Guid (const char *that) { 56 Guid (const char *that) 57 { 54 58 ::RTUuidClear (&uuid); 55 59 ::RTUuidFromStr (&uuid, that); 56 60 } 57 61 58 Guid &operator= (const Guid &that) { 62 Guid &operator= (const Guid &that) 63 { 59 64 ::memcpy (&uuid, &that.uuid, sizeof (RTUUID)); 60 65 return *this; 61 66 } 62 Guid &operator= (const GUID &guid) { 67 Guid &operator= (const GUID &guid) 68 { 63 69 ::memcpy (&uuid, &guid, sizeof (GUID)); 64 70 return *this; 65 71 } 66 Guid &operator= (const RTUUID &guid) { 72 Guid &operator= (const RTUUID &guid) 73 { 67 74 ::memcpy (&uuid, &guid, sizeof (RTUUID)); 68 75 return *this; 69 76 } 70 Guid &operator= (const char *str) { 77 Guid &operator= (const char *str) 78 { 71 79 ::RTUuidFromStr (&uuid, str); 72 80 return *this; … … 76 84 void clear() { ::RTUuidClear (&uuid); } 77 85 78 Utf8Str toString () const { 86 Utf8Str toString () const 87 { 79 88 char buf [RTUUID_STR_LENGTH]; 80 89 ::RTUuidToStr (&uuid, buf, RTUUID_STR_LENGTH); … … 92 101 bool operator< (const GUID &guid) const { return ::RTUuidCompare (&uuid, (PRTUUID) &guid) < 0; } 93 102 94 / / to pass instances as GUIDPARAM parameters to interface methods103 /* to pass instances as GUIDPARAM parameters to interface methods */ 95 104 operator const GUID &() const { return *(GUID *) &uuid; } 96 105 97 / / to directly pass instances to CFGLDRQueryUUID()106 /* to directly pass instances to CFGLDRQueryUUID() */ 98 107 PRTUUID ptr() { return &uuid; } 99 108 100 / / to pass instances to printf-like functions109 /* to pass instances to printf-like functions */ 101 110 PCRTUUID raw() const { return &uuid; } 102 111 103 / / to pass instances to RTUuid*() as a constant argument112 /* to pass instances to RTUuid*() as a constant argument */ 104 113 operator const RTUUID * () const { return &uuid; } 105 114 106 115 #if defined(RT_OS_WINDOWS) 107 116 108 // to assign instances to GUIDPARAMOUT parameters from within the interface method 109 const Guid &cloneTo (GUID *pguid) const { 117 /* to assign instances to GUIDPARAMOUT parameters from within the 118 * interface method */ 119 const Guid &cloneTo (GUID *pguid) const 120 { 110 121 if (pguid) { ::memcpy (pguid, &uuid, sizeof (GUID)); } 111 122 return *this; 112 123 } 113 124 114 / / to pass instances as GUIDPARAMOUT parameters to interface methods125 /* to pass instances as GUIDPARAMOUT parameters to interface methods */ 115 126 GUID *asOutParam() { return (GUID *) &uuid; } 116 127 117 128 #else 118 129 119 // to assign instances to GUIDPARAMOUT parameters from within the interface method 120 const Guid &cloneTo (nsID **ppguid) const { 130 /* to assign instances to GUIDPARAMOUT parameters from within the 131 * interface method */ 132 const Guid &cloneTo (nsID **ppguid) const 133 { 121 134 if (ppguid) { *ppguid = (nsID *) nsMemory::Clone (&uuid, sizeof (nsID)); } 122 135 return *this; 123 136 } 124 137 125 // internal helper class for asOutParam() 126 class GuidOutParam { 138 /* internal helper class for asOutParam() */ 139 class GuidOutParam 140 { 127 141 GuidOutParam (Guid &guid) : ptr (0), outer (guid) { outer.clear(); } 128 142 nsID *ptr; … … 132 146 public: 133 147 operator nsID **() { return &ptr; } 134 ~GuidOutParam() { 148 ~GuidOutParam() 149 { 135 150 if (ptr && outer.isEmpty()) { outer = *ptr; nsMemory::Free (ptr); } 136 151 } … … 138 153 }; 139 154 140 / / to pass instances as GUIDPARAMOUT parameters to interface methods155 /* to pass instances as GUIDPARAMOUT parameters to interface methods */ 141 156 GuidOutParam asOutParam() { return GuidOutParam (*this); } 142 157 143 158 #endif 144 159 145 // to directly test GUIDPARAM interface method's parameters 146 static BOOL isEmpty (const GUID &guid) { return ::RTUuidIsNull ((PRTUUID) &guid); } 160 /* to directly test GUIDPARAM interface method's parameters */ 161 static bool isEmpty (const GUID &guid) 162 { 163 return ::RTUuidIsNull ((PRTUUID) &guid) != 0; 164 } 165 166 /** 167 * Static immutable empty object. May be used for comparison purposes. 168 */ 169 static const Guid Empty; 147 170 148 171 private: … … 151 174 }; 152 175 153 #if defined (_MSC_VER) 154 155 // work around error C2593 of the stupid MSVC 7.x ambiguity resolver 156 inline bool operator! (const Guid& guid) { return !bool (guid); } 157 inline bool operator&& (const Guid& guid, bool b) { return bool (guid) && b; } 158 inline bool operator|| (const Guid& guid, bool b) { return bool (guid) || b; } 159 inline bool operator&& (bool b, const Guid& guid) { return b && bool (guid); } 160 inline bool operator|| (bool b, const Guid& guid) { return b || bool (guid); } 161 162 #endif 176 /* work around error C2593 of the stupid MSVC 7.x ambiguity resolver */ 177 WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP (Guid); 163 178 164 179 } /* namespace com */ 165 180 166 #endif 181 #endif /* ___VBox_com_Guid_h */ 167 182 -
trunk/include/VBox/com/assert.h
r5999 r6076 79 79 80 80 /** 81 * A special version of AssertComRC that evaluates the given expression and 82 * throws it if the result code is failed. 83 * 84 * @param rc COM result code 85 * @param eval the expression to evaluate 86 */ 87 #define AssertComRCThrow(rc, eval) \ 88 if (1) { AssertComRC (rc); if (!SUCCEEDED (rc)) { throw (eval); } } else do {} while (0) 89 90 /** 81 91 * A special version of AssertComRC that just breaks if the result code is 82 92 * failed. … … 88 98 89 99 /** 100 * A special version of AssertComRC that just throws @a rc if the result code is 101 * failed. 102 * 103 * @param rc COM result code 104 */ 105 #define AssertComRCThrowRC(rc) \ 106 if (1) { AssertComRC (rc); if (!SUCCEEDED (rc)) { throw rc; } } else do {} while (0) 107 108 /** 90 109 * Checks whether the given COM result code is successful. 91 110 * If not, executes the return statement with this result code. … … 104 123 #define CheckComRCBreakRC(rc) \ 105 124 if (1) { if (!SUCCEEDED (rc)) { break; } } else do {} while (0) 125 126 /** 127 * Checks whether the given COM result code is successful. 128 * If not, throws the given COM result. 129 * 130 * @param rc COM result code 131 */ 132 #define CheckComRCThrowRC(rc) \ 133 if (1) { if (!SUCCEEDED (rc)) { throw rc; } } else do {} while (0) 106 134 107 135 /* -
trunk/include/VBox/com/defs.h
r5999 r6076 77 77 #define COM_IIDOF(I) _ATL_IIDOF (I) 78 78 79 #else / / defined (RT_OS_WINDOWS)79 #else /* defined (RT_OS_WINDOWS) */ 80 80 81 81 #error "VBOX_WITH_XPCOM is not defined!" 82 82 83 #endif / / defined (RT_OS_WINDOWS)84 85 #else / / !defined (VBOX_WITH_XPCOM)83 #endif /* defined (RT_OS_WINDOWS) */ 84 85 #else /* !defined (VBOX_WITH_XPCOM) */ 86 86 87 87 // XPCOM … … 101 101 #undef TRUE 102 102 103 #endif / / defined (RT_OS_OS2)103 #endif /* defined (RT_OS_OS2) */ 104 104 105 105 #if defined (RT_OS_DARWIN) … … 289 289 } 290 290 291 #endif / / !defined (RT_OS_WINDOWS)291 #endif /* !defined (RT_OS_WINDOWS) */ 292 292 293 293 /** … … 304 304 #endif 305 305 306 #endif 307 306 #endif /* ___VBox_com_defs_h */ 307 -
trunk/include/VBox/com/string.h
r5999 r6076 1 /* $Id$ */ 2 1 3 /** @file 2 4 * MS COM / XPCOM Abstraction Layer: … … 36 38 37 39 #include <iprt/string.h> 40 #include <iprt/cpputils.h> 38 41 #include <iprt/alloc.h> 39 42 … … 208 211 BSTR *asOutParam() { setNull(); return &bstr; } 209 212 213 /** 214 * Static immutable null object. May be used for comparison purposes. 215 */ 216 static const Bstr Null; 217 210 218 private: 211 219 … … 417 425 char **asOutParam() { setNull(); return &str; } 418 426 427 /** 428 * Static immutable null object. May be used for comparison purposes. 429 */ 430 static const Utf8Str Null; 431 419 432 private: 420 433 … … 568 581 } /* namespace com */ 569 582 570 #endif 583 #endif /* ___VBox_com_string_h */
Note:
See TracChangeset
for help on using the changeset viewer.