ufe  4.2
Universal Front End is a DCC-agnostic component that will allow a DCC to browse and edit data in multiple data models
ufeAssert.h
Go to the documentation of this file.
1 #line 1 "S:/jenkins/workspace/ECP/ufe/ufe-full-python3.10-windows/ufe/include/ufeAssert.h"
2 #ifndef _ufeAssert
3 #define _ufeAssert
4 // ===========================================================================
5 // Copyright 2018 Autodesk, Inc. All rights reserved.
6 //
7 // Use of this software is subject to the terms of the Autodesk license
8 // agreement provided at the time of installation or download, or which
9 // otherwise accompanies this software in either electronic or hard copy form.
10 // ===========================================================================
11 
12 #include "common/ufeExport.h"
13 
14 #if !defined(NDEBUG)
15 #define UFE_ENABLE_ASSERTS
16 #endif
17 
18 // \brief Customized assertion macro that can be explicitly enabled on non-debug builds.
19 //
20 // When UFE_ENABLE_ASSERTS is defined, the macro UFE_ASSERT_MSG executes a
21 // custom assertion check, even on non-debug builds. If UFE_ENABLE_ASSERTS
22 // is not defined, UFE_ASSERT_MSG does nothing.
23 //
24 // The macro UFE_ASSERT_MSG also allows a description of the assertion error
25 // to be emitted when a failure occurs.
26 //
27 // \param EXPR The expression to assert
28 // \param MSG The description of the assertion error
29 #ifdef UFE_ENABLE_ASSERTS
30  #ifdef WIN32
31  #define UFE_ASSERT_MSG(EXPR, MSG) \
32  ( (EXPR) ? (void)0 : Ufe::handleAssert(__FUNCTION__, __FILE__, __LINE__, #EXPR, MSG) )
33  #else
34  #define UFE_ASSERT_MSG(EXPR, MSG) \
35  ( (EXPR) ? (void)0 : Ufe::handleAssert(__func__, __FILE__, __LINE__, #EXPR, MSG) )
36  #endif
37  #define UFE_ASSERT_COMPILED(CODE) CODE
38 #else
39  #define UFE_ASSERT_MSG(EXPR, MSG)
40  #define UFE_ASSERT_COMPILED(CODE)
41 #endif
42 
46 #define UFE_ASSERT(EXPR) UFE_ASSERT_MSG(EXPR, nullptr)
47 
49 {
50 // \brief Handle the custom assertion action.
51 //
52 // This function display a message containing the failing expression, the
53 // filename, line number, and function where the assertion failure occurred. It
54 // also display an optional message description of the assertion failure.
55 //
56 // In order to avoid the execution on a potential unstable environment an
57 // exception is also thrown after the assertion error is displayed.
58 //
59 // \note This function only display the assertion message. The actual expression
60 // check is performed in the UFE_ASSERT_MSG macro.
61 //
62 // \param func The function where the assertion occurred.
63 // \param filename The filename where the assertion occurred.
64 // \param lineno The line number where the assertion occurred.
65 // \param expr The expression that caused the assertion failure.
66 // \param msg Custom message description to be printed.
67 UFE_SDK_DECL void handleAssert(const char* func,
68  const char* filename,
69  int lineno,
70  const char* expr,
71  const char* msg);
72 
73 } // UFE_NS_DEF
74 
75 #endif /* _ufeAssert */
Definition of macros for symbol visibility.
#define UFE_NS_DEF
Definition: ufe.h:35
void handleAssert(const char *func, const char *filename, int lineno, const char *expr, const char *msg)
#define UFE_SDK_DECL
Definition: ufeExport.h:36