BeAssert.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------------------+
2 |
3 | Supplied under applicable software license agreement.
4 |
5 | Copyright (c) 2018 Bentley Systems, Incorporated. All rights reserved.
6 |
7 +---------------------------------------------------------------------------------------*/
8 #pragma once
9 
11 
12 #include "Bentley.h"
13 
15 
18 {
19 enum class AssertType
20  {
21  Normal = 0,
22  Data = 1,
23  Sigabrt = 2,
24  TypeCount = 3,
25  All = 99
26  };
27 typedef void T_BeAssertHandler (wchar_t const* _Message, wchar_t const*_File, unsigned _Line, AssertType atype);
28 
29 
31 BENTLEYDLL_EXPORT static void SetBeAssertHandler (T_BeAssertHandler*);
33 BENTLEYDLL_EXPORT static void PerformBeAssert(wchar_t const* _Message, wchar_t const*_File, unsigned _Line);
36 BENTLEYDLL_EXPORT static void DefaultAssertionFailureHandler (wchar_t const* message, wchar_t const* file, unsigned line);
37 };
38 
40 
41 #include <assert.h>
42 
43 #ifdef NDEBUG
44 
45 #define BeAssert(_Expression) ((void)0)
46 #define BeDataAssert(_Expression) ((void)0)
47 #define BeAssertOnce(_Expression) ((void)0)
48 #define BeDataAssertOnce(_Expression) ((void)0)
49 
50 #else
51 
56 #define BeAssert(_Expression) (void)( (!!(_Expression)) || (BeAssertFunctions::PerformBeAssert(_CRT_WIDE(#_Expression), _CRT_WIDE(__FILE__), __LINE__), 0) )
57 
58 #define BeAssertOnce(_Expression) \
59  do { \
60  static int st_bAssertedOnce = 0; \
61  if (!st_bAssertedOnce) \
62  { \
63  (!!(_Expression)) || (BeAssertFunctions::PerformBeAssert(_CRT_WIDE(#_Expression), _CRT_WIDE(__FILE__), __LINE__), 0); \
64  st_bAssertedOnce = 1; \
65  } \
66  } while (0)
67 
68 
69 
70 #endif /* NDEBUG */
#define BENTLEYDLL_EXPORT
Definition: Bentley.h:249
The default file attribute.
Definition: TextTableHandler.h:216
Definition: BeAssert.h:17
#define BEGIN_BENTLEY_NAMESPACE
Definition: Bentley.r.h:24
AssertType
Definition: BeAssert.h:19
Defines typedefs and constants that can be used across other namespaces. All Bentley-authored C++ sou...
void T_BeAssertHandler(wchar_t const *_Message, wchar_t const *_File, unsigned _Line, AssertType atype)
Definition: BeAssert.h:27
#define END_BENTLEY_NAMESPACE
Definition: Bentley.r.h:25

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.