Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
00007 #define CPPTL_JSON_ASSERTIONS_H_INCLUDED
00008
00009 #include <stdlib.h>
00010 #include <sstream>
00011
00012 #if !defined(JSON_IS_AMALGAMATION)
00013 #include "config.h"
00014 #endif // if !defined(JSON_IS_AMALGAMATION)
00015
00020 #if JSON_USE_EXCEPTION
00021
00022
00023 # define JSON_ASSERT(condition) \
00024 {if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
00025
00026 # define JSON_FAIL_MESSAGE(message) \
00027 { \
00028 std::ostringstream oss; oss << message; \
00029 Json::throwLogicError(oss.str()); \
00030 abort(); \
00031 }
00032
00033 #else // JSON_USE_EXCEPTION
00034
00035 # define JSON_ASSERT(condition) assert(condition)
00036
00037
00038
00039 # define JSON_FAIL_MESSAGE(message) \
00040 { \
00041 std::ostringstream oss; oss << message; \
00042 assert(false && oss.str().c_str()); \
00043 abort(); \
00044 }
00045
00046
00047 #endif
00048
00049 #define JSON_ASSERT_MESSAGE(condition, message) \
00050 if (!(condition)) { \
00051 JSON_FAIL_MESSAGE(message); \
00052 }
00053
00054 #endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED