summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/jsoncpp/include/json/assertions.h
diff options
context:
space:
mode:
author Cowering <cowering@users.noreply.github.com>2015-07-02 16:53:38 -0500
committer Cowering <cowering@users.noreply.github.com>2015-07-08 14:31:26 -0500
commit21b5ebeba7dc4ef9d8b1f809741ad73418989a16 (patch)
treed163ac2b76b5362c8da954ee8221922c6eb126dc /3rdparty/jsoncpp/include/json/assertions.h
parent1e37ed88936371ede63ada5b7aea9dd1d0bc287c (diff)
github version of jsoncpp with some fixes: pedantic and C++98 and others. please try to compile for all platforms
Diffstat (limited to '3rdparty/jsoncpp/include/json/assertions.h')
-rw-r--r--3rdparty/jsoncpp/include/json/assertions.h39
1 files changed, 26 insertions, 13 deletions
diff --git a/3rdparty/jsoncpp/include/json/assertions.h b/3rdparty/jsoncpp/include/json/assertions.h
index 5ef7e7bb7d4..fbec7ae00e2 100644
--- a/3rdparty/jsoncpp/include/json/assertions.h
+++ b/3rdparty/jsoncpp/include/json/assertions.h
@@ -7,35 +7,48 @@
#define CPPTL_JSON_ASSERTIONS_H_INCLUDED
#include <stdlib.h>
+#include <sstream>
#if !defined(JSON_IS_AMALGAMATION)
#include "config.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
+/** It should not be possible for a maliciously designed file to
+ * cause an abort() or seg-fault, so these macros are used only
+ * for pre-condition violations and internal logic errors.
+ */
#if JSON_USE_EXCEPTION
-#include <stdexcept>
-#define JSON_ASSERT(condition) \
- assert(condition); // @todo <= change this into an exception throw
-#define JSON_FAIL_MESSAGE(message) throw std::runtime_error(message);
+
+// @todo <= add detail about condition in exception
+# define JSON_ASSERT(condition) \
+ {if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
+
+# define JSON_FAIL_MESSAGE(message) \
+ { \
+ std::ostringstream oss; oss << message; \
+ Json::throwLogicError(oss.str()); \
+ abort(); \
+ }
+
#else // JSON_USE_EXCEPTION
-#define JSON_ASSERT(condition) assert(condition);
+
+# define JSON_ASSERT(condition) assert(condition)
// The call to assert() will show the failure message in debug builds. In
-// release bugs we write to invalid memory in order to crash hard, so that a
-// debugger or crash reporter gets the chance to take over. We still call exit()
-// afterward in order to tell the compiler that this macro doesn't return.
-#define JSON_FAIL_MESSAGE(message) \
+// release builds we abort, for a core-dump or debugger.
+# define JSON_FAIL_MESSAGE(message) \
{ \
- assert(false&& message); \
- strcpy(reinterpret_cast<char*>(666), message); \
- exit(123); \
+ std::ostringstream oss; oss << message; \
+ assert(false && oss.str().c_str()); \
+ abort(); \
}
+
#endif
#define JSON_ASSERT_MESSAGE(condition, message) \
if (!(condition)) { \
- JSON_FAIL_MESSAGE(message) \
+ JSON_FAIL_MESSAGE(message); \
}
#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED