Changeset 26553 in vbox
- Timestamp:
- Feb 15, 2010 5:34:29 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/Guid.h
r26550 r26553 97 97 { 98 98 ::RTUuidClear (&uuid); 99 if (!that.is Empty())99 if (!that.isNull()) 100 100 ::RTUuidFromUtf16(&uuid, that.raw()); 101 101 refresh(); … … 145 145 } 146 146 147 Bstr toUtf16 () const147 Bstr toUtf16 () const 148 148 { 149 149 if (isEmpty()) -
trunk/include/VBox/com/string.h
r26552 r26553 3 3 /** @file 4 4 * MS COM / XPCOM Abstraction Layer: 5 * UTF-8 and UTF-16 string classes5 * Smart string classes declaration 6 6 */ 7 7 … … 59 59 60 60 /** 61 * String class used universally in Main for COM-style Utf-16 strings. 62 * Unfortunately COM on Windows uses UTF-16 everywhere, requiring conversions 63 * back and forth since most of VirtualBox and our libraries use UTF-8. 64 * The Bstr class makes such conversions easier. 65 * 66 * Whereas the BSTR identifier is a typedef for a pointer to a wide character 67 * array (const char *uint_16 effectively, depending on the platform), 68 * the Bstr class is a fully featured string class with memory management 69 * for such strings. 70 * 71 * Bstr uses COM/XPCOM-provided memory management routines (SysAlloc* etc.) 72 * to allocate and free string buffers. This makes it possible to use it as 73 * a type of member variables of COM/XPCOM components and pass their values 74 * to callers through component methods' output parameters using the #cloneTo() 75 * operation. Also, the class can adopt (take ownership of) string buffers 76 * returned in output parameters of COM methods using the #asOutParam() 77 * operation and correctly free them afterwards. 78 * 79 * As opposed to the Ut8Str class, which is very efficient, Bstr does not 80 * cache the length of its member string. As a result, copying Bstr's is 81 * more expensive, and Bstr really should only be used to capture arguments 82 * from and return data to public COM methods. 83 * 84 * Starting with VirtualBox 3.2, like Utf8Str, Bstr no longer differentiates 85 * between NULL strings and empty strings. In other words, Bstr("") and 86 * Bstr(NULL) behave the same. In both cases, Bstr allocates no memory, 87 * reports a zero length and zero allocated bytes for both, and returns an 88 * empty C wide string from raw(). 61 * Helper class that represents the |BSTR| type and hides platform-specific 62 * implementation details. 63 * 64 * This class uses COM/XPCOM-provided memory management routines to allocate 65 * and free string buffers. This makes it possible to: 66 * - use it as a type of member variables of COM/XPCOM components and pass 67 * their values to callers through component methods' output parameters 68 * using the #cloneTo() operation; 69 * - adopt (take ownership of) string buffers returned in output parameters 70 * of COM methods using the #asOutParam() operation and correctly free them 71 * afterwards. 89 72 */ 90 73 class Bstr … … 92 75 public: 93 76 94 /** 95 * Creates an empty string that has no memory allocated. 96 */ 97 Bstr() 98 : m_bstr(NULL) 99 { 100 } 101 102 /** 103 * Creates a copy of another Bstr. 104 * 105 * This allocates s.length() + 1 wide characters for the new instance, unless s is empty. 106 * 107 * @param s The source string. 108 * 109 * @throws std::bad_alloc 110 */ 111 Bstr(const Bstr &s) 112 { 113 copyFrom(s); 114 } 115 116 /** 117 * Creates a copy of a wide char string buffer. 118 * 119 * This allocates SysStringLen(pw) + 1 wide characters for the new instance, unless s is empty. 120 * 121 * @param pcsz The source string. 122 * 123 * @throws std::bad_alloc 124 */ 125 Bstr(CBSTR pw) 126 { 127 copyFrom(pw); 128 } 77 typedef BSTR String; 78 typedef CBSTR ConstString; 79 80 Bstr() : bstr(NULL) {} 81 82 Bstr(const Bstr &that) : bstr(NULL) { raw_copy(bstr, that.bstr); } 83 Bstr(CBSTR that) : bstr(NULL) { raw_copy(bstr, that); } 129 84 130 85 #if defined (VBOX_WITH_XPCOM) 131 Bstr(const wchar_t * pw)86 Bstr(const wchar_t *that) : bstr(NULL) 132 87 { 133 88 AssertCompile(sizeof(wchar_t) == sizeof(OLECHAR)); 134 copyFrom((CBSTR)pw);89 raw_copy(bstr, (CBSTR)that); 135 90 } 136 91 #endif 137 92 138 139 /** 140 * Creates a copy of an IPRT MiniString (which includes Utf8Str). 141 * 142 * This allocates s.length() + 1 wide characters for the new instance, unless s is empty. 143 * 144 * @param pcsz The source string. 145 * 146 * @throws std::bad_alloc 147 */ 148 Bstr(const iprt::MiniString &s) 149 { 150 copyFrom(s.c_str()); // @todo the source string length is know, we can probably speed this up 151 } 152 153 /** 154 * Creates a copy of a C string. 155 * 156 * This allocates strlen(pcsz) + 1 bytes for the new instance, unless s is empty. 157 * 158 * @param pcsz The source string. 159 * 160 * @throws std::bad_alloc 161 */ 162 Bstr(const char *pcsz) 163 { 164 copyFrom(pcsz); 165 } 166 167 /** 168 * String length in wide characters. 169 * 170 * Returns the length of the member string, which is equal to SysStringLen(raw()). 171 * In other words, this returns neither bytes nor the number of unicode codepoints. 172 * 173 * As opposed to Utf8Str::length(), this is _not_ cached and expensive. 174 */ 175 size_t length() const 176 { 177 return ::SysStringLen(m_bstr); 178 } 179 180 /** 181 * Deallocates all memory. 182 */ 183 inline void setNull() 184 { 185 cleanup(); 186 } 187 188 /** 189 * Returns a const pointer to the member string. If the member string is empty, 190 * returns a pointer to a static null character. 191 * @return 192 */ 193 CBSTR raw() const 194 { 195 return (m_bstr) ? m_bstr : (CBSTR)L""; 196 } 197 198 /** 199 * Empty string or not? 200 * 201 * Returns true if the member string has no length. 202 * 203 * @returns true if empty, false if not. 204 */ 205 bool isEmpty() const 206 { 207 return (m_bstr == NULL); 208 } 209 210 /** Case sensitivity selector. */ 211 enum CaseSensitivity 212 { 213 CaseSensitive, 214 CaseInsensitive 215 }; 216 217 int compare(CBSTR str, CaseSensitivity cs = CaseSensitive) const 218 { 219 if (m_bstr == str) 220 return 0; 221 if (m_bstr == NULL) 222 return -1; 223 if (str == NULL) 224 return 1; 225 226 if (cs == CaseSensitive) 227 return ::RTUtf16Cmp((PRTUTF16)m_bstr, (PRTUTF16)str); 228 else 229 return ::RTUtf16ICmp((PRTUTF16)m_bstr, (PRTUTF16)str); 230 } 231 232 int compare(const Bstr &bstr, CaseSensitivity cs = CaseSensitive) const 233 { 234 return compare(bstr.raw(), cs); 235 } 236 237 /** @name Comparison operators. 238 * @{ */ 239 bool operator==(const Bstr &that) const { return !compare(that.raw()); } 240 bool operator!=(const Bstr &that) const { return !!compare(that.raw()); } 241 bool operator<( const Bstr &that) const { return compare(that.raw()) < 0; } 242 bool operator>( const Bstr &that) const { return compare(that.raw()) > 0; } 243 93 Bstr(const iprt::MiniString &that); 94 Bstr(const char *that); 95 96 /** Shortcut that calls #alloc(aSize) right after object creation. */ 97 Bstr(size_t aSize) : bstr(NULL) { alloc(aSize); } 98 99 ~Bstr() { setNull(); } 100 101 Bstr &operator=(const Bstr &that) { safe_assign(that.bstr); return *this; } 102 Bstr &operator=(CBSTR that) { safe_assign(that); return *this; } 103 104 Bstr &operator=(const Utf8Str &that); 105 Bstr &operator=(const char *that); 106 107 Bstr &setNull() 108 { 109 if (bstr) 110 { 111 ::SysFreeString(bstr); 112 bstr = NULL; 113 } 114 return *this; 115 } 116 117 Bstr &setNullIfEmpty() 118 { 119 if (bstr && *bstr == 0) 120 { 121 ::SysFreeString(bstr); 122 bstr = NULL; 123 } 124 return *this; 125 } 126 127 /** 128 * Allocates memory for a string capable to store \a aSize - 1 characters; 129 * in other words, aSize includes the terminating zero character. If \a aSize 130 * is zero, or if a memory allocation error occurs, this object will become null. 131 */ 132 Bstr &alloc(size_t aSize) 133 { 134 setNull(); 135 if (aSize) 136 { 137 unsigned int size = (unsigned int) aSize; Assert(size == aSize); 138 bstr = ::SysAllocStringLen(NULL, size - 1); 139 if (bstr) 140 bstr[0] = 0; 141 } 142 return *this; 143 } 144 145 int compare(CBSTR str) const 146 { 147 return ::RTUtf16Cmp((PRTUTF16) bstr, (PRTUTF16) str); 148 } 149 150 int compare(BSTR str) const 151 { 152 return ::RTUtf16Cmp((PRTUTF16) bstr, (PRTUTF16) str); 153 } 154 155 bool operator==(const Bstr &that) const { return !compare(that.bstr); } 156 bool operator!=(const Bstr &that) const { return !!compare(that.bstr); } 244 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) 161 bool operator!=(const wchar_t *that) const 162 { 163 AssertCompile(sizeof(wchar_t) == sizeof(OLECHAR)); 164 return !!compare((CBSTR) that); 165 } 166 bool operator==(const wchar_t *that) const 167 { 168 AssertCompile(sizeof(wchar_t) == sizeof(OLECHAR)); 169 return !compare((CBSTR) that); 170 } 171 #endif 172 245 173 bool operator!=(CBSTR that) const { return !!compare(that); } 246 bool operator<( CBSTR that) const { return compare(that) < 0; } 247 bool operator>( CBSTR that) const { return compare(that) > 0; } 248 249 /** @} */ 174 bool operator!=(BSTR that) const { return !!compare(that); } 175 bool operator<(const Bstr &that) const { return compare(that.bstr) < 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) 179 bool operator<(const wchar_t *that) const 180 { 181 AssertCompile(sizeof(wchar_t) == sizeof(OLECHAR)); 182 return compare((CBSTR) that) < 0; 183 } 184 #endif 185 186 int compareIgnoreCase(CBSTR str) const 187 { 188 return ::RTUtf16LocaleICmp(bstr, str); 189 } 190 191 bool isNull() const { return bstr == NULL; } 192 operator bool() const { return !isNull(); } 193 194 bool isEmpty() const { return isNull() || *bstr == 0; } 195 196 size_t length() const { return isNull() ? 0 : ::RTUtf16Len((PRTUTF16) bstr); } 250 197 251 198 /** Intended to to pass instances as |CBSTR| input parameters to methods. */ 252 operator CBSTR() const { return raw(); }199 operator CBSTR() const { return bstr; } 253 200 254 201 /** … … 257 204 * input BSTR parameters of interface methods are not const. 258 205 */ 259 operator BSTR() { return (BSTR)raw(); } 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; } 213 214 /** 215 * Returns a non-const raw pointer that allows to modify the string directly. 216 * @warning 217 * Be sure not to modify data beyond the allocated memory! The 218 * guaranteed size of the allocated memory is at least #length() 219 * bytes after creation and after every assignment operation. 220 */ 221 BSTR mutableRaw() { return bstr; } 260 222 261 223 /** … … 263 225 * within the interface method. Transfers the ownership of the duplicated 264 226 * string to the caller. 265 * 266 * This allocates a single 0 byte in the target if the member string is empty. 267 */ 268 const Bstr& cloneTo(BSTR *pstr) const 227 */ 228 const Bstr &cloneTo(BSTR *pstr) const 269 229 { 270 230 if (pstr) 271 *pstr = ::SysAllocString((const OLECHAR*)raw()); 272 // raw() never returns NULL, so we always allocate something here 231 { 232 *pstr = NULL; 233 raw_copy(*pstr, bstr); 234 } 273 235 return *this; 274 236 } … … 281 243 * As opposed to cloneTo(), this method doesn't create a copy of the 282 244 * string. 283 * 284 * This allocates a single 0 byte in the target if the member string is empty. 285 */ 286 Bstr& detachTo(BSTR *pstr) 287 { 288 *pstr = (m_bstr) ? m_bstr : ::SysAllocString((const OLECHAR*)""); 289 m_bstr = NULL; 290 return *this; 291 } 245 */ 246 Bstr &detachTo(BSTR *pstr) 247 { 248 *pstr = bstr; 249 bstr = NULL; 250 return *this; 251 } 252 253 /** 254 * Intended to assign copies of instances to |char *| out parameters from 255 * within the interface method. Transfers the ownership of the duplicated 256 * string to the caller. 257 */ 258 const Bstr &cloneTo(char **pstr) const; 292 259 293 260 /** … … 295 262 * Takes the ownership of the returned data. 296 263 */ 297 BSTR* asOutParam() 298 { 299 cleanup(); 300 return &m_bstr; 301 } 264 BSTR *asOutParam() { setNull(); return &bstr; } 302 265 303 266 /** … … 308 271 protected: 309 272 310 /** 311 * Destructor implementation, also used to clean up in operator=() before 312 * assigning a new string. 313 */ 314 void cleanup() 315 { 316 if (m_bstr) 317 { 318 ::SysFreeString(m_bstr); 319 m_bstr = NULL; 320 } 321 } 322 323 /** 324 * Protected internal helper which allocates memory for a string capable of 325 * storing \a aSize - 1 characters (not bytes, not codepoints); in other words, 326 * aSize includes the terminating null character. 327 * 328 * Does NOT call cleanup() before allocating! 329 * 330 * @throws std::bad_alloc On allocation failure. The object is left describing 331 * a NULL string. 332 */ 333 void alloc(size_t cw) 334 { 335 if (cw) 336 { 337 m_bstr = ::SysAllocStringLen(NULL, (unsigned int)cw - 1); 338 #ifdef RT_EXCEPTIONS_ENABLED 339 if (!m_bstr) 340 throw std::bad_alloc(); 341 #endif 342 } 343 } 344 345 /** 346 * Protected internal helper to copy a string, ignoring the previous object state. 347 * 348 * copyFrom() unconditionally sets the members to a copy of the given other 349 * strings and makes no assumptions about previous contents. Can therefore be 350 * used both in copy constructors, when member variables have no defined value, 351 * and in assignments after having called cleanup(). 352 * 353 * This variant copies from another Bstr. Since Bstr does _not_ cache string lengths, 354 * this is not fast. 355 * 356 * @param s The source string. 357 * 358 * @throws std::bad_alloc On allocation failure. The object is left describing 359 * a NULL string. 360 */ 361 void copyFrom(const Bstr &s) 362 { 363 copyFrom(s.raw()); 364 } 365 366 /** 367 * Protected internal helper to copy a string, ignoring the previous object state. 368 * 369 * See copyFrom() above. 370 * 371 * This variant copies from a wide char C string. 372 * 373 * @param pcsz The source string. 374 * 375 * @throws std::bad_alloc On allocation failure. The object is left describing 376 * a NULL string. 377 */ 378 void copyFrom(CBSTR pw) 379 { 380 size_t cwLength; 381 if ( (pw) 382 && ((cwLength = ::SysStringLen((BSTR)pw))) 383 ) 384 { 385 size_t cwAllocated = cwLength + 1; 386 alloc(cwAllocated); 387 memcpy(m_bstr, pw, cwAllocated * sizeof(OLECHAR)); // include 0 terminator 388 } 389 else 390 m_bstr = NULL; 391 } 392 393 /** 394 * Protected internal helper to copy a string, ignoring the previous object state. 395 * 396 * See copyFrom() above. 397 * 398 * This variant converts from a Utf-8 C string. 399 * 400 * @param pcsz The source string. 401 * 402 * @throws std::bad_alloc On allocation failure. The object is left describing 403 * a NULL string. 404 */ 405 void copyFrom(const char *pcsz) 406 { 407 if (pcsz && *pcsz) 408 { 409 // @todo r=dj apparently this was copied twice in the original because our buffers 410 // use memory from SysAllocMem and IPRT doesn't, but check if this can be made faster 273 void safe_assign(CBSTR str) 274 { 275 if (bstr != str) 276 { 277 setNull(); 278 raw_copy(bstr, str); 279 } 280 } 281 282 inline static void raw_copy(BSTR &ls, CBSTR rs) 283 { 284 if (rs) 285 ls = ::SysAllocString((const OLECHAR *) rs); 286 } 287 288 inline static void raw_copy(BSTR &ls, const char *rs) 289 { 290 if (rs) 291 { 411 292 PRTUTF16 s = NULL; 412 ::RTStrToUtf16( pcsz, &s);413 copyFrom((BSTR)s); // @todo r=dj this is not exception safe293 ::RTStrToUtf16(rs, &s); 294 raw_copy(ls, (BSTR)s); 414 295 ::RTUtf16Free(s); 415 296 } 416 else417 m_bstr = NULL; 418 }419 420 BSTR m_bstr; /**< The string buffer.*/297 } 298 299 BSTR bstr; 300 301 friend class Utf8Str; /* to access our raw_copy() */ 421 302 }; 422 303 … … 430 311 431 312 /** 432 * String class used universally in Main for Utf-8 strings. 433 * 434 * This is based on iprt::MiniString, to which some functionality has been 435 * moved. Here we keep things that are specific to Main, such as conversions 436 * with UTF-16 strings (Bstr). 437 * 438 * Like iprt::MiniString, Utf8Str does not differentiate between NULL strings 439 * and empty strings. In other words, Utf8Str("") and Utf8Str(NULL) 440 * behave the same. In both cases, MiniString allocates no memory, reports 441 * a zero length and zero allocated bytes for both, and returns an empty 442 * C string from c_str(). 313 * Helper class that represents UTF8 (|char *|) strings. Useful in 314 * conjunction with Bstr to simplify conversions between UTF16 (|BSTR|) 315 * and UTF8. 316 * 317 * This class uses COM/XPCOM-provided memory management routines to allocate 318 * and free string buffers. This makes it possible to: 319 * - use it as a type of member variables of COM/XPCOM components and pass 320 * their values to callers through component methods' output parameters 321 * using the #cloneTo() operation; 322 * - adopt (take ownership of) string buffers returned in output parameters 323 * of COM methods using the #asOutParam() operation and correctly free them 324 * afterwards. 443 325 */ 444 326 class Utf8Str : public iprt::MiniString … … 458 340 Utf8Str(const Bstr &that) 459 341 { 460 copyFrom(that .raw());342 copyFrom(that); 461 343 } 462 344 … … 481 363 { 482 364 cleanup(); 483 copyFrom(that .raw());365 copyFrom(that); 484 366 return *this; 485 367 } … … 497 379 * caller. 498 380 * 499 * This allocates a single 0 byte in the target if the member string is empty.500 *501 381 * @remarks The returned string must be freed by RTStrFree, not RTMemFree. 502 382 */ 503 383 const Utf8Str& cloneTo(char **pstr) const 504 384 { 505 if (pstr) 506 { 507 *pstr = RTStrDup(raw()); 508 #ifdef RT_EXCEPTIONS_ENABLED 509 if (!*pstr) 510 throw std::bad_alloc(); 511 #endif 512 } 385 if (pstr) /** @todo r=bird: This needs to if m_psz is NULL. Shouldn't it also throw std::bad_alloc? */ 386 *pstr = RTStrDup(m_psz); 387 return *this; 388 } 389 390 /** 391 * Intended to assign instances to |char *| out parameters from within the 392 * interface method. Transfers the ownership of the original string to the 393 * caller and resets the instance to null. 394 * 395 * As opposed to cloneTo(), this method doesn't create a copy of the 396 * string. 397 */ 398 Utf8Str& detachTo(char **pstr) 399 { 400 *pstr = m_psz; 401 m_psz = NULL; 402 m_cbAllocated = 0; 403 m_cbLength = 0; 513 404 return *this; 514 405 } … … 518 409 * interface method. Transfers the ownership of the duplicated string to the 519 410 * caller. 520 *521 * This allocates a single 0 byte in the target if the member string is empty.522 411 */ 523 412 const Utf8Str& cloneTo(BSTR *pstr) const … … 525 414 if (pstr) 526 415 { 527 Bstr bstr(c_str());528 416 *pstr = NULL; 529 bstr.detachTo(pstr);417 Bstr::raw_copy(*pstr, m_psz); 530 418 } 531 419 return *this; … … 619 507 if (s) 620 508 { 621 RTUtf16ToUtf8((PRTUTF16)s, &m_psz); /** @todo r=bird: This technically requires using RTStrFree, ministring::cleanup() uses RTMemFree. */ 622 #ifdef RT_EXCEPTIONS_ENABLED 623 if (!m_psz) 624 throw std::bad_alloc(); 625 #endif 509 RTUtf16ToUtf8((PRTUTF16)s, &m_psz); /** @todo r=bird: This isn't throwing std::bad_alloc / handling return codes. 510 * Also, this technically requires using RTStrFree, ministring::cleanup() uses RTMemFree. */ 626 511 m_cbLength = strlen(m_psz); /** @todo optimize by using a different RTUtf* function */ 627 512 m_cbAllocated = m_cbLength + 1; … … 640 525 // work around error C2593 of the stupid MSVC 7.x ambiguity resolver 641 526 WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Bstr) 527 528 //////////////////////////////////////////////////////////////////////////////// 529 530 // inlined Bstr members that depend on Utf8Str 531 532 inline Bstr::Bstr(const iprt::MiniString &that) 533 : bstr(NULL) 534 { 535 raw_copy(bstr, that.c_str()); 536 } 537 538 inline Bstr::Bstr(const char *that) 539 : bstr(NULL) 540 { 541 raw_copy(bstr, that); 542 } 543 544 inline Bstr &Bstr::operator=(const Utf8Str &that) 545 { 546 setNull(); 547 raw_copy(bstr, that.c_str()); 548 return *this; 549 } 550 inline Bstr &Bstr::operator=(const char *that) 551 { 552 setNull(); 553 raw_copy(bstr, that); 554 return *this; 555 } 556 557 inline const Bstr& Bstr::cloneTo(char **pstr) const 558 { 559 if (pstr) 560 { 561 Utf8Str ustr(*this); 562 ustr.detachTo(pstr); 563 } 564 return *this; 565 } 642 566 643 567 //////////////////////////////////////////////////////////////////////////////// … … 730 654 va_list args; 731 655 va_start(args, aFormat); 732 copyFrom(Utf8StrFmtVA(aFormat, args).c_str());656 raw_copy(bstr, Utf8StrFmtVA(aFormat, args).c_str()); 733 657 va_end(args); 734 658 } … … 751 675 BstrFmtVA(const char *aFormat, va_list aArgs) 752 676 { 753 copyFrom(Utf8StrFmtVA(aFormat, aArgs).c_str());677 raw_copy(bstr, Utf8StrFmtVA(aFormat, aArgs).c_str()); 754 678 } 755 679 }; -
trunk/include/iprt/cpp/ministring.h
r26550 r26553 45 45 * else except IPRT memory management functions. Semantics are like in 46 46 * std::string, except it can do a lot less. 47 *48 * Note that MiniString does not differentiate between NULL strings and49 * empty strings. In other words, MiniString("") and MiniString(NULL)50 * behave the same. In both cases, MiniString allocates no memory, reports51 * a zero length and zero allocated bytes for both, and returns an empty52 * C string from c_str().53 47 */ 54 48 #ifdef VBOX … … 77 71 * Creates a copy of another MiniString. 78 72 * 79 * This allocates s.length() + 1 bytes for the new instance , unless s is empty.73 * This allocates s.length() + 1 bytes for the new instance. 80 74 * 81 75 * @param s The source string. … … 89 83 90 84 /** 91 * Creates a copy of a C string.92 * 93 * This allocates strlen(pcsz) + 1 bytes for the new instance , unless s is empty.85 * Creates a copy of another MiniString. 86 * 87 * This allocates strlen(pcsz) + 1 bytes for the new instance. 94 88 * 95 89 * @param pcsz The source string. … … 129 123 * 130 124 * Returns the number of bytes allocated in the internal string buffer, which is 131 * at least length() + 1 if length() > 0. Returns 0 for an empty string.125 * at least length() + 1 if length() > 0. 132 126 * 133 127 * @returns m_cbAllocated. … … 281 275 * Returns the byte at the given index, or a null byte if the index is not 282 276 * smaller than length(). This does _not_ count codepoints but simply points 283 * into the member C string ; the result may not be a valid UTF-8 character.277 * into the member C string. 284 278 * 285 279 * @param i The index into the string buffer. … … 295 289 /** 296 290 * Returns the contained string as a C-style const char* pointer. 297 * This never returns NULL; if the string is empty, returns a298 * pointer to static null byte.299 291 * 300 292 * @returns const pointer to C-style string. … … 302 294 inline const char *c_str() const 303 295 { 304 return (m_psz) ? m_psz : "";296 return m_psz; 305 297 } 306 298 307 299 /** 308 300 * Like c_str(), for compatibility with lots of VirtualBox Main code. 309 * This never returns NULL; if the string is empty, returns a310 * pointer to static null byte.311 301 * 312 302 * @returns const pointer to C-style string. … … 314 304 inline const char *raw() const 315 305 { 316 return (m_psz) ? m_psz : "";317 } 318 319 /** 320 * Empt y string or not?306 return m_psz; 307 } 308 309 /** 310 * Emptry string or not? 321 311 * 322 312 * Returns true if the member string has no length. This states nothing about … … 482 472 483 473 /** 474 * Hide operator bool() to force people to use isEmpty() explicitly. 475 */ 476 operator bool() const { return false; } 477 478 /** 484 479 * Destructor implementation, also used to clean up in operator=() before 485 480 * assigning a new string. … … 497 492 498 493 /** 499 * Protected internal helper to copy a string, ignoring the previous object state. 494 * Protected internal helper for copy a string that completely ignors the 495 * current object state. 500 496 * 501 497 * copyFrom() unconditionally sets the members to a copy of the given other … … 505 501 * 506 502 * This variant copies from another MiniString and is fast since 507 * the length of thesource string is known.503 * the length of source string is known. 508 504 * 509 505 * @param s The source string. … … 537 533 538 534 /** 539 * Protected internal helper to copy a string, ignoring the previous object state. 535 * Protected internal helper for copy a string that completely ignors the 536 * current object state. 540 537 * 541 538 * See copyFrom() above. … … 575 572 } 576 573 577 private:578 579 /**580 * Hide operator bool() to force people to use isEmpty() explicitly.581 */582 operator bool() const;583 584 protected:585 586 574 char *m_psz; /**< The string buffer. */ 587 575 size_t m_cbLength; /**< strlen(m_psz) - i.e. no terminator included. */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDHCPServer.cpp
r26550 r26553 230 230 231 231 ComPtr<IHostNetworkInterface> hif; 232 CHECK_ERROR(host, FindHostNetworkInterfaceByName(Bstr(pIfName) , hif.asOutParam()));232 CHECK_ERROR(host, FindHostNetworkInterfaceByName(Bstr(pIfName).mutableRaw(), hif.asOutParam())); 233 233 if(FAILED(rc)) 234 234 return errorArgument("could not find interface '%s'", pIfName); … … 244 244 245 245 ComPtr<IDHCPServer> svr; 246 rc = a->virtualBox->FindDHCPServerByNetworkName(NetName , svr.asOutParam());246 rc = a->virtualBox->FindDHCPServerByNetworkName(NetName.mutableRaw(), svr.asOutParam()); 247 247 if(enmCode == OP_ADD) 248 248 { … … 250 250 return errorArgument("dhcp server already exists"); 251 251 252 CHECK_ERROR(a->virtualBox, CreateDHCPServer(NetName. raw(), svr.asOutParam()));252 CHECK_ERROR(a->virtualBox, CreateDHCPServer(NetName.mutableRaw(), svr.asOutParam())); 253 253 if(FAILED(rc)) 254 254 return errorArgument("failed to create server"); … … 263 263 if (pIp || pNetmask || pLowerIp || pUpperIp) 264 264 { 265 CHECK_ERROR(svr, SetConfiguration (Bstr(pIp).raw(), Bstr(pNetmask), Bstr(pLowerIp), Bstr(pUpperIp)));265 CHECK_ERROR(svr, SetConfiguration (Bstr(pIp).mutableRaw(), Bstr(pNetmask).mutableRaw(), Bstr(pLowerIp).mutableRaw(), Bstr(pUpperIp).mutableRaw())); 266 266 if(FAILED(rc)) 267 267 return errorArgument("failed to set configuration"); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r26550 r26553 281 281 bool doClose = false; 282 282 283 if (!comment.is Empty())283 if (!comment.isNull()) 284 284 { 285 285 CHECK_ERROR(hardDisk,COMSETTER(Description)(comment)); … … 1038 1038 if (FAILED(rc)) break; 1039 1039 1040 if (!port.is Empty())1040 if (!port.isNull()) 1041 1041 server = BstrFmt ("%ls:%ls", server.raw(), port.raw()); 1042 1042 … … 1047 1047 server.detachTo (values.appendedRaw()); 1048 1048 Bstr ("TargetName").detachTo (names.appendedRaw()); 1049 target.detachTo (values.appendedRaw());1050 1051 if (!lun.is Empty())1049 target.detachTo (values.appendedRaw()); 1050 1051 if (!lun.isNull()) 1052 1052 { 1053 1053 Bstr ("LUN").detachTo (names.appendedRaw()); 1054 1054 lun.detachTo (values.appendedRaw()); 1055 1055 } 1056 if (!username.is Empty())1056 if (!username.isNull()) 1057 1057 { 1058 1058 Bstr ("InitiatorUsername").detachTo (names.appendedRaw()); 1059 1059 username.detachTo (values.appendedRaw()); 1060 1060 } 1061 if (!password.is Empty())1061 if (!password.isNull()) 1062 1062 { 1063 1063 Bstr ("InitiatorSecret").detachTo (names.appendedRaw()); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp
r26550 r26553 441 441 if (!f.mActive.isNull()) 442 442 CHECK_ERROR_BREAK (flt, COMSETTER(Active) (f.mActive)); 443 if (!f.mVendorId.is Empty())444 CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId));445 if (!f.mProductId.is Empty())446 CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId ));447 if (!f.mRevision.is Empty())448 CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision ));449 if (!f.mManufacturer.is Empty())450 CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer ));451 if (!f.mSerialNumber.is Empty())452 CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber ));443 if (!f.mVendorId.isNull()) 444 CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId.setNullIfEmpty())); 445 if (!f.mProductId.isNull()) 446 CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId.setNullIfEmpty())); 447 if (!f.mRevision.isNull()) 448 CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision.setNullIfEmpty())); 449 if (!f.mManufacturer.isNull()) 450 CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer.setNullIfEmpty())); 451 if (!f.mSerialNumber.isNull()) 452 CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber.setNullIfEmpty())); 453 453 if (!f.mMaskedInterfaces.isNull()) 454 454 CHECK_ERROR_BREAK (flt, COMSETTER(MaskedInterfaces) (f.mMaskedInterfaces)); … … 466 466 if (!f.mActive.isNull()) 467 467 CHECK_ERROR_BREAK (flt, COMSETTER(Active) (f.mActive)); 468 if (!f.mVendorId.is Empty())469 CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId ));470 if (!f.mProductId.is Empty())471 CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId ));472 if (!f.mRevision.is Empty())473 CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision ));474 if (!f.mManufacturer.is Empty())475 CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer ));476 if (!f.mRemote.is Empty())477 CHECK_ERROR_BREAK (flt, COMSETTER(Remote) (f.mRemote ));478 if (!f.mSerialNumber.is Empty())479 CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber ));468 if (!f.mVendorId.isNull()) 469 CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId.setNullIfEmpty())); 470 if (!f.mProductId.isNull()) 471 CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId.setNullIfEmpty())); 472 if (!f.mRevision.isNull()) 473 CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision.setNullIfEmpty())); 474 if (!f.mManufacturer.isNull()) 475 CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer.setNullIfEmpty())); 476 if (!f.mRemote.isNull()) 477 CHECK_ERROR_BREAK (flt, COMSETTER(Remote) (f.mRemote.setNullIfEmpty())); 478 if (!f.mSerialNumber.isNull()) 479 CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber.setNullIfEmpty())); 480 480 if (!f.mMaskedInterfaces.isNull()) 481 481 CHECK_ERROR_BREAK (flt, COMSETTER(MaskedInterfaces) (f.mMaskedInterfaces)); … … 494 494 ComPtr <IHostUSBDeviceFilter> flt = coll[cmd.mIndex]; 495 495 496 if (!f.mName.is Empty())497 CHECK_ERROR_BREAK (flt, COMSETTER(Name) (f.mName ));496 if (!f.mName.isNull()) 497 CHECK_ERROR_BREAK (flt, COMSETTER(Name) (f.mName.setNullIfEmpty())); 498 498 if (!f.mActive.isNull()) 499 499 CHECK_ERROR_BREAK (flt, COMSETTER(Active) (f.mActive)); 500 if (!f.mVendorId.is Empty())501 CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId ));502 if (!f.mProductId.is Empty())503 CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId ));504 if (!f.mRevision.is Empty())505 CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision ));506 if (!f.mManufacturer.is Empty())507 CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer ));508 if (!f.mSerialNumber.is Empty())509 CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber ));500 if (!f.mVendorId.isNull()) 501 CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId.setNullIfEmpty())); 502 if (!f.mProductId.isNull()) 503 CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId.setNullIfEmpty())); 504 if (!f.mRevision.isNull()) 505 CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision.setNullIfEmpty())); 506 if (!f.mManufacturer.isNull()) 507 CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer.setNullIfEmpty())); 508 if (!f.mSerialNumber.isNull()) 509 CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber.setNullIfEmpty())); 510 510 if (!f.mMaskedInterfaces.isNull()) 511 511 CHECK_ERROR_BREAK (flt, COMSETTER(MaskedInterfaces) (f.mMaskedInterfaces)); … … 521 521 ComPtr <IUSBDeviceFilter> flt = coll[cmd.mIndex]; 522 522 523 if (!f.mName.is Empty())524 CHECK_ERROR_BREAK (flt, COMSETTER(Name) (f.mName ));523 if (!f.mName.isNull()) 524 CHECK_ERROR_BREAK (flt, COMSETTER(Name) (f.mName.setNullIfEmpty())); 525 525 if (!f.mActive.isNull()) 526 526 CHECK_ERROR_BREAK (flt, COMSETTER(Active) (f.mActive)); 527 if (!f.mVendorId.is Empty())528 CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId ));529 if (!f.mProductId.is Empty())530 CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId ));531 if (!f.mRevision.is Empty())532 CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision ));533 if (!f.mManufacturer.is Empty())534 CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer ));535 if (!f.mRemote.is Empty())536 CHECK_ERROR_BREAK (flt, COMSETTER(Remote) (f.mRemote ));537 if (!f.mSerialNumber.is Empty())538 CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber ));527 if (!f.mVendorId.isNull()) 528 CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId.setNullIfEmpty())); 529 if (!f.mProductId.isNull()) 530 CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId.setNullIfEmpty())); 531 if (!f.mRevision.isNull()) 532 CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision.setNullIfEmpty())); 533 if (!f.mManufacturer.isNull()) 534 CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer.setNullIfEmpty())); 535 if (!f.mRemote.isNull()) 536 CHECK_ERROR_BREAK (flt, COMSETTER(Remote) (f.mRemote.setNullIfEmpty())); 537 if (!f.mSerialNumber.isNull()) 538 CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber.setNullIfEmpty())); 539 539 if (!f.mMaskedInterfaces.isNull()) 540 540 CHECK_ERROR_BREAK (flt, COMSETTER(MaskedInterfaces) (f.mMaskedInterfaces)); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r26550 r26553 228 228 return E_INVALIDARG; 229 229 230 if (com::asGuidStr(id).is Empty())230 if (com::asGuidStr(id).isNull()) 231 231 { 232 232 /* it's a global extra data key someone wants to change */ … … 310 310 IN_BSTR key, IN_BSTR value) 311 311 { 312 if (com::asGuidStr(id).is Empty())312 if (com::asGuidStr(id).isNull()) 313 313 { 314 314 QString sKey = QString::fromUtf16 (key); -
trunk/src/VBox/HostServices/GuestProperties/service.cpp
r26550 r26553 1158 1158 */ 1159 1159 /* static */ 1160 DECLCALLBACK(int) Service::reqNotify(PFNHGCMSVCEXT pfnCallback, 1161 void *pvData, 1162 char *pszName, 1163 char *pszValue, 1164 uint32_t u32TimeHigh, 1165 uint32_t u32TimeLow, 1166 char *pszFlags) 1160 DECLCALLBACK(int) Service::reqNotify(PFNHGCMSVCEXT pfnCallback, void *pvData, 1161 char *pszName, char *pszValue, uint32_t u32TimeHigh, 1162 uint32_t u32TimeLow, char *pszFlags) 1167 1163 { 1168 1164 LogFlowFunc (("pfnCallback=%p, pvData=%p, pszName=%p, pszValue=%p, u32TimeHigh=%u, u32TimeLow=%u, pszFlags=%p\n", pfnCallback, pvData, pszName, pszValue, u32TimeHigh, u32TimeLow, pszFlags)); -
trunk/src/VBox/Main/ApplianceImpl.cpp
r26550 r26553 370 370 int i = 1; 371 371 /* @todo: Maybe too cost-intensive; try to find a lighter way */ 372 while (mVirtualBox->FindMachine(Bstr(tmpName) .raw(), &machine) != VBOX_E_OBJECT_NOT_FOUND)372 while (mVirtualBox->FindMachine(Bstr(tmpName), &machine) != VBOX_E_OBJECT_NOT_FOUND) 373 373 { 374 374 RTStrFree(tmpName); … … 391 391 /* @todo: Maybe too cost-intensive; try to find a lighter way */ 392 392 while (RTPathExists(tmpName) || 393 mVirtualBox->FindHardDisk(Bstr(tmpName) .raw(), &harddisk) != VBOX_E_OBJECT_NOT_FOUND)393 mVirtualBox->FindHardDisk(Bstr(tmpName), &harddisk) != VBOX_E_OBJECT_NOT_FOUND) 394 394 { 395 395 RTStrFree(tmpName); … … 501 501 } 502 502 503 HRESULT Appliance::setUpProgressFS(ComObjPtr<Progress> &pProgress, const Utf8Str &strDescription)503 HRESULT Appliance::setUpProgressFS(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription) 504 504 { 505 505 HRESULT rc; … … 532 532 533 533 rc = pProgress->init(mVirtualBox, static_cast<IAppliance*>(this), 534 strDescription,534 bstrDescription, 535 535 TRUE /* aCancelable */, 536 536 cOperations, // ULONG cOperations, 537 537 ulTotalOperationsWeight, // ULONG ulTotalOperationsWeight, 538 strDescription, // CBSTR bstrFirstOperationDescription,538 bstrDescription, // CBSTR bstrFirstOperationDescription, 539 539 m->ulWeightPerOperation); // ULONG ulFirstOperationWeight, 540 540 return rc; 541 541 } 542 542 543 HRESULT Appliance::setUpProgressImportS3(ComObjPtr<Progress> &pProgress, const Utf8Str &strDescription)543 HRESULT Appliance::setUpProgressImportS3(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription) 544 544 { 545 545 HRESULT rc; … … 572 572 573 573 rc = pProgress->init(mVirtualBox, static_cast<IAppliance*>(this), 574 strDescription,574 bstrDescription, 575 575 TRUE /* aCancelable */, 576 576 cOperations, // ULONG cOperations, 577 577 ulTotalOperationsWeight, // ULONG ulTotalOperationsWeight, 578 tr("Init"), // CBSTR bstrFirstOperationDescription,578 Bstr(tr("Init")), // CBSTR bstrFirstOperationDescription, 579 579 ulInitWeight); // ULONG ulFirstOperationWeight, 580 580 return rc; 581 581 } 582 582 583 HRESULT Appliance::setUpProgressWriteS3(ComObjPtr<Progress> &pProgress, const Utf8Str &strDescription)583 HRESULT Appliance::setUpProgressWriteS3(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription) 584 584 { 585 585 HRESULT rc; … … 614 614 615 615 rc = pProgress->init(mVirtualBox, static_cast<IAppliance*>(this), 616 strDescription,616 bstrDescription, 617 617 TRUE /* aCancelable */, 618 618 cOperations, // ULONG cOperations, 619 619 ulTotalOperationsWeight, // ULONG ulTotalOperationsWeight, 620 strDescription, // CBSTR bstrFirstOperationDescription,620 bstrDescription, // CBSTR bstrFirstOperationDescription, 621 621 ulOVFCreationWeight); // ULONG ulFirstOperationWeight, 622 622 return rc; … … 837 837 task->locInfo = aLocInfo; 838 838 839 Utf8Str progressDesc = Utf8StrFmt(tr("Import appliance '%s'"),840 839 Bstr progressDesc = BstrFmt(tr("Import appliance '%s'"), 840 aLocInfo.strPath.c_str()); 841 841 842 842 HRESULT rc = S_OK; … … 1569 1569 mhda.lDevice, 1570 1570 DeviceType_Floppy, 1571 NULL);1571 Bstr("")); 1572 1572 if (FAILED(rc)) throw rc; 1573 1573 … … 1618 1618 mhda.lDevice, 1619 1619 DeviceType_DVD, 1620 NULL);1620 Bstr("")); 1621 1621 if (FAILED(rc)) throw rc; 1622 1622 … … 1744 1744 rc = mVirtualBox->OpenHardDisk(Bstr(strSrcFilePath), 1745 1745 AccessMode_ReadOnly, 1746 false, NULL, false, NULL,1746 false, Bstr(""), false, Bstr(""), 1747 1747 srcHdVBox.asOutParam()); 1748 1748 if (FAILED(rc)) throw rc; … … 4281 4281 IN_BSTR aExtraConfigValue) 4282 4282 { 4283 CheckComArgNotNull(aVboxValue); 4284 CheckComArgNotNull(aExtraConfigValue); 4285 4283 4286 AutoCaller autoCaller(this); 4284 4287 if (FAILED(autoCaller.rc())) return autoCaller.rc(); -
trunk/src/VBox/Main/ConsoleImpl.cpp
r26550 r26553 584 584 if (RT_SUCCESS(rc)) 585 585 { 586 mMachine->SetGuestProperty(Bstr(pszPropertyName), NULL, Bstr("RDONLYGUEST"));586 mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(""), Bstr("RDONLYGUEST")); 587 587 RTStrFree(pszPropertyName); 588 588 } … … 591 591 if (RT_SUCCESS(rc)) 592 592 { 593 mMachine->SetGuestProperty(Bstr(pszPropertyName), NULL, Bstr("RDONLYGUEST"));593 mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(""), Bstr("RDONLYGUEST")); 594 594 RTStrFree(pszPropertyName); 595 595 } … … 598 598 if (RT_SUCCESS(rc)) 599 599 { 600 mMachine->SetGuestProperty(Bstr(pszPropertyName), NULL, Bstr("RDONLYGUEST"));600 mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(""), Bstr("RDONLYGUEST")); 601 601 RTStrFree(pszPropertyName); 602 602 } … … 1190 1190 1191 1191 // static 1192 DECLCALLBACK(int) Console::doGuestPropNotification(void *pvExtension,1193 1194 1192 DECLCALLBACK(int) 1193 Console::doGuestPropNotification(void *pvExtension, uint32_t u32Function, 1194 void *pvParms, uint32_t cbParms) 1195 1195 { 1196 1196 using namespace guestProp; … … 1212 1212 Bstr value(pCBData->pcszValue); 1213 1213 Bstr flags(pCBData->pcszFlags); 1214 ComObjPtr<Console> ptrConsole = reinterpret_cast<Console *>(pvExtension); 1215 HRESULT hrc = ptrConsole->mControl->PushGuestProperty(name, 1216 value, 1217 pCBData->u64Timestamp, 1218 flags); 1219 if (SUCCEEDED(hrc)) 1220 rc = VINF_SUCCESS; 1214 if ( !name.isNull() 1215 && (!value.isNull() || pCBData->pcszValue == NULL) 1216 && (!flags.isNull() || pCBData->pcszFlags == NULL) 1217 ) 1218 { 1219 ComObjPtr<Console> ptrConsole = reinterpret_cast<Console *>(pvExtension); 1220 HRESULT hrc = ptrConsole->mControl->PushGuestProperty(name, 1221 value, 1222 pCBData->u64Timestamp, 1223 flags); 1224 if (SUCCEEDED(hrc)) 1225 rc = VINF_SUCCESS; 1226 else 1227 { 1228 LogFunc(("Console::doGuestPropNotification: hrc=%Rhrc pCBData={.pcszName=%s, .pcszValue=%s, .pcszFlags=%s}\n", 1229 pCBData->pcszName, pCBData->pcszValue, pCBData->pcszFlags)); 1230 rc = Global::vboxStatusCodeFromCOM(hrc); 1231 } 1232 } 1221 1233 else 1222 { 1223 LogFunc(("Console::doGuestPropNotification: hrc=%Rhrc pCBData={.pcszName=%s, .pcszValue=%s, .pcszFlags=%s}\n", 1224 pCBData->pcszName, pCBData->pcszValue, pCBData->pcszFlags)); 1225 rc = Global::vboxStatusCodeFromCOM(hrc); 1226 } 1234 rc = VERR_NO_MEMORY; 1227 1235 return rc; 1228 1236 } … … 2586 2594 { 2587 2595 #ifdef VBOX_WITH_USB 2588 CheckComArg StrNotEmptyOrNull(aAddress);2596 CheckComArgNotNull(aAddress); 2589 2597 CheckComArgOutPointerValid(aDevice); 2590 2598 … … 2653 2661 } 2654 2662 2655 STDMETHODIMP Console::CreateSharedFolder(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable) 2656 { 2657 CheckComArgStrNotEmptyOrNull(aName); 2658 CheckComArgStrNotEmptyOrNull(aHostPath); 2663 STDMETHODIMP 2664 Console::CreateSharedFolder(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable) 2665 { 2666 CheckComArgNotNull(aName); 2667 CheckComArgNotNull(aHostPath); 2659 2668 2660 2669 AutoCaller autoCaller(this); … … 2723 2732 STDMETHODIMP Console::RemoveSharedFolder(IN_BSTR aName) 2724 2733 { 2725 CheckComArg StrNotEmptyOrNull(aName);2734 CheckComArgNotNull(aName); 2726 2735 2727 2736 AutoCaller autoCaller(this); … … 2789 2798 LogFlowThisFunc(("aName='%ls' mMachineState=%08X\n", aName, mMachineState)); 2790 2799 2791 CheckComArg StrNotEmptyOrNull(aName);2800 CheckComArgNotNull(aName); 2792 2801 CheckComArgOutPointerValid(aProgress); 2793 2802 … … 7716 7725 * (i.e. creating a snapshot online) 7717 7726 */ 7718 ComAssertThrow( (!pTask->bstrSavedStateFile.is Empty() && pTask->fTakingSnapshotOnline)7719 || (pTask->bstrSavedStateFile.is Empty() && !pTask->fTakingSnapshotOnline),7727 ComAssertThrow( (!pTask->bstrSavedStateFile.isNull() && pTask->fTakingSnapshotOnline) 7728 || (pTask->bstrSavedStateFile.isNull() && !pTask->fTakingSnapshotOnline), 7720 7729 rc = E_FAIL); 7721 7730 -
trunk/src/VBox/Main/ConsoleImpl2.cpp
r26550 r26553 3155 3155 } 3156 3156 3157 if (!networkName.is Empty())3157 if (!networkName.isNull()) 3158 3158 { 3159 3159 /* … … 3162 3162 */ 3163 3163 ComPtr<IDHCPServer> dhcpServer; 3164 hrc = virtualBox->FindDHCPServerByNetworkName(networkName. raw(), dhcpServer.asOutParam());3164 hrc = virtualBox->FindDHCPServerByNetworkName(networkName.mutableRaw(), dhcpServer.asOutParam()); 3165 3165 if (SUCCEEDED(hrc)) 3166 3166 { -
trunk/src/VBox/Main/ConsoleImplTeleporter.cpp
r26550 r26553 894 894 * @param aProgress Where to return the progress object. 895 895 */ 896 STDMETHODIMP Console::Teleport(IN_BSTR aHostname, 897 ULONG aPort, 898 IN_BSTR aPassword, 899 ULONG aMaxDowntime, 900 IProgress **aProgress) 896 STDMETHODIMP 897 Console::Teleport(IN_BSTR aHostname, ULONG aPort, IN_BSTR aPassword, ULONG aMaxDowntime, IProgress **aProgress) 901 898 { 902 899 /* … … 906 903 CheckComArgOutPointerValid(aProgress); 907 904 CheckComArgStrNotEmptyOrNull(aHostname); 905 CheckComArgNotNull(aHostname); 908 906 CheckComArgExprMsg(aPort, aPort > 0 && aPort <= 65535, ("is %u", aPort)); 909 907 CheckComArgExprMsg(aMaxDowntime, aMaxDowntime > 0, ("is %u", aMaxDowntime)); -
trunk/src/VBox/Main/GuestImpl.cpp
r26550 r26553 127 127 128 128 // redirect the call to IMachine if no additions are installed 129 if (mData.mAdditionsVersion.is Empty())130 return mParent->machine()->COMGETTER(OSTypeId) (aOSTypeId);129 if (mData.mAdditionsVersion.isNull()) 130 return mParent->machine()->COMGETTER(OSTypeId) (aOSTypeId); 131 131 132 132 mData.mOSTypeId.cloneTo(aOSTypeId); … … 135 135 } 136 136 137 STDMETHODIMP Guest::COMGETTER(AdditionsActive) (BOOL *aAdditionsActive)137 STDMETHODIMP Guest::COMGETTER(AdditionsActive) (BOOL *aAdditionsActive) 138 138 { 139 139 CheckComArgOutPointerValid(aAdditionsActive); … … 262 262 IN_BSTR aDomain, BOOL aAllowInteractiveLogon) 263 263 { 264 CheckComArgNotNull(aUserName); 265 CheckComArgNotNull(aPassword); 266 CheckComArgNotNull(aDomain); 267 264 268 AutoCaller autoCaller(this); 265 269 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 274 278 275 279 vmmDev->getVMMDevPort()->pfnSetCredentials(vmmDev->getVMMDevPort(), 276 Utf8Str(aUserName).raw(), 277 Utf8Str(aPassword).raw(), 278 Utf8Str(aDomain).raw(), 279 u32Flags); 280 Utf8Str(aUserName).raw(), Utf8Str(aPassword).raw(), 281 Utf8Str(aDomain).raw(), u32Flags); 280 282 return S_OK; 281 283 } … … 315 317 void Guest::setAdditionsVersion (Bstr aVersion, VBOXOSTYPE aOsType) 316 318 { 317 Assert(aVersion.is Empty() || !aVersion.isEmpty());319 Assert(aVersion.isNull() || !aVersion.isEmpty()); 318 320 319 321 AutoCaller autoCaller(this); … … 323 325 324 326 mData.mAdditionsVersion = aVersion; 325 mData.mAdditionsActive = !aVersion.is Empty();326 327 mData.mOSTypeId = Global::OSTypeId (aOsType);327 mData.mAdditionsActive = !aVersion.isNull(); 328 329 mData.mOSTypeId = Global::OSTypeId (aOsType); 328 330 } 329 331 -
trunk/src/VBox/Main/HostImpl.cpp
r26550 r26553 1290 1290 STDMETHODIMP Host::FindHostDVDDrive(IN_BSTR aName, IMedium **aDrive) 1291 1291 { 1292 CheckComArg StrNotEmptyOrNull(aName);1292 CheckComArgNotNull(aName); 1293 1293 CheckComArgOutPointerValid(aDrive); 1294 1294 … … 1317 1317 STDMETHODIMP Host::FindHostFloppyDrive(IN_BSTR aName, IMedium **aDrive) 1318 1318 { 1319 CheckComArg StrNotEmptyOrNull(aName);1319 CheckComArgNotNull(aName); 1320 1320 CheckComArgOutPointerValid(aDrive); 1321 1321 … … 1451 1451 { 1452 1452 #ifdef VBOX_WITH_USB 1453 CheckComArg StrNotEmptyOrNull(aAddress);1453 CheckComArgNotNull(aAddress); 1454 1454 CheckComArgOutPointerValid(aDevice); 1455 1455 -
trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp
r26550 r26553 56 56 * @param aGuid GUID of the host network interface 57 57 */ 58 HRESULT HostNetworkInterface::init (Bstr aInterfaceName, Guid aGuid, HostNetworkInterfaceType_T ifType)58 HRESULT HostNetworkInterface::init (Bstr aInterfaceName, Guid aGuid, HostNetworkInterfaceType_T ifType) 59 59 { 60 60 LogFlowThisFunc(("aInterfaceName={%ls}, aGuid={%s}\n", 61 aInterfaceName.raw(), aGuid.toString().raw()));61 aInterfaceName.raw(), aGuid.toString().raw())); 62 62 63 63 ComAssertRet(aInterfaceName, E_INVALIDARG); … … 423 423 { 424 424 m.realIPAddress = 0; 425 if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPAddress", mInterfaceName.raw())), NULL)))425 if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPAddress", mInterfaceName.raw())), Bstr("")))) 426 426 return E_FAIL; 427 if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPNetMask", mInterfaceName.raw())), NULL)))427 if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPNetMask", mInterfaceName.raw())), Bstr("")))) 428 428 return E_FAIL; 429 429 return S_OK; -
trunk/src/VBox/Main/MachineImpl.cpp
r26550 r26553 697 697 STDMETHODIMP Machine::COMSETTER(Name)(IN_BSTR aName) 698 698 { 699 if (!aName || !*aName) 699 CheckComArgNotNull(aName); 700 701 if (!*aName) 700 702 return setError(E_INVALIDARG, 701 703 tr("Machine name cannot be empty")); … … 777 779 STDMETHODIMP Machine::COMSETTER(OSTypeId)(IN_BSTR aOSTypeId) 778 780 { 779 CheckComArg StrNotEmptyOrNull(aOSTypeId);781 CheckComArgNotNull(aOSTypeId); 780 782 781 783 AutoCaller autoCaller(this); … … 1928 1930 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1929 1931 1930 mData->mSession.mType.cloneTo(aSessionType); 1932 if (mData->mSession.mType.isNull()) 1933 Bstr("").cloneTo(aSessionType); 1934 else 1935 mData->mSession.mType.cloneTo(aSessionType); 1931 1936 1932 1937 return S_OK; … … 1985 1990 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1986 1991 1987 mSSData->mStateFilePath.cloneTo(aStateFilePath); 1992 if (mSSData->mStateFilePath.isEmpty()) 1993 Bstr("").cloneTo(aStateFilePath); 1994 else 1995 mSSData->mStateFilePath.cloneTo(aStateFilePath); 1988 1996 1989 1997 return S_OK; … … 2126 2134 } 2127 2135 2128 STDMETHODIMP Machine::COMSETTER(GuestPropertyNotificationPatterns)(IN_BSTR aPatterns) 2129 { 2136 STDMETHODIMP 2137 Machine::COMSETTER(GuestPropertyNotificationPatterns)(IN_BSTR aPatterns) 2138 { 2139 CheckComArgNotNull(aPatterns); 2130 2140 AutoCaller autoCaller(this); 2131 2141 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 2390 2400 IN_BSTR aId) 2391 2401 { 2392 CheckComArgStrNotEmptyOrNull(aControllerName);2393 2394 2402 LogFlowThisFunc(("aControllerName=\"%ls\" aControllerPort=%d aDevice=%d aType=%d aId=\"%ls\"\n", 2395 2403 aControllerName, aControllerPort, aDevice, aType, aId)); 2404 2405 CheckComArgNotNull(aControllerName); 2406 CheckComArgNotNull(aId); 2396 2407 2397 2408 AutoCaller autoCaller(this); … … 2815 2826 LONG aDevice) 2816 2827 { 2817 CheckComArg StrNotEmptyOrNull(aControllerName);2828 CheckComArgNotNull(aControllerName); 2818 2829 2819 2830 LogFlowThisFunc(("aControllerName=\"%ls\" aControllerPort=%ld aDevice=%ld\n", … … 2900 2911 LONG aDevice, BOOL aPassthrough) 2901 2912 { 2902 CheckComArg StrNotEmptyOrNull(aControllerName);2913 CheckComArgNotNull(aControllerName); 2903 2914 2904 2915 LogFlowThisFunc(("aControllerName=\"%ls\" aControllerPort=%ld aDevice=%ld aPassthrough=%d\n", … … 2954 2965 aControllerName, aControllerPort, aDevice, aForce)); 2955 2966 2956 CheckComArgStrNotEmptyOrNull(aControllerName); 2967 CheckComArgNotNull(aControllerName); 2968 CheckComArgNotNull(aId); 2957 2969 2958 2970 AutoCaller autoCaller(this); … … 3094 3106 aControllerName, aControllerPort, aDevice)); 3095 3107 3096 CheckComArg StrNotEmptyOrNull(aControllerName);3108 CheckComArgNotNull(aControllerName); 3097 3109 CheckComArgOutPointerValid(aMedium); 3098 3110 … … 3193 3205 BSTR *aValue) 3194 3206 { 3195 CheckComArg StrNotEmptyOrNull(aKey);3207 CheckComArgNotNull(aKey); 3196 3208 CheckComArgOutPointerValid(aValue); 3197 3209 … … 3200 3212 3201 3213 /* start with nothing found */ 3202 Bstr bstrResult ;3214 Bstr bstrResult(""); 3203 3215 3204 3216 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); … … 3220 3232 STDMETHODIMP Machine::SetExtraData(IN_BSTR aKey, IN_BSTR aValue) 3221 3233 { 3222 CheckComArg StrNotEmptyOrNull(aKey);3234 CheckComArgNotNull(aKey); 3223 3235 3224 3236 AutoCaller autoCaller(this); … … 3251 3263 // lock to copy the list of callbacks to invoke 3252 3264 Bstr error; 3253 Bstr bstrValue(aValue); 3265 Bstr bstrValue; 3266 if (aValue) 3267 bstrValue = aValue; 3268 else 3269 bstrValue = (const char *)""; 3254 3270 3255 3271 if (!mParent->onExtraDataCanChange(mData->mUuid, aKey, bstrValue, error)) 3256 3272 { 3257 3273 const char *sep = error.isEmpty() ? "" : ": "; 3258 CBSTR err = error. raw();3274 CBSTR err = error.isNull() ? (CBSTR) L"" : error.raw(); 3259 3275 LogWarningFunc(("Someone vetoed! Change refused%s%ls\n", 3260 3276 sep, err)); … … 3440 3456 STDMETHODIMP Machine::FindSnapshot(IN_BSTR aName, ISnapshot **aSnapshot) 3441 3457 { 3442 CheckComArg StrNotEmptyOrNull(aName);3458 CheckComArgNotNull(aName); 3443 3459 CheckComArgOutPointerValid(aSnapshot); 3444 3460 … … 3466 3482 STDMETHODIMP Machine::CreateSharedFolder(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable) 3467 3483 { 3468 CheckComArg StrNotEmptyOrNull(aName);3469 CheckComArg StrNotEmptyOrNull(aHostPath);3484 CheckComArgNotNull(aName); 3485 CheckComArgNotNull(aHostPath); 3470 3486 3471 3487 AutoCaller autoCaller(this); … … 3501 3517 STDMETHODIMP Machine::RemoveSharedFolder(IN_BSTR aName) 3502 3518 { 3503 CheckComArg StrNotEmptyOrNull(aName);3519 CheckComArgNotNull(aName); 3504 3520 3505 3521 AutoCaller autoCaller(this); … … 3591 3607 ReturnComNotImplemented(); 3592 3608 #else // VBOX_WITH_GUEST_PROPS 3593 CheckComArg StrNotEmptyOrNull(aName);3609 CheckComArgNotNull(aName); 3594 3610 CheckComArgOutPointerValid(aValue); 3595 3611 CheckComArgOutPointerValid(aTimestamp); … … 3670 3686 using namespace guestProp; 3671 3687 3672 CheckComArgStrNotEmptyOrNull(aName); 3688 CheckComArgNotNull(aName); 3689 CheckComArgNotNull(aValue); 3673 3690 if ((aFlags != NULL) && !VALID_PTR(aFlags)) 3674 3691 return E_INVALIDARG; … … 3679 3696 { 3680 3697 Utf8Str utf8Name(aName); 3681 Utf8Str utf8Value(aValue);3682 3698 Utf8Str utf8Flags(aFlags); 3683 3699 … … 3735 3751 if (found && SUCCEEDED(rc)) 3736 3752 { 3737 if ( utf8Value.length())3753 if (*aValue) 3738 3754 { 3739 3755 RTTIMESPEC time; 3740 property.strValue = utf8Value;3756 property.strValue = aValue; 3741 3757 property.mTimestamp = RTTimeSpecGetNano(RTTimeNow(&time)); 3742 3758 if (aFlags != NULL) … … 3745 3761 } 3746 3762 } 3747 else if (SUCCEEDED(rc) && utf8Value.length())3763 else if (SUCCEEDED(rc) && *aValue) 3748 3764 { 3749 3765 RTTIMESPEC time; … … 3751 3767 mHWData.backup(); 3752 3768 property.strName = aName; 3753 property.strValue = utf8Value;3769 property.strValue = aValue; 3754 3770 property.mTimestamp = RTTimeSpecGetNano(RTTimeNow(&time)); 3755 3771 property.mFlags = fFlags; … … 3769 3785 else 3770 3786 { 3771 ComPtr<IInternalSessionControl> directControl = mData->mSession.mDirectControl; 3787 ComPtr<IInternalSessionControl> directControl = 3788 mData->mSession.mDirectControl; 3772 3789 3773 3790 /* just be on the safe side when calling another process */ … … 3780 3797 else 3781 3798 rc = directControl->AccessGuestProperty(aName, 3782 aValue,3799 *aValue ? aValue : NULL, /** @todo Fix when adding DeleteGuestProperty(), see defect. */ 3783 3800 aFlags, 3784 3801 true /* isSetter */, … … 3914 3931 aControllerName, aControllerPort, aDevice)); 3915 3932 3916 CheckComArg StrNotEmptyOrNull(aControllerName);3933 CheckComArgNotNull(aControllerName); 3917 3934 CheckComArgOutPointerValid(aAttachment); 3918 3935 … … 8930 8947 #endif /* VBOX_WITH_USB */ 8931 8948 8932 if (!mData->mSession.mType.is Empty())8949 if (!mData->mSession.mType.isNull()) 8933 8950 { 8934 8951 /* mType is not null when this machine's process has been started by … … 9638 9655 using namespace guestProp; 9639 9656 9640 CheckComArg StrNotEmptyOrNull(aName);9641 if (aValue && *aValue&& (!VALID_PTR(aValue) || !VALID_PTR(aFlags)))9657 CheckComArgNotNull(aName); 9658 if (aValue != NULL && (!VALID_PTR(aValue) || !VALID_PTR(aFlags))) 9642 9659 return E_POINTER; /* aValue can be NULL to indicate deletion */ 9643 9660 -
trunk/src/VBox/Main/Matching.cpp
r26550 r26553 198 198 return 199 199 mSimple.isEmpty() || 200 (mIgnoreCase && mSimple.compare (aValue, Bstr::CaseInsensitive) == 0) ||201 (!mIgnoreCase && mSimple.compare (aValue) == 0);200 (mIgnoreCase && mSimple.compareIgnoreCase (aValue) == 0) || 201 (!mIgnoreCase && mSimple.compare (aValue) == 0); 202 202 } 203 203 -
trunk/src/VBox/Main/MediumImpl.cpp
r26550 r26553 1361 1361 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1362 1362 1363 m->strDescription.cloneTo(aDescription); 1363 if (m->strDescription.isEmpty()) 1364 Bstr("").cloneTo(aDescription); 1365 else 1366 m->strDescription.cloneTo(aDescription); 1364 1367 1365 1368 return S_OK; … … 1368 1371 STDMETHODIMP Medium::COMSETTER(Description)(IN_BSTR aDescription) 1369 1372 { 1373 CheckComArgNotNull(aDescription); 1374 1370 1375 AutoCaller autoCaller(this); 1371 1376 if (FAILED(autoCaller.rc())) return autoCaller.rc(); … … 1410 1415 STDMETHODIMP Medium::COMSETTER(Location)(IN_BSTR aLocation) 1411 1416 { 1412 CheckComArg StrNotEmptyOrNull(aLocation);1417 CheckComArgNotNull(aLocation); 1413 1418 1414 1419 AutoCaller autoCaller(this); … … 1720 1725 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1721 1726 1722 m->strLastAccessError.cloneTo(aLastAccessError); 1727 if (m->strLastAccessError.isEmpty()) 1728 Bstr("").cloneTo(aLastAccessError); 1729 else 1730 m->strLastAccessError.cloneTo(aLastAccessError); 1723 1731 1724 1732 return S_OK; … … 2094 2102 tr("Property '%ls' does not exist"), aName); 2095 2103 2096 it->second.cloneTo(aValue); 2104 if (it->second.isEmpty()) 2105 Bstr("").cloneTo(aValue); 2106 else 2107 it->second.cloneTo(aValue); 2097 2108 2098 2109 return S_OK; … … 2158 2169 { 2159 2170 it->first.cloneTo(&names[i]); 2160 it->second.cloneTo(&values[i]); 2171 if (it->second.isEmpty()) 2172 Bstr("").cloneTo(&values[i]); 2173 else 2174 it->second.cloneTo(&values[i]); 2161 2175 ++ i; 2162 2176 } … … 2348 2362 2349 2363 STDMETHODIMP Medium::CloneTo(IMedium *aTarget, 2350 MediumVariant_T aVariant,2351 IMedium *aParent,2352 IProgress **aProgress)2364 MediumVariant_T aVariant, 2365 IMedium *aParent, 2366 IProgress **aProgress) 2353 2367 { 2354 2368 CheckComArgNotNull(aTarget); … … 3076 3090 { 3077 3091 /* only save properties that have non-default values */ 3078 if (!it->second.is Empty())3092 if (!it->second.isNull()) 3079 3093 { 3080 3094 Utf8Str name = it->first; … … 4844 4858 4845 4859 /* we interpret null values as "no value" in Medium */ 4846 if (it->second.is Empty())4860 if (it->second.isNull()) 4847 4861 return VERR_CFGM_VALUE_NOT_FOUND; 4848 4862 … … 4871 4885 4872 4886 /* we interpret null values as "no value" in Medium */ 4873 if (it->second.is Empty())4887 if (it->second.isNull()) 4874 4888 return VERR_CFGM_VALUE_NOT_FOUND; 4875 4889 -
trunk/src/VBox/Main/NetworkAdapterImpl.cpp
r26550 r26553 1026 1026 case NetworkAttachmentType_NAT: 1027 1027 mData->mNATNetwork = data.strName; 1028 if (mData->mNATNetwork.isNull()) 1029 mData->mNATNetwork = ""; 1028 1030 rc = AttachToNAT(); 1029 1031 if (FAILED(rc)) return rc; … … 1039 1041 case NetworkAttachmentType_Internal: 1040 1042 mData->mInternalNetwork = data.strName; 1041 Assert(!mData->mInternalNetwork.is Empty());1043 Assert(!mData->mInternalNetwork.isNull()); 1042 1044 1043 1045 rc = AttachToInternalNetwork(); -
trunk/src/VBox/Main/ProgressImpl.cpp
r26550 r26553 97 97 * @return COM result indicator. 98 98 */ 99 HRESULT ProgressBase::protectedInit (AutoInitSpan &aAutoInitSpan,99 HRESULT ProgressBase::protectedInit (AutoInitSpan &aAutoInitSpan, 100 100 #if !defined (VBOX_COM_INPROC) 101 101 VirtualBox *aParent, 102 102 #endif 103 IUnknown *aInitiator, 104 const Utf8Str &strDescription, 105 OUT_GUID aId /* = NULL */) 103 IUnknown *aInitiator, 104 CBSTR aDescription, OUT_GUID aId /* = NULL */) 106 105 { 107 106 /* Guarantees subclasses call this method at the proper time */ … … 117 116 #endif 118 117 119 AssertReturn( !strDescription.isEmpty(), E_INVALIDARG);118 AssertReturn(aDescription, E_INVALIDARG); 120 119 121 120 #if !defined (VBOX_COM_INPROC) … … 144 143 #endif 145 144 146 unconst(m _strDescription) = strDescription;145 unconst(mDescription) = aDescription; 147 146 148 147 return S_OK; … … 221 220 222 221 /* mDescription is constant during life time, no need to lock */ 223 m _strDescription.cloneTo(aDescription);222 mDescription.cloneTo(aDescription); 224 223 225 224 return S_OK; … … 466 465 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 467 466 468 m_ strOperationDescription.cloneTo(aOperationDescription);467 m_bstrOperationDescription.cloneTo(aOperationDescription); 469 468 470 469 return S_OK; … … 664 663 #endif 665 664 IUnknown *aInitiator, 666 const Utf8Str &strDescription,665 CBSTR aDescription, 667 666 BOOL aCancelable, 668 667 ULONG cOperations, 669 668 ULONG ulTotalOperationsWeight, 670 const Utf8Str &strFirstOperationDescription,669 CBSTR bstrFirstOperationDescription, 671 670 ULONG ulFirstOperationWeight, 672 671 OUT_GUID aId /* = NULL */) 673 672 { 674 LogFlowThisFunc(("aDescription=\"% s\", cOperations=%d, ulTotalOperationsWeight=%d, strFirstOperationDescription=\"%s\", ulFirstOperationWeight=%d\n",675 strDescription.c_str(),673 LogFlowThisFunc(("aDescription=\"%ls\", cOperations=%d, ulTotalOperationsWeight=%d, bstrFirstOperationDescription=\"%ls\", ulFirstOperationWeight=%d\n", 674 aDescription, 676 675 cOperations, 677 676 ulTotalOperationsWeight, 678 strFirstOperationDescription.c_str(),677 bstrFirstOperationDescription, 679 678 ulFirstOperationWeight)); 680 679 681 AssertReturn( !strFirstOperationDescription.isEmpty(), E_INVALIDARG);680 AssertReturn(bstrFirstOperationDescription, E_INVALIDARG); 682 681 AssertReturn(ulTotalOperationsWeight >= 1, E_INVALIDARG); 683 682 … … 688 687 HRESULT rc = S_OK; 689 688 690 rc = ProgressBase::protectedInit (autoInitSpan,689 rc = ProgressBase::protectedInit (autoInitSpan, 691 690 #if !defined (VBOX_COM_INPROC) 692 aParent,691 aParent, 693 692 #endif 694 aInitiator, 695 strDescription, 696 aId); 693 aInitiator, aDescription, aId); 697 694 if (FAILED(rc)) return rc; 698 695 … … 703 700 m_ulOperationsCompletedWeight = 0; 704 701 m_ulCurrentOperation = 0; 705 m_ strOperationDescription =strFirstOperationDescription;702 m_bstrOperationDescription = bstrFirstOperationDescription; 706 703 m_ulCurrentOperationWeight = ulFirstOperationWeight; 707 704 m_ulOperationPercent = 0; … … 736 733 HRESULT Progress::init(BOOL aCancelable, 737 734 ULONG aOperationCount, 738 const Utf8Str &strOperationDescription)739 { 740 LogFlowThisFunc(("aOperationDescription=\"% s\"\n", strOperationDescription.c_str()));735 CBSTR aOperationDescription) 736 { 737 LogFlowThisFunc(("aOperationDescription=\"%ls\"\n", aOperationDescription)); 741 738 742 739 /* Enclose the state transition NotReady->InInit->Ready */ … … 746 743 HRESULT rc = S_OK; 747 744 748 rc = ProgressBase::protectedInit (autoInitSpan);745 rc = ProgressBase::protectedInit (autoInitSpan); 749 746 if (FAILED(rc)) return rc; 750 747 … … 757 754 m_ulOperationsCompletedWeight = 0; 758 755 m_ulCurrentOperation = 0; 759 m_ strOperationDescription = strOperationDescription;756 m_bstrOperationDescription = aOperationDescription; 760 757 m_ulCurrentOperationWeight = 1; 761 758 m_ulOperationPercent = 0; 762 759 763 int vrc = RTSemEventMultiCreate (&mCompletedSem);764 ComAssertRCRet (vrc, E_FAIL);765 766 RTSemEventMultiReset (mCompletedSem);760 int vrc = RTSemEventMultiCreate (&mCompletedSem); 761 ComAssertRCRet (vrc, E_FAIL); 762 763 RTSemEventMultiReset (mCompletedSem); 767 764 768 765 /* Confirm a successful initialization when it's the case */ … … 790 787 if (mWaitersCount > 0) 791 788 { 792 LogFlow (("WARNING: There are still %d threads waiting for '% s' completion!\n",793 mWaitersCount, m _strDescription.c_str()));794 RTSemEventMultiSignal (mCompletedSem);789 LogFlow (("WARNING: There are still %d threads waiting for '%ls' completion!\n", 790 mWaitersCount, mDescription.raw())); 791 RTSemEventMultiSignal (mCompletedSem); 795 792 } 796 793 797 RTSemEventMultiDestroy (mCompletedSem);798 799 ProgressBase::protectedUninit (autoUninitSpan);794 RTSemEventMultiDestroy (mCompletedSem); 795 796 ProgressBase::protectedUninit (autoUninitSpan); 800 797 } 801 798 … … 1007 1004 m_ulOperationsCompletedWeight += m_ulCurrentOperationWeight; 1008 1005 1009 m_ strOperationDescription = bstrNextOperationDescription;1006 m_bstrOperationDescription = bstrNextOperationDescription; 1010 1007 m_ulCurrentOperationWeight = ulNextOperationsWeight; 1011 1008 m_ulOperationPercent = 0; 1012 1009 1013 Log(("Progress::setNextOperation(% s): ulNextOperationsWeight = %d; m_ulCurrentOperation is now %d, m_ulOperationsCompletedWeight is now %d\n",1014 m_ strOperationDescription.c_str(), ulNextOperationsWeight, m_ulCurrentOperation, m_ulOperationsCompletedWeight));1010 Log(("Progress::setNextOperation(%ls): ulNextOperationsWeight = %d; m_ulCurrentOperation is now %d, m_ulOperationsCompletedWeight is now %d\n", 1011 m_bstrOperationDescription.raw(), ulNextOperationsWeight, m_ulCurrentOperation, m_ulOperationsCompletedWeight)); 1015 1012 1016 1013 /* wake up all waiting threads */ … … 1289 1286 1290 1287 m_ulCurrentOperation = 0; 1291 Bstr bstrOperationDescription; 1292 rc = mProgresses[0]->COMGETTER(OperationDescription)(bstrOperationDescription.asOutParam()); 1293 m_strOperationDescription = bstrOperationDescription; 1288 rc = mProgresses[0]->COMGETTER(OperationDescription)(m_bstrOperationDescription.asOutParam()); 1294 1289 if (FAILED(rc)) return rc; 1295 1290 … … 1791 1786 { 1792 1787 m_ulCurrentOperation = mCompletedOperations + operation; 1793 Bstr bstrOperationDescription; 1794 rc = progress->COMGETTER(OperationDescription)(bstrOperationDescription.asOutParam()); 1795 m_strOperationDescription = bstrOperationDescription; 1788 rc = progress->COMGETTER(OperationDescription) ( 1789 m_bstrOperationDescription.asOutParam()); 1796 1790 } 1797 1791 } -
trunk/src/VBox/Main/RemoteUSBDeviceImpl.cpp
r26550 r26553 134 134 ///////////////////////////////////////////////////////////////////////////// 135 135 136 STDMETHODIMP RemoteUSBDevice::COMGETTER(Id) (BSTR *aId)136 STDMETHODIMP RemoteUSBDevice::COMGETTER(Id) (BSTR *aId) 137 137 { 138 138 CheckComArgOutPointerValid(aId); … … 142 142 143 143 /* this is const, no need to lock */ 144 Bstr(mData.id .toUtf16()).cloneTo(aId);144 Bstr(mData.id).cloneTo(aId); 145 145 146 146 return S_OK; -
trunk/src/VBox/Main/SessionImpl.cpp
r26550 r26553 682 682 } 683 683 684 STDMETHODIMP Session::AccessGuestProperty(IN_BSTR aName, 685 IN_BSTR aValue, 686 IN_BSTR aFlags, 687 BOOL aIsSetter, 688 BSTR *aRetValue, 689 ULONG64 *aRetTimestamp, 690 BSTR *aRetFlags) 684 STDMETHODIMP Session::AccessGuestProperty(IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags, 685 BOOL aIsSetter, BSTR *aRetValue, ULONG64 *aRetTimestamp, BSTR *aRetFlags) 691 686 { 692 687 #ifdef VBOX_WITH_GUEST_PROPS … … 699 694 Global::stringifySessionState(mState)); 700 695 AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE); 701 CheckComArg StrNotEmptyOrNull(aName);696 CheckComArgNotNull(aName); 702 697 if (!aIsSetter && !VALID_PTR(aRetValue)) 703 698 return E_POINTER; -
trunk/src/VBox/Main/SharedFolderImpl.cpp
r26550 r26553 333 333 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 334 334 335 m.lastAccessError.cloneTo(aLastAccessError); 335 if (m.lastAccessError.isEmpty()) 336 Bstr("").cloneTo(aLastAccessError); 337 else 338 m.lastAccessError.cloneTo(aLastAccessError); 336 339 337 340 return S_OK; -
trunk/src/VBox/Main/SnapshotImpl.cpp
r26550 r26553 342 342 STDMETHODIMP Snapshot::COMSETTER(Name)(IN_BSTR aName) 343 343 { 344 CheckComArg StrNotEmptyOrNull(aName);344 CheckComArgNotNull(aName); 345 345 346 346 AutoCaller autoCaller(this); … … 378 378 STDMETHODIMP Snapshot::COMSETTER(Description)(IN_BSTR aDescription) 379 379 { 380 CheckComArgNotNull(aDescription); 381 380 382 AutoCaller autoCaller(this); 381 383 if (FAILED(autoCaller.rc())) return autoCaller.rc(); -
trunk/src/VBox/Main/SystemPropertiesImpl.cpp
r26550 r26553 814 814 * @return ComObjPtr<MediumFormat> 815 815 */ 816 ComObjPtr<MediumFormat> SystemProperties::mediumFormat (CBSTR aFormat)816 ComObjPtr<MediumFormat> SystemProperties::mediumFormat (CBSTR aFormat) 817 817 { 818 818 ComObjPtr<MediumFormat> format; … … 824 824 825 825 for (MediumFormatList::const_iterator it = mMediumFormats.begin(); 826 it != mMediumFormats.end(); 827 ++it) 826 it != mMediumFormats.end(); ++ it) 828 827 { 829 828 /* MediumFormat is all const, no need to lock */ 830 829 831 if ((*it)->id().compare (aFormat, Bstr::CaseInsensitive) == 0)830 if ((*it)->id().compareIgnoreCase (aFormat) == 0) 832 831 { 833 832 format = *it; -
trunk/src/VBox/Main/USBControllerImpl.cpp
r26550 r26553 1110 1110 rc = aUSBDevice->COMGETTER(Manufacturer) (manufacturer.asOutParam()); 1111 1111 ComAssertComRCRet(rc, false); 1112 if (!manufacturer.is Empty())1112 if (!manufacturer.isNull()) 1113 1113 USBFilterSetStringExact (&dev, USBFILTERIDX_MANUFACTURER_STR, Utf8Str(manufacturer).c_str(), true); 1114 1114 … … 1116 1116 rc = aUSBDevice->COMGETTER(Product) (product.asOutParam()); 1117 1117 ComAssertComRCRet(rc, false); 1118 if (!product.is Empty())1118 if (!product.isNull()) 1119 1119 USBFilterSetStringExact (&dev, USBFILTERIDX_PRODUCT_STR, Utf8Str(product).c_str(), true); 1120 1120 … … 1122 1122 rc = aUSBDevice->COMGETTER(SerialNumber) (serialNumber.asOutParam()); 1123 1123 ComAssertComRCRet(rc, false); 1124 if (!serialNumber.is Empty())1124 if (!serialNumber.isNull()) 1125 1125 USBFilterSetStringExact (&dev, USBFILTERIDX_SERIAL_NUMBER_STR, Utf8Str(serialNumber).c_str(), true); 1126 1126 -
trunk/src/VBox/Main/USBDeviceImpl.cpp
r26550 r26553 155 155 156 156 /* this is const, no need to lock */ 157 Guid(mData.id).to Utf16().cloneTo(aId);157 Guid(mData.id).toString().cloneTo(aId); 158 158 159 159 return S_OK; -
trunk/src/VBox/Main/VirtualBoxBase.cpp
r26550 r26553 810 810 */ 811 811 /* static */ 812 HRESULT VirtualBoxSupportErrorInfoImplBase::setErrorInternal(HRESULT aResultCode, 813 const GUID &aIID, 814 const Bstr &aComponent, 815 const Bstr &aText, 816 bool aWarning, 817 bool aLogIt) 812 HRESULT VirtualBoxSupportErrorInfoImplBase::setErrorInternal ( 813 HRESULT aResultCode, const GUID &aIID, 814 const Bstr &aComponent, const Bstr &aText, 815 bool aWarning, bool aLogIt) 818 816 { 819 817 /* whether multi-error mode is turned on */ … … 827 825 828 826 /* these are mandatory, others -- not */ 829 AssertReturn( (!aWarning && FAILED(aResultCode))830 ||(aWarning && aResultCode != S_OK),827 AssertReturn((!aWarning && FAILED(aResultCode)) || 828 (aWarning && aResultCode != S_OK), 831 829 E_FAIL); 832 830 AssertReturn(!aText.isEmpty(), E_FAIL); … … 916 914 917 915 /* set the current error info and preserve the previous one if any */ 918 rc = info->init (aResultCode, aIID, aComponent.raw(), aText.raw(), curInfo);916 rc = info->init (aResultCode, aIID, aComponent, aText, curInfo); 919 917 if (FAILED(rc)) break; 920 918 -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r26550 r26553 302 302 LogFlowThisFuncEnter(); 303 303 304 if (sVersion.is Empty())304 if (sVersion.isNull()) 305 305 sVersion = VBOX_VERSION_STRING; 306 306 sRevision = RTBldCfgRevision(); 307 if (sPackageType.is Empty())307 if (sPackageType.isNull()) 308 308 sPackageType = VBOX_PACKAGE_STRING; 309 309 LogFlowThisFunc(("Version: %ls, Package: %ls\n", sVersion.raw(), sPackageType.raw())); … … 323 323 /* compose the VirtualBox.xml file name */ 324 324 unconst(m->strSettingsFilePath) = Utf8StrFmt("%s%c%s", 325 326 327 325 m->strHomeDir.raw(), 326 RTPATH_DELIMITER, 327 VBOX_GLOBAL_SETTINGS_FILE); 328 328 HRESULT rc = S_OK; 329 329 bool fCreate = false; … … 979 979 firmwareDesc[i].fileName); 980 980 rc = calculateFullPath(shortName, fullName); AssertRCReturn(rc, rc); 981 if (RTFileExists(fullName. c_str()))981 if (RTFileExists(fullName.raw())) 982 982 { 983 983 *aResult = TRUE; 984 984 if (aFile) 985 fullName.cloneTo(aFile);985 Utf8Str(fullName).cloneTo(aFile); 986 986 break; 987 987 } … … 993 993 RTPATH_DELIMITER, 994 994 firmwareDesc[i].fileName); 995 if (RTFileExists(fullName. c_str()))995 if (RTFileExists(fullName.raw())) 996 996 { 997 997 *aResult = TRUE; 998 998 if (aFile) 999 fullName.cloneTo(aFile);999 Utf8Str(fullName).cloneTo(aFile); 1000 1000 break; 1001 1001 } … … 1225 1225 LogFlowThisFunc(("aName=\"%ls\", aMachine={%p}\n", aName, aMachine)); 1226 1226 1227 CheckComArg StrNotEmptyOrNull(aName);1227 CheckComArgNotNull(aName); 1228 1228 CheckComArgOutSafeArrayPointerValid(aMachine); 1229 1229 … … 1346 1346 IMedium **aHardDisk) 1347 1347 { 1348 CheckComArgStrNotEmptyOrNull(aLocation); 1348 CheckComArgNotNull(aLocation); 1349 CheckComArgNotNull(aImageId); 1350 CheckComArgNotNull(aParentId); 1349 1351 CheckComArgOutSafeArrayPointerValid(aHardDisk); 1350 1352 … … 1421 1423 IMedium **aHardDisk) 1422 1424 { 1423 CheckComArg StrNotEmptyOrNull(aLocation);1425 CheckComArgNotNull(aLocation); 1424 1426 CheckComArgOutSafeArrayPointerValid(aHardDisk); 1425 1427 … … 1428 1430 1429 1431 ComObjPtr<Medium> hardDisk; 1430 Utf8Str strLocation(aLocation); 1431 HRESULT rc = findHardDisk(NULL, &strLocation, true /* setError */, &hardDisk); 1432 HRESULT rc = findHardDisk(NULL, aLocation, true /* setError */, &hardDisk); 1432 1433 1433 1434 /* the below will set *aHardDisk to NULL if hardDisk is null */ … … 1478 1479 1479 1480 /** @note Locks objects! */ 1480 STDMETHODIMP VirtualBox::GetDVDImage (IN_BSTR aId, IMedium **aDVDImage)1481 STDMETHODIMP VirtualBox::GetDVDImage (IN_BSTR aId, IMedium **aDVDImage) 1481 1482 { 1482 1483 CheckComArgOutSafeArrayPointerValid(aDVDImage); … … 1496 1497 1497 1498 /** @note Locks objects! */ 1498 STDMETHODIMP VirtualBox::FindDVDImage (IN_BSTR aLocation, IMedium **aDVDImage)1499 { 1500 CheckComArg StrNotEmptyOrNull(aLocation);1499 STDMETHODIMP VirtualBox::FindDVDImage (IN_BSTR aLocation, IMedium **aDVDImage) 1500 { 1501 CheckComArgNotNull(aLocation); 1501 1502 CheckComArgOutSafeArrayPointerValid(aDVDImage); 1502 1503 … … 1505 1506 1506 1507 ComObjPtr<Medium> image; 1507 Utf8Str strLocation(aLocation); 1508 HRESULT rc = findDVDImage(NULL, &strLocation, true /* setError */, &image); 1508 HRESULT rc = findDVDImage (NULL, aLocation, true /* setError */, &image); 1509 1509 1510 1510 /* the below will set *aDVDImage to NULL if dvd is null */ … … 1515 1515 1516 1516 /** @note Doesn't lock anything. */ 1517 STDMETHODIMP VirtualBox::OpenFloppyImage (IN_BSTR aLocation, IN_BSTR aId,1518 IMedium **aFloppyImage)1517 STDMETHODIMP VirtualBox::OpenFloppyImage (IN_BSTR aLocation, IN_BSTR aId, 1518 IMedium **aFloppyImage) 1519 1519 { 1520 1520 CheckComArgStrNotEmptyOrNull(aLocation); … … 1555 1555 1556 1556 /** @note Locks objects! */ 1557 STDMETHODIMP VirtualBox::GetFloppyImage (IN_BSTR aId,1558 IMedium **aFloppyImage)1557 STDMETHODIMP VirtualBox::GetFloppyImage (IN_BSTR aId, 1558 IMedium **aFloppyImage) 1559 1559 1560 1560 { … … 1575 1575 1576 1576 /** @note Locks objects! */ 1577 STDMETHODIMP VirtualBox::FindFloppyImage (IN_BSTR aLocation,1578 IMedium **aFloppyImage)1579 { 1580 CheckComArg StrNotEmptyOrNull(aLocation);1577 STDMETHODIMP VirtualBox::FindFloppyImage (IN_BSTR aLocation, 1578 IMedium **aFloppyImage) 1579 { 1580 CheckComArgNotNull(aLocation); 1581 1581 CheckComArgOutSafeArrayPointerValid(aFloppyImage); 1582 1582 … … 1585 1585 1586 1586 ComObjPtr<Medium> image; 1587 Utf8Str strLocation(aLocation); 1588 HRESULT rc = findFloppyImage(NULL, &strLocation, true /* setError */, &image); 1587 HRESULT rc = findFloppyImage(NULL, aLocation, true /* setError */, &image); 1589 1588 1590 1589 /* the below will set *aFloppyImage to NULL if img is null */ … … 1595 1594 1596 1595 /** @note Locks this object for reading. */ 1597 STDMETHODIMP VirtualBox::GetGuestOSType (IN_BSTR aId, IGuestOSType **aType)1596 STDMETHODIMP VirtualBox::GetGuestOSType (IN_BSTR aId, IGuestOSType **aType) 1598 1597 { 1599 1598 /* Old ID to new ID conversion table. See r39691 for a source */ … … 1616 1615 }; 1617 1616 1618 CheckComArgNotNull (aType);1617 CheckComArgNotNull (aType); 1619 1618 1620 1619 AutoCaller autoCaller(this); … … 1640 1639 { 1641 1640 const Bstr &typeId = (*it)->id(); 1642 if (typeId.compare(id, Bstr::CaseInsensitive) == 0) 1641 AssertMsg (!!typeId, ("ID must not be NULL")); 1642 if (typeId.compareIgnoreCase (id) == 0) 1643 1643 { 1644 1644 (*it).queryInterfaceTo(aType); … … 1709 1709 BSTR *aValue) 1710 1710 { 1711 CheckComArg StrNotEmptyOrNull(aKey);1711 CheckComArgNotNull(aKey); 1712 1712 CheckComArgNotNull(aValue); 1713 1713 … … 1716 1716 1717 1717 /* start with nothing found */ 1718 Bstr bstrResult ;1718 Bstr bstrResult(""); 1719 1719 1720 1720 settings::ExtraDataItemsMap::const_iterator it = m->pMainConfigFile->mapExtraDataItems.find(Utf8Str(aKey)); … … 1735 1735 IN_BSTR aValue) 1736 1736 { 1737 CheckComArg StrNotEmptyOrNull(aKey);1737 CheckComArgNotNull(aKey); 1738 1738 1739 1739 AutoCaller autoCaller(this); … … 1766 1766 // lock to copy the list of callbacks to invoke 1767 1767 Bstr error; 1768 Bstr bstrValue(aValue); 1768 Bstr bstrValue; 1769 if (aValue) 1770 bstrValue = aValue; 1771 else 1772 bstrValue = (const char *)""; 1769 1773 1770 1774 if (!onExtraDataCanChange(Guid::Empty, aKey, bstrValue, error)) 1771 1775 { 1772 1776 const char *sep = error.isEmpty() ? "" : ": "; 1773 CBSTR err = error. raw();1777 CBSTR err = error.isNull() ? (CBSTR) L"" : error.raw(); 1774 1778 LogWarningFunc(("Someone vetoed! Change refused%s%ls\n", 1775 1779 sep, err)); … … 1862 1866 LogRel(("remotesession=%s\n", Utf8Str(aMachineId).c_str())); 1863 1867 1864 CheckComArg StrNotEmptyOrNull(aMachineId);1868 CheckComArgNotNull(aMachineId); 1865 1869 CheckComArgNotNull(aSession); 1870 CheckComArgNotNull(aType); 1866 1871 CheckComArgOutSafeArrayPointerValid(aProgress); 1867 1872 … … 1892 1897 ComObjPtr<Progress> progress; 1893 1898 progress.createObject(); 1894 progress->init(this, 1895 static_cast<IMachine*>(machine), 1896 tr("Spawning session"), 1897 FALSE /* aCancelable */); 1899 progress->init (this, static_cast <IMachine *> (machine), 1900 Bstr (tr ("Spawning session")), 1901 FALSE /* aCancelable */); 1898 1902 1899 1903 rc = machine->openRemoteSession (control, aType, aEnvironment, progress); … … 2430 2434 case DataChanged: 2431 2435 LogFlow (("OnMachineDataChange: id={%RTuuid}\n", id.ptr())); 2432 aCallback->OnMachineDataChange (id.toUtf16());2436 aCallback->OnMachineDataChange (id.toUtf16()); 2433 2437 break; 2434 2438 … … 2436 2440 LogFlow (("OnMachineStateChange: id={%RTuuid}, state=%d\n", 2437 2441 id.ptr(), state)); 2438 aCallback->OnMachineStateChange (id.toUtf16(), state);2442 aCallback->OnMachineStateChange (id.toUtf16(), state); 2439 2443 break; 2440 2444 … … 2442 2446 LogFlow (("OnMachineRegistered: id={%RTuuid}, registered=%d\n", 2443 2447 id.ptr(), registered)); 2444 aCallback->OnMachineRegistered (id.toUtf16(), registered);2448 aCallback->OnMachineRegistered (id.toUtf16(), registered); 2445 2449 break; 2446 2450 } … … 2493 2497 while ((it != list.end()) && allowChange) 2494 2498 { 2495 HRESULT rc = (*it++)->OnExtraDataCanChange(id, 2496 aKey, 2497 aValue, 2498 aError.asOutParam(), 2499 &allowChange); 2499 HRESULT rc = (*it++)->OnExtraDataCanChange (id, aKey, aValue, 2500 aError.asOutParam(), &allowChange); 2500 2501 if (FAILED(rc)) 2501 2502 { … … 2526 2527 LogFlow (("OnExtraDataChange: machineId={%RTuuid}, key='%ls', val='%ls'\n", 2527 2528 machineId.ptr(), key.raw(), val.raw())); 2528 aCallback->OnExtraDataChange (machineId.toUtf16(), key, val);2529 aCallback->OnExtraDataChange (machineId.toUtf16(), key, val); 2529 2530 } 2530 2531 … … 2553 2554 { 2554 2555 SessionEvent (VirtualBox *aVB, const Guid &aMachineId, SessionState_T aState) 2555 : CallbackEvent (aVB), machineId (aMachineId), sessionState (aState)2556 : CallbackEvent (aVB), machineId (aMachineId), sessionState (aState) 2556 2557 {} 2557 2558 … … 2560 2561 LogFlow (("OnSessionStateChange: machineId={%RTuuid}, sessionState=%d\n", 2561 2562 machineId.ptr(), sessionState)); 2562 aCallback->OnSessionStateChange (machineId.toUtf16(), sessionState);2563 aCallback->OnSessionStateChange (machineId.toUtf16(), sessionState); 2563 2564 } 2564 2565 … … 2597 2598 LogFlow (("OnSnapshotTaken: machineId={%RTuuid}, snapshotId={%RTuuid}\n", 2598 2599 machineId.ptr(), snapshotId.ptr())); 2599 aCallback->OnSnapshotTaken (mid, sid);2600 aCallback->OnSnapshotTaken (mid, sid); 2600 2601 break; 2601 2602 … … 2603 2604 LogFlow (("OnSnapshotDiscarded: machineId={%RTuuid}, snapshotId={%RTuuid}\n", 2604 2605 machineId.ptr(), snapshotId.ptr())); 2605 aCallback->OnSnapshotDiscarded (mid, sid);2606 aCallback->OnSnapshotDiscarded (mid, sid); 2606 2607 break; 2607 2608 … … 2609 2610 LogFlow (("OnSnapshotChange: machineId={%RTuuid}, snapshotId={%RTuuid}\n", 2610 2611 machineId.ptr(), snapshotId.ptr())); 2611 aCallback->OnSnapshotChange (mid, sid);2612 aCallback->OnSnapshotChange (mid, sid); 2612 2613 break; 2613 2614 } … … 2660 2661 LogFlow(("OnGuestPropertyChange: machineId={%RTuuid}, name='%ls', value='%ls', flags='%ls'\n", 2661 2662 machineId.ptr(), name.raw(), value.raw(), flags.raw())); 2662 aCallback->OnGuestPropertyChange (machineId.toUtf16(), name, value, flags);2663 aCallback->OnGuestPropertyChange (machineId.toUtf16(), name, value, flags); 2663 2664 } 2664 2665 … … 2796 2797 * 2797 2798 * @param aId ID of the hard disk (unused when NULL). 2798 * @param pstrLocationFull location specification (unused NULL).2799 * @param aLocation Full location specification (unused NULL). 2799 2800 * @param aSetError If @c true , the appropriate error info is set in case 2800 2801 * when the hard disk is not found. … … 2806 2807 */ 2807 2808 HRESULT VirtualBox::findHardDisk(const Guid *aId, 2808 const Utf8Str *pstrLocation,2809 CBSTR aLocation, 2809 2810 bool aSetError, 2810 2811 ComObjPtr<Medium> *aHardDisk /*= NULL*/) 2811 2812 { 2812 AssertReturn(aId || pstrLocation, E_INVALIDARG);2813 AssertReturn(aId || aLocation, E_INVALIDARG); 2813 2814 2814 2815 // we use the hard disks map, but it is protected by the … … 2830 2831 /* then iterate and search by location */ 2831 2832 int result = -1; 2832 if (pstrLocation) 2833 { 2833 if (aLocation) 2834 { 2835 Utf8Str location = aLocation; 2836 2834 2837 for (HardDiskMap::const_iterator it = m->mapHardDisks.begin(); 2835 2838 it != m->mapHardDisks.end(); … … 2838 2841 const ComObjPtr<Medium> &hd = (*it).second; 2839 2842 2840 HRESULT rc = hd->compareLocationTo( pstrLocation->c_str(), result);2843 HRESULT rc = hd->compareLocationTo(location.c_str(), result); 2841 2844 if (FAILED(rc)) return rc; 2842 2845 … … 2861 2864 else 2862 2865 setError(rc, 2863 tr("Could not find a hard disk with location '% s' in the media registry ('%s')"),2864 pstrLocation->c_str(),2866 tr("Could not find a hard disk with location '%ls' in the media registry ('%s')"), 2867 aLocation, 2865 2868 m->strSettingsFilePath.raw()); 2866 2869 } … … 2885 2888 */ 2886 2889 HRESULT VirtualBox::findDVDImage(const Guid *aId, 2887 const Utf8Str *pstrLocation,2890 CBSTR aLocation, 2888 2891 bool aSetError, 2889 2892 ComObjPtr<Medium> *aImage /* = NULL */) 2890 2893 { 2891 AssertReturn(aId || pstrLocation, E_INVALIDARG);2894 AssertReturn(aId || aLocation, E_INVALIDARG); 2892 2895 2893 2896 Utf8Str location; 2894 2897 2895 if ( pstrLocation != NULL)2896 { 2897 int vrc = calculateFullPath( *pstrLocation, location);2898 if (aLocation != NULL) 2899 { 2900 int vrc = calculateFullPath(Utf8Str(aLocation), location); 2898 2901 if (RT_FAILURE(vrc)) 2899 2902 return setError(VBOX_E_FILE_ERROR, 2900 tr("Invalid image file location '% s' (%Rrc)"),2901 pstrLocation->c_str(),2903 tr("Invalid image file location '%ls' (%Rrc)"), 2904 aLocation, 2902 2905 vrc); 2903 2906 } … … 2914 2917 AutoReadLock imageLock(*it COMMA_LOCKVAL_SRC_POS); 2915 2918 2916 found = (aId && (*it)->getId() == *aId)2917 || ( pstrLocation != NULL2918 &&RTPathCompare(location.c_str(),2919 2920 2919 found = (aId && (*it)->getId() == *aId) || 2920 (aLocation != NULL && 2921 RTPathCompare(location.c_str(), 2922 (*it)->getLocationFull().c_str() 2923 ) == 0); 2921 2924 if (found) 2922 2925 { … … 2938 2941 else 2939 2942 setError(rc, 2940 tr("Could not find a CD/DVD image with location '% s' in the media registry ('%s')"),2941 pstrLocation->c_str(),2943 tr("Could not find a CD/DVD image with location '%ls' in the media registry ('%s')"), 2944 aLocation, 2942 2945 m->strSettingsFilePath.raw()); 2943 2946 } … … 2963 2966 */ 2964 2967 HRESULT VirtualBox::findFloppyImage(const Guid *aId, 2965 const Utf8Str *pstrLocation,2968 CBSTR aLocation, 2966 2969 bool aSetError, 2967 2970 ComObjPtr<Medium> *aImage /* = NULL */) 2968 2971 { 2969 AssertReturn(aId || pstrLocation, E_INVALIDARG);2972 AssertReturn(aId || aLocation, E_INVALIDARG); 2970 2973 2971 2974 Utf8Str location; 2972 2975 2973 if ( pstrLocation != NULL)2974 { 2975 int vrc = calculateFullPath( *pstrLocation, location);2976 if (aLocation != NULL) 2977 { 2978 int vrc = calculateFullPath(Utf8Str(aLocation), location); 2976 2979 if (RT_FAILURE(vrc)) 2977 2980 return setError(VBOX_E_FILE_ERROR, 2978 tr("Invalid image file location '%s' (%Rrc)"), 2979 pstrLocation->c_str(), 2980 vrc); 2981 tr("Invalid image file location '%ls' (%Rrc)"), 2982 aLocation, vrc); 2981 2983 } 2982 2984 … … 2992 2994 AutoReadLock imageLock(*it COMMA_LOCKVAL_SRC_POS); 2993 2995 2994 found = (aId && (*it)->getId() == *aId)2995 || ( pstrLocation != NULL2996 &&RTPathCompare(location.c_str(),2997 2998 2996 found = (aId && (*it)->getId() == *aId) || 2997 (aLocation != NULL && 2998 RTPathCompare(location.c_str(), 2999 (*it)->getLocationFull().c_str() 3000 ) == 0); 2999 3001 if (found) 3000 3002 { … … 3016 3018 else 3017 3019 setError(rc, 3018 tr("Could not find a floppy image with location '% s' in the media registry ('%s')"),3019 pstrLocation->c_str(),3020 tr("Could not find a floppy image with location '%ls' in the media registry ('%s')"), 3021 aLocation, 3020 3022 m->strSettingsFilePath.raw()); 3021 3023 } … … 3195 3197 HRESULT rc = S_OK; 3196 3198 3199 Bstr bstrLocation(aLocation); 3200 3197 3201 { 3198 3202 ComObjPtr<Medium> hardDisk; 3199 rc = findHardDisk(&aId, &aLocation, false /* aSetError */, &hardDisk);3203 rc = findHardDisk(&aId, bstrLocation, false /* aSetError */, &hardDisk); 3200 3204 if (SUCCEEDED(rc)) 3201 3205 { … … 3211 3215 { 3212 3216 ComObjPtr<Medium> image; 3213 rc = findDVDImage(&aId, &aLocation, false /* aSetError */, &image);3217 rc = findDVDImage(&aId, bstrLocation, false /* aSetError */, &image); 3214 3218 if (SUCCEEDED(rc)) 3215 3219 { … … 3225 3229 { 3226 3230 ComObjPtr<Medium> image; 3227 rc = findFloppyImage(&aId, &aLocation, false /* aSetError */, &image);3231 rc = findFloppyImage(&aId, bstrLocation, false /* aSetError */, &image); 3228 3232 if (SUCCEEDED(rc)) 3229 3233 { … … 4355 4359 STDMETHODIMP VirtualBox::CreateDHCPServer (IN_BSTR aName, IDHCPServer ** aServer) 4356 4360 { 4357 CheckComArg StrNotEmptyOrNull(aName);4361 CheckComArgNotNull(aName); 4358 4362 CheckComArgNotNull(aServer); 4359 4363 … … 4376 4380 STDMETHODIMP VirtualBox::FindDHCPServerByNetworkName(IN_BSTR aName, IDHCPServer ** aServer) 4377 4381 { 4378 CheckComArg StrNotEmptyOrNull(aName);4382 CheckComArgNotNull(aName); 4379 4383 CheckComArgNotNull(aServer); 4380 4384 … … 4452 4456 4453 4457 ComPtr<IDHCPServer> existing; 4454 rc = FindDHCPServerByNetworkName(name , existing.asOutParam());4458 rc = FindDHCPServerByNetworkName(name.mutableRaw(), existing.asOutParam()); 4455 4459 if (SUCCEEDED(rc)) 4456 4460 { -
trunk/src/VBox/Main/generic/NetIf-generic.cpp
r26550 r26553 231 231 Bstr ifname; 232 232 ComPtr<IHostNetworkInterface> iface; 233 if (FAILED(host->FindHostNetworkInterfaceById (Guid(aId).toUtf16(), iface.asOutParam())))233 if (FAILED(host->FindHostNetworkInterfaceById (Guid(aId).toUtf16(), iface.asOutParam()))) 234 234 return VERR_INVALID_PARAMETER; 235 iface->COMGETTER(Name) (ifname.asOutParam());236 if (ifname.is Empty())235 iface->COMGETTER(Name) (ifname.asOutParam()); 236 if (ifname.isNull()) 237 237 return VERR_INTERNAL_ERROR; 238 238 239 rc = progress->init(pVBox, 240 host, 241 Bstr("Removing host network interface"), 239 rc = progress->init (pVBox, host, 240 Bstr ("Removing host network interface"), 242 241 FALSE /* aCancelable */); 243 242 if(SUCCEEDED(rc)) -
trunk/src/VBox/Main/glue/ErrorInfo.cpp
r26550 r26553 170 170 { 171 171 mCalleeIID = aIID; 172 GetInterfaceNameByIID (aIID, mCalleeName.asOutParam());172 GetInterfaceNameByIID (aIID, mCalleeName.asOutParam()); 173 173 } 174 174 } -
trunk/src/VBox/Main/include/ApplianceImpl.h
r26550 r26553 96 96 97 97 void disksWeight(uint32_t &ulTotalMB, uint32_t &cDisks) const; 98 HRESULT setUpProgressFS(ComObjPtr<Progress> &pProgress, const Utf8Str &strDescription);99 HRESULT setUpProgressImportS3(ComObjPtr<Progress> &pProgress, const Utf8Str &strDescription);100 HRESULT setUpProgressWriteS3(ComObjPtr<Progress> &pProgress, const Utf8Str &strDescription);98 HRESULT setUpProgressFS(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription); 99 HRESULT setUpProgressImportS3(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription); 100 HRESULT setUpProgressWriteS3(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription); 101 101 102 102 struct LocationInfo; -
trunk/src/VBox/Main/include/ProgressImpl.h
r26550 r26553 52 52 HRESULT protectedInit(AutoInitSpan &aAutoInitSpan, 53 53 #if !defined (VBOX_COM_INPROC) 54 VirtualBox *aParent, 55 #endif 56 IUnknown *aInitiator, 57 const Utf8Str &strDescription, 58 OUT_GUID aId = NULL); 54 VirtualBox *aParent, 55 #endif 56 IUnknown *aInitiator, 57 CBSTR aDescription, OUT_GUID aId = NULL); 59 58 HRESULT protectedInit(AutoInitSpan &aAutoInitSpan); 60 59 void protectedUninit(AutoUninitSpan &aAutoUninitSpan); … … 106 105 107 106 const Guid mId; 108 const Utf8Str m_strDescription;107 const Bstr mDescription; 109 108 110 109 uint64_t m_ullTimestamp; // progress object creation timestamp, for ETA computation … … 127 126 128 127 ULONG m_ulCurrentOperation; // operations counter, incremented with each setNextOperation() 129 Utf8Str m_strOperationDescription;// name of current operation; initially from constructor, changed with setNextOperation()128 Bstr m_bstrOperationDescription; // name of current operation; initially from constructor, changed with setNextOperation() 130 129 ULONG m_ulCurrentOperationWeight; // weight of current operation, given to setNextOperation() 131 130 ULONG m_ulOperationPercent; // percentage of current operation, set with setCurrentOperationProgress() … … 177 176 #endif 178 177 IUnknown *aInitiator, 179 const Utf8Str &strDescription,178 CBSTR aDescription, 180 179 BOOL aCancelable, 181 180 OUT_GUID aId = NULL) … … 186 185 #endif 187 186 aInitiator, 188 strDescription,187 aDescription, 189 188 aCancelable, 190 189 1, // cOperations 191 190 1, // ulTotalOperationsWeight 192 strDescription, // bstrFirstOperationDescription191 aDescription, // bstrFirstOperationDescription 193 192 1, // ulFirstOperationWeight 194 193 aId); … … 212 211 #endif 213 212 IUnknown *aInitiator, 214 const Utf8Str &strDescription, 215 BOOL aCancelable, 213 CBSTR aDescription, BOOL aCancelable, 216 214 ULONG cOperations, 217 const Utf8Str &strFirstOperationDescription,215 CBSTR bstrFirstOperationDescription, 218 216 OUT_GUID aId = NULL) 219 217 { … … 223 221 #endif 224 222 aInitiator, 225 strDescription,223 aDescription, 226 224 aCancelable, 227 225 cOperations, // cOperations 228 226 cOperations, // ulTotalOperationsWeight = cOperations 229 strFirstOperationDescription, // bstrFirstOperationDescription227 bstrFirstOperationDescription, // bstrFirstOperationDescription 230 228 1, // ulFirstOperationWeight: weigh them all the same 231 229 aId); … … 237 235 #endif 238 236 IUnknown *aInitiator, 239 const Utf8Str &strDescription,237 CBSTR aDescription, 240 238 BOOL aCancelable, 241 239 ULONG cOperations, 242 240 ULONG ulTotalOperationsWeight, 243 const Utf8Str &strFirstOperationDescription,241 CBSTR bstrFirstOperationDescription, 244 242 ULONG ulFirstOperationWeight, 245 243 OUT_GUID aId = NULL); … … 247 245 HRESULT init(BOOL aCancelable, 248 246 ULONG aOperationCount, 249 const Utf8Str &strOperationDescription);247 CBSTR aOperationDescription); 250 248 251 249 void uninit(); -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r26550 r26553 246 246 ComObjPtr<Machine> *machine = NULL); 247 247 248 HRESULT findHardDisk(const Guid *aId, const Utf8Str *pstrLocation,248 HRESULT findHardDisk(const Guid *aId, CBSTR aLocation, 249 249 bool aSetError, ComObjPtr<Medium> *aHardDisk = NULL); 250 HRESULT findDVDImage(const Guid *aId, const Utf8Str *pstrLocation,250 HRESULT findDVDImage(const Guid *aId, CBSTR aLocation, 251 251 bool aSetError, ComObjPtr<Medium> *aImage = NULL); 252 HRESULT findFloppyImage(const Guid *aId, const Utf8Str *pstrLocation,252 HRESULT findFloppyImage(const Guid *aId, CBSTR aLocation, 253 253 bool aSetError, ComObjPtr<Medium> *aImage = NULL); 254 254 -
trunk/src/VBox/Main/xml/Settings.cpp
r26550 r26553 195 195 strLine = Utf8StrFmt(" (line %RU32)", pNode->getLineNumber()); 196 196 197 const char *pcsz = strLine.c_str(); 197 198 Utf8StrFmt str(N_("Error in %s%s -- %s"), 198 199 file->m->strFilename.c_str(), 199 strLine.c_str(),200 (pcsz) ? pcsz : "", 200 201 strWhat.c_str()); 201 202
Note:
See TracChangeset
for help on using the changeset viewer.