Go to the documentation of this file.
6 #if !defined(IOSS_SMART_ASSERT_H)
7 #define IOSS_SMART_ASSERT_H
11 #endif // _MSC_VER > 1000
19 #pragma warning(disable : 4786)
23 #pragma warning(disable : 4355)
56 using string = std::string;
89 if (strMsg !=
nullptr) {
141 bool is(
const T & )
const {
return false; }
146 bool is(
char *
const &val) {
return val ==
nullptr; }
151 bool is(
const char *
const &val) {
return val ==
nullptr; }
192 std::ostringstream out;
195 bool bIsNull = f.
is(val);
289 handlers_collection::const_iterator found =
handlers().find(nLevel);
291 return (*found).second;
315 #ifdef SMART_ASSERT_DEBUG_MODE
316 #if SMART_ASSERT_DEBUG_MODE == 1
317 #define SMART_ASSERT_DEBUG
319 #undef SMART_ASSERT_DEBUG
326 #define SMART_ASSERT_DEBUG
328 #undef SMART_ASSERT_DEBUG
332 #ifdef SMART_ASSERT_DEBUG
334 #define SMART_ASSERT(expr) \
338 (void)::SmartAssert::make_assert(#expr).print_context(__FILE__, __LINE__).SMART_ASSERT_A
342 #define SMART_ASSERT(expr) \
346 (void)::SmartAssert::make_assert("").SMART_ASSERT_A
348 #endif // ifdef SMART_ASSERT_DEBUG
350 #define SMART_VERIFY(expr) \
354 (void)::SmartAssert::make_assert(#expr) \
356 .print_context(__FILE__, __LINE__) \
359 #define SMART_ASSERT_A(x) SMART_ASSERT_OP(x, B)
360 #define SMART_ASSERT_B(x) SMART_ASSERT_OP(x, A)
362 #define SMART_ASSERT_OP(x, next) SMART_ASSERT_A.print_current_val((x), #x).SMART_ASSERT_##next
@ lvl_fatal
Definition: Ioss_SmartAssert.h:48
static handlers_collection & handlers()
Definition: Ioss_SmartAssert.h:281
bool needs_handling_
Definition: Ioss_SmartAssert.h:300
void default_logger(const assert_context &context)
Definition: Ioss_SmartAssert.C:108
Assert(const Assert &other)
Definition: Ioss_SmartAssert.h:176
Assert & print_current_val(const type &val, const char *my_msg)
Definition: Ioss_SmartAssert.h:190
SmartAssert::assert_func assert_func
Definition: Ioss_SmartAssert.h:159
assert_context()
Definition: Ioss_SmartAssert.h:59
static assert_func get_handler(int nLevel)
Definition: Ioss_SmartAssert.h:287
const string & get_context_file() const
Definition: Ioss_SmartAssert.h:67
string expr_
Definition: Ioss_SmartAssert.h:104
Assert & print_context(const char *file, int line)
Definition: Ioss_SmartAssert.h:207
Assert & SMART_ASSERT_B
Definition: Ioss_SmartAssert.h:163
Definition: Ioss_SmartAssert.h:140
@ lvl_error
Definition: Ioss_SmartAssert.h:44
Definition: Ioss_SmartAssert.C:41
void set_level(int nLevel)
Definition: Ioss_SmartAssert.h:83
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:40
bool is(const T &) const
Definition: Ioss_SmartAssert.h:141
Assert & debug(const char *strMsg=nullptr)
Definition: Ioss_SmartAssert.h:228
int level_
Definition: Ioss_SmartAssert.h:108
void set_level_msg(const char *strMsg)
Definition: Ioss_SmartAssert.h:87
int get_level() const
Definition: Ioss_SmartAssert.h:84
void dump_context_summary(const assert_context &context, std::ostream &out)
Definition: Ioss_SmartAssert.C:60
static void set_log(std::ostream &out)
Definition: Ioss_SmartAssert.h:244
Assert & SMART_ASSERT_A
Definition: Ioss_SmartAssert.h:162
assert_context context_
Definition: Ioss_SmartAssert.h:299
std::string get_typeof_level(int nLevel)
Definition: Ioss_SmartAssert.C:44
void set_default_log_name(const char *str)
Definition: Ioss_SmartAssert.C:215
string file_
Definition: Ioss_SmartAssert.h:100
Assert & fatal(const char *strMsg=nullptr)
Definition: Ioss_SmartAssert.h:232
@ lvl_debug
Definition: Ioss_SmartAssert.h:41
void default_warn_handler(const assert_context &context)
Definition: Ioss_SmartAssert.C:120
Definition: Ioss_SmartAssert.h:158
static assert_func & logger()
Definition: Ioss_SmartAssert.h:273
string msg_
Definition: Ioss_SmartAssert.h:109
bool is(char *const &val)
Definition: Ioss_SmartAssert.h:146
static void set_handler(int nLevel, assert_func handler)
Definition: Ioss_SmartAssert.h:252
void set_file_line(const char *file, int line)
Definition: Ioss_SmartAssert.h:62
void set_expr(const string &str)
Definition: Ioss_SmartAssert.h:71
Assert & msg(const char *strMsg)
Definition: Ioss_SmartAssert.h:213
Assert & warn(const char *strMsg=nullptr)
Definition: Ioss_SmartAssert.h:226
static void set_log(assert_func log)
Definition: Ioss_SmartAssert.h:250
bool is(const char *const &val)
Definition: Ioss_SmartAssert.h:151
std::pair< string, string > val_and_str
Definition: Ioss_SmartAssert.h:74
void default_fatal_handler(const assert_context &context)
Definition: Ioss_SmartAssert.C:187
void default_debug_handler(const assert_context &context)
Definition: Ioss_SmartAssert.C:126
Assert(const char *expr)
Definition: Ioss_SmartAssert.h:165
static void set_log(const char *strFileName)
Definition: Ioss_SmartAssert.h:236
void set_default_log_stream(std::ostream &out)
Definition: Ioss_SmartAssert.C:208
@ lvl_warn
Definition: Ioss_SmartAssert.h:37
const string & get_level_msg() const
Definition: Ioss_SmartAssert.h:96
const string & get_expr() const
Definition: Ioss_SmartAssert.h:72
int get_context_line() const
Definition: Ioss_SmartAssert.h:68
Assert make_assert(const char *expr)
Definition: Ioss_SmartAssert.h:304
void add_val(const string &val, const string &str)
Definition: Ioss_SmartAssert.h:80
std::vector< val_and_str > vals_array
Definition: Ioss_SmartAssert.h:75
~Assert()
Definition: Ioss_SmartAssert.h:183
void default_error_handler(const assert_context &context)
Definition: Ioss_SmartAssert.C:179
Assert & level(int nLevel, const char *strMsg=nullptr)
Definition: Ioss_SmartAssert.h:219
void dump_context_detail(const assert_context &context, std::ostream &out)
Definition: Ioss_SmartAssert.C:75
int line_
Definition: Ioss_SmartAssert.h:101
void(*)(const assert_context &) assert_func
Definition: Ioss_SmartAssert.h:114
const vals_array & get_vals_array() const
Definition: Ioss_SmartAssert.h:78
Definition: Ioss_SmartAssert.h:55
void handle_assert()
Definition: Ioss_SmartAssert.h:256
vals_array vals_
Definition: Ioss_SmartAssert.h:105
void init_assert()
Definition: Ioss_SmartAssert.C:198
Assert & error(const char *strMsg=nullptr)
Definition: Ioss_SmartAssert.h:230
std::map< int, assert_func > handlers_collection
Definition: Ioss_SmartAssert.h:280