Go to the documentation of this file.
32 #if !defined(IOSS_SMART_ASSERT_H)
33 #define IOSS_SMART_ASSERT_H
37 #endif // _MSC_VER > 1000
45 #pragma warning(disable : 4786)
49 #pragma warning(disable : 4355)
82 using string = std::string;
115 if (strMsg !=
nullptr) {
167 bool is(
const T & )
const {
return false; }
172 bool is(
char *
const &val) {
return val ==
nullptr; }
177 bool is(
const char *
const &val) {
return val ==
nullptr; }
218 std::ostringstream out;
221 bool bIsNull = f.
is(val);
315 handlers_collection::const_iterator found =
handlers().find(nLevel);
317 return (*found).second;
341 #ifdef SMART_ASSERT_DEBUG_MODE
342 #if SMART_ASSERT_DEBUG_MODE == 1
343 #define SMART_ASSERT_DEBUG
345 #undef SMART_ASSERT_DEBUG
352 #define SMART_ASSERT_DEBUG
354 #undef SMART_ASSERT_DEBUG
358 #ifdef SMART_ASSERT_DEBUG
360 #define SMART_ASSERT(expr) \
364 (void)::SmartAssert::make_assert(#expr).print_context(__FILE__, __LINE__).SMART_ASSERT_A
368 #define SMART_ASSERT(expr) \
372 (void)::SmartAssert::make_assert("").SMART_ASSERT_A
374 #endif // ifdef SMART_ASSERT_DEBUG
376 #define SMART_VERIFY(expr) \
380 (void)::SmartAssert::make_assert(#expr) \
382 .print_context(__FILE__, __LINE__) \
385 #define SMART_ASSERT_A(x) SMART_ASSERT_OP(x, B)
386 #define SMART_ASSERT_B(x) SMART_ASSERT_OP(x, A)
388 #define SMART_ASSERT_OP(x, next) SMART_ASSERT_A.print_current_val((x), #x).SMART_ASSERT_##next
static handlers_collection & handlers()
Definition: Ioss_SmartAssert.h:307
bool needs_handling_
Definition: Ioss_SmartAssert.h:326
void default_logger(const assert_context &context)
Definition: Ioss_SmartAssert.C:133
Assert(const Assert &other)
Definition: Ioss_SmartAssert.h:202
Assert & print_current_val(const type &val, const char *my_msg)
Definition: Ioss_SmartAssert.h:216
SmartAssert::assert_func assert_func
Definition: Ioss_SmartAssert.h:185
assert_context()
Definition: Ioss_SmartAssert.h:85
static assert_func get_handler(int nLevel)
Definition: Ioss_SmartAssert.h:313
const string & get_context_file() const
Definition: Ioss_SmartAssert.h:93
string expr_
Definition: Ioss_SmartAssert.h:130
Definition: Ioss_SmartAssert.h:70
Assert & print_context(const char *file, int line)
Definition: Ioss_SmartAssert.h:233
Assert & SMART_ASSERT_B
Definition: Ioss_SmartAssert.h:189
Definition: Ioss_SmartAssert.h:165
Definition: Ioss_SmartAssert.C:66
void set_level(int nLevel)
Definition: Ioss_SmartAssert.h:109
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:66
bool is(const T &) const
Definition: Ioss_SmartAssert.h:167
Assert & debug(const char *strMsg=nullptr)
Definition: Ioss_SmartAssert.h:254
int level_
Definition: Ioss_SmartAssert.h:134
void set_level_msg(const char *strMsg)
Definition: Ioss_SmartAssert.h:113
int get_level() const
Definition: Ioss_SmartAssert.h:110
void dump_context_summary(const assert_context &context, std::ostream &out)
Definition: Ioss_SmartAssert.C:85
static void set_log(std::ostream &out)
Definition: Ioss_SmartAssert.h:270
Assert & SMART_ASSERT_A
Definition: Ioss_SmartAssert.h:188
assert_context context_
Definition: Ioss_SmartAssert.h:325
std::string get_typeof_level(int nLevel)
Definition: Ioss_SmartAssert.C:69
void set_default_log_name(const char *str)
Definition: Ioss_SmartAssert.C:240
string file_
Definition: Ioss_SmartAssert.h:126
Assert & fatal(const char *strMsg=nullptr)
Definition: Ioss_SmartAssert.h:258
void default_warn_handler(const assert_context &context)
Definition: Ioss_SmartAssert.C:145
Definition: Ioss_SmartAssert.h:183
static assert_func & logger()
Definition: Ioss_SmartAssert.h:299
string msg_
Definition: Ioss_SmartAssert.h:135
bool is(char *const &val)
Definition: Ioss_SmartAssert.h:172
static void set_handler(int nLevel, assert_func handler)
Definition: Ioss_SmartAssert.h:278
void set_file_line(const char *file, int line)
Definition: Ioss_SmartAssert.h:88
void set_expr(const string &str)
Definition: Ioss_SmartAssert.h:97
Assert & msg(const char *strMsg)
Definition: Ioss_SmartAssert.h:239
Assert & warn(const char *strMsg=nullptr)
Definition: Ioss_SmartAssert.h:252
static void set_log(assert_func log)
Definition: Ioss_SmartAssert.h:276
bool is(const char *const &val)
Definition: Ioss_SmartAssert.h:177
std::pair< string, string > val_and_str
Definition: Ioss_SmartAssert.h:100
Definition: Ioss_SmartAssert.h:67
void default_fatal_handler(const assert_context &context)
Definition: Ioss_SmartAssert.C:212
void default_debug_handler(const assert_context &context)
Definition: Ioss_SmartAssert.C:151
Assert(const char *expr)
Definition: Ioss_SmartAssert.h:191
static void set_log(const char *strFileName)
Definition: Ioss_SmartAssert.h:262
void set_default_log_stream(std::ostream &out)
Definition: Ioss_SmartAssert.C:233
const string & get_level_msg() const
Definition: Ioss_SmartAssert.h:122
const string & get_expr() const
Definition: Ioss_SmartAssert.h:98
int get_context_line() const
Definition: Ioss_SmartAssert.h:94
Assert make_assert(const char *expr)
Definition: Ioss_SmartAssert.h:330
void add_val(const string &val, const string &str)
Definition: Ioss_SmartAssert.h:106
std::vector< val_and_str > vals_array
Definition: Ioss_SmartAssert.h:101
~Assert()
Definition: Ioss_SmartAssert.h:209
void default_error_handler(const assert_context &context)
Definition: Ioss_SmartAssert.C:204
Assert & level(int nLevel, const char *strMsg=nullptr)
Definition: Ioss_SmartAssert.h:245
void dump_context_detail(const assert_context &context, std::ostream &out)
Definition: Ioss_SmartAssert.C:100
int line_
Definition: Ioss_SmartAssert.h:127
void(*)(const assert_context &) assert_func
Definition: Ioss_SmartAssert.h:140
const vals_array & get_vals_array() const
Definition: Ioss_SmartAssert.h:104
Definition: Ioss_SmartAssert.h:80
void handle_assert()
Definition: Ioss_SmartAssert.h:282
Definition: Ioss_SmartAssert.h:63
vals_array vals_
Definition: Ioss_SmartAssert.h:131
Definition: Ioss_SmartAssert.h:74
void init_assert()
Definition: Ioss_SmartAssert.C:223
Assert & error(const char *strMsg=nullptr)
Definition: Ioss_SmartAssert.h:256
std::map< int, assert_func > handlers_collection
Definition: Ioss_SmartAssert.h:306