Changeset 32718 in vbox for trunk/include/VBox
- Timestamp:
- Sep 23, 2010 12:57:52 PM (14 years ago)
- Location:
- trunk/include/VBox/com
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/ErrorInfo.h
r30683 r32718 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2010 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 55 55 * ... 56 56 * HRESULT rc = foo->SomeMethod(); 57 * if (FAILED 58 * ErrorInfo info 57 * if (FAILED(rc)) { 58 * ErrorInfo info(foo); 59 59 * if (info.isFullAvailable()) { 60 * printf 60 * printf("error message = %ls\n", info.getText().raw()); 61 61 * } 62 62 * } … … 227 227 * 228 228 * This method returns a non-null IID only if the instance was created 229 * using #template <class I> ErrorInfo 230 * template <class I> ErrorInfo (const ComPtr<I> &i) constructor.229 * using #template <class I> ErrorInfo(I *i) or 230 * template <class I> ErrorInfo(const ComPtr<I> &i) constructor. 231 231 */ 232 232 const Guid& getCalleeIID() const … … 239 239 * 240 240 * This method returns a non-null name only if the instance was created 241 * using #template <class I> ErrorInfo 242 * template <class I> ErrorInfo (const ComPtr<I> &i) constructor.241 * using #template <class I> ErrorInfo(I *i) or 242 * template <class I> ErrorInfo(const ComPtr<I> &i) constructor. 243 243 */ 244 244 const Bstr& getCalleeName() const … … 248 248 249 249 /** 250 * Resets all collected error information. #is Null() will251 * return @c true after this method is called.250 * Resets all collected error information. #isBasicAvailable() and 251 * #isFullAvailable will return @c true after this method is called. 252 252 */ 253 253 void setNull() … … 327 327 * <code> 328 328 * rc = foo->method(); 329 * if (FAILED 329 * if (FAILED(rc)) 330 330 * { 331 331 * ErrorInfoKeeper eik; … … 353 353 * the instance uninitialized. 354 354 */ 355 ErrorInfoKeeper 356 : ErrorInfo (false), mForgot(aIsNull)355 ErrorInfoKeeper(bool aIsNull = false) 356 : ErrorInfo(false), mForgot(aIsNull) 357 357 { 358 358 if (!aIsNull) 359 init 359 init(true /* aKeepObj */); 360 360 } 361 361 … … 399 399 * stored error info object to the caller. 400 400 */ 401 ComPtr 401 ComPtr<IUnknown> takeError() { mForgot = true; return mErrorInfo; } 402 402 403 403 private: -
trunk/include/VBox/com/string.h
r31539 r32718 179 179 } 180 180 181 int compare(BSTR str) const 182 { 183 return compare((CBSTR)str); 181 int compare(BSTR str, CaseSensitivity cs = CaseSensitive) const 182 { 183 return compare((CBSTR)str, cs); 184 } 185 186 int compare(const Bstr &that, CaseSensitivity cs = CaseSensitive) const 187 { 188 return compare(that.m_bstr, cs); 184 189 } 185 190 … … 201 206 * @note Always use this method to check if an instance is empty. Do not 202 207 * use length() because that may need to run through the entire string 203 * (Bstr does not cache string lengths). Also do not use operator bool(); 204 * for one, MSVC is really annoying with its thinking that that is ambiguous, 205 * and even though operator bool() is protected with Bstr, at least gcc uses 206 * operator CBSTR() when a construct like "if (string)" is encountered, which 207 * is always true now since it raw() never returns an empty string. Again, 208 * always use isEmpty() even though if (string) may compile! 208 * (Bstr does not cache string lengths). 209 209 */ 210 210 bool isEmpty() const { return m_bstr == NULL || *m_bstr == 0; } 211 211 212 212 size_t length() const { return isEmpty() ? 0 : ::RTUtf16Len((PRTUTF16)m_bstr); } 213 214 /**215 * Returns true if the member string is not empty. I'd like to make this216 * private but since we require operator BSTR() it's futile anyway because217 * the compiler will then (wrongly) use that one instead. Also if this is218 * private the odd WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP macro below219 * will fail on Windows.220 */221 operator bool() const222 {223 return m_bstr != NULL;224 }225 213 226 214 /** … … 236 224 return g_bstrEmpty; 237 225 } 238 239 /**240 * Convenience operator so that Bstr's can be passed to CBSTR input parameters241 * of COM methods.242 */243 operator CBSTR() const { return raw(); }244 245 /**246 * Convenience operator so that Bstr's can be passed to CBSTR input parameters247 * of COM methods. Unfortunately this is required for Windows since with248 * MSCOM, input BSTR parameters of interface methods are not const.249 */250 operator BSTR() { return (BSTR)raw(); }251 226 252 227 /** … … 397 372 inline bool operator!=(BSTR l, const Bstr &r) { return r.operator!=(l); } 398 373 399 // work around error C2593 of the stupid MSVC 7.x ambiguity resolver400 WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Bstr)401 374 402 375 //////////////////////////////////////////////////////////////////////////////// … … 431 404 Utf8Str(const Bstr &that) 432 405 { 406 copyFrom(that.raw()); 407 } 408 409 Utf8Str(CBSTR that) 410 { 433 411 copyFrom(that); 434 412 } 435 413 436 Utf8Str(CBSTR that)437 {438 copyFrom(that);439 }440 441 414 Utf8Str& operator=(const MiniString &that) 442 415 { … … 454 427 { 455 428 cleanup(); 456 copyFrom(that );429 copyFrom(that.raw()); 457 430 return *this; 458 431 }
Note:
See TracChangeset
for help on using the changeset viewer.