Changeset 30670 in vbox for trunk/include/VBox/com/defs.h
- Timestamp:
- Jul 6, 2010 2:37:09 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 63429
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/defs.h
r28950 r30670 521 521 if ((FAILED (aRC) && !FAILED (mRC)) || 522 522 (mRC == S_OK && aRC != S_OK)) 523 mRC = aRC;524 525 return *this;526 }527 528 operator HRESULT() const { return mRC; }529 530 HRESULT *operator&() { return &mRC; }531 532 private:533 534 HRESULT mRC;535 };536 537 /**538 * "Last worst" result type.539 *540 * Variables of this class are used instead of HRESULT variables when it is541 * desirable to memorize the "last worst" result code instead of the last542 * assigned one. In other words, an assignment operation to a variable of this543 * class will succeed only if the result code to assign has the same or worse544 * severity. The following table demonstrate this (the first column lists the545 * previous result code stored in the variable, the first row lists the new546 * assigned, 'A' means the assignment will take place, '> S_OK' means a warning547 * result code):548 *549 * {{{550 * FAILED > S_OK S_OK551 * FAILED A - -552 * > S_OK A A -553 * S_OK A A -554 *555 * }}}556 *557 * In practice, you will need to use a LWResult variable when you call some COM558 * method B after COM method A fails and want to return the result code of B559 * if B also fails, but still want to return the failed result code of A if B560 * issues a warning or succeeds.561 */562 class LWResult563 {564 565 public:566 567 /**568 * Constructs a new variable. Note that by default this constructor sets the569 * result code to E_FAIL to make sure a failure is returned to the caller if570 * the variable is never assigned another value (which is considered as the571 * improper use of this class).572 */573 LWResult (HRESULT aRC = E_FAIL) : mRC (aRC) {}574 575 LWResult &operator= (HRESULT aRC)576 {577 if (FAILED (aRC) ||578 (SUCCEEDED (mRC) && aRC != S_OK))579 523 mRC = aRC; 580 524
Note:
See TracChangeset
for help on using the changeset viewer.