VirtualBox

source: vbox/trunk/include/VBox/com/assert.h@ 27023

Last change on this file since 27023 was 25149, checked in by vboxsync, 15 years ago

Main: cleanup: remove all CheckComRC* macros (no functional change)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/** @file
2 * MS COM / XPCOM Abstraction Layer:
3 * Assertion macros for COM/XPCOM
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 *
26 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31#ifndef ___VBox_com_assert_h
32#define ___VBox_com_assert_h
33
34#include <iprt/assert.h>
35
36/**
37 * Asserts that the COM result code is succeeded in strict builds.
38 * In non-strict builds the result code will be NOREF'ed to kill compiler warnings.
39 *
40 * @param rc COM result code
41 */
42#define AssertComRC(rc) \
43 do { AssertMsg (SUCCEEDED (rc), ("COM RC = %Rhrc (0x%08X)\n", rc, rc)); NOREF (rc); } while (0)
44
45/**
46 * A special version of AssertComRC that returns the given expression
47 * if the result code is failed.
48 *
49 * @param rc COM result code
50 * @param ret the expression to return
51 */
52#define AssertComRCReturn(rc, ret) \
53 AssertMsgReturn (SUCCEEDED (rc), ("COM RC = %Rhrc (0x%08X)\n", rc, rc), ret)
54
55/**
56 * A special version of AssertComRC that returns the given result code
57 * if it is failed.
58 *
59 * @param rc COM result code
60 * @param ret the expression to return
61 */
62#define AssertComRCReturnRC(rc) \
63 AssertMsgReturn (SUCCEEDED (rc), ("COM RC = %Rhrc (0x%08X)\n", rc, rc), rc)
64
65/**
66 * A special version of AssertComRC that returns if the result code is failed.
67 *
68 * @param rc COM result code
69 * @param ret the expression to return
70 */
71#define AssertComRCReturnVoid(rc) \
72 AssertMsgReturnVoid (SUCCEEDED (rc), ("COM RC = %Rhrc (0x%08X)\n", rc, rc))
73
74/**
75 * A special version of AssertComRC that evaluates the given expression and
76 * breaks if the result code is failed.
77 *
78 * @param rc COM result code
79 * @param eval the expression to evaluate
80 */
81#define AssertComRCBreak(rc, eval) \
82 if (!SUCCEEDED (rc)) { AssertComRC (rc); eval; break; } else do {} while (0)
83
84/**
85 * A special version of AssertComRC that evaluates the given expression and
86 * throws it if the result code is failed.
87 *
88 * @param rc COM result code
89 * @param eval the expression to throw
90 */
91#define AssertComRCThrow(rc, eval) \
92 if (!SUCCEEDED (rc)) { AssertComRC (rc); throw (eval); } else do {} while (0)
93
94/**
95 * A special version of AssertComRC that just breaks if the result code is
96 * failed.
97 *
98 * @param rc COM result code
99 */
100#define AssertComRCBreakRC(rc) \
101 if (!SUCCEEDED (rc)) { AssertComRC (rc); break; } else do {} while (0)
102
103/**
104 * A special version of AssertComRC that just throws @a rc if the result code is
105 * failed.
106 *
107 * @param rc COM result code
108 */
109#define AssertComRCThrowRC(rc) \
110 if (!SUCCEEDED (rc)) { AssertComRC (rc); throw rc; } else do {} while (0)
111
112#endif // !___VBox_com_assert_h
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette