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