VirtualBox

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

Last change on this file since 47018 was 45125, checked in by vboxsync, 12 years ago

VBox/com/*.h: file header and block fixes.

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