Path: blob/master/thirdparty/openxr/src/external/jsoncpp/include/json/assertions.h
9913 views
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors1// Distributed under MIT license, or public domain if desired and2// recognized in your jurisdiction.3// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE45#ifndef JSON_ASSERTIONS_H_INCLUDED6#define JSON_ASSERTIONS_H_INCLUDED78#include <cstdlib>9#include <sstream>1011#if !defined(JSON_IS_AMALGAMATION)12#include "config.h"13#endif // if !defined(JSON_IS_AMALGAMATION)1415/** It should not be possible for a maliciously designed file to16* cause an abort() or seg-fault, so these macros are used only17* for pre-condition violations and internal logic errors.18*/19#if JSON_USE_EXCEPTION2021// @todo <= add detail about condition in exception22#define JSON_ASSERT(condition) \23do { \24if (!(condition)) { \25Json::throwLogicError("assert json failed"); \26} \27} while (0)2829#define JSON_FAIL_MESSAGE(message) \30do { \31OStringStream oss; \32oss << message; \33Json::throwLogicError(oss.str()); \34abort(); \35} while (0)3637#else // JSON_USE_EXCEPTION3839#define JSON_ASSERT(condition) assert(condition)4041// The call to assert() will show the failure message in debug builds. In42// release builds we abort, for a core-dump or debugger.43#define JSON_FAIL_MESSAGE(message) \44{ \45OStringStream oss; \46oss << message; \47assert(false && oss.str().c_str()); \48abort(); \49}5051#endif5253#define JSON_ASSERT_MESSAGE(condition, message) \54do { \55if (!(condition)) { \56JSON_FAIL_MESSAGE(message); \57} \58} while (0)5960#endif // JSON_ASSERTIONS_H_INCLUDED616263