Aaron Jacobs | e3d0eca | 2011-05-24 01:03:22 +0000 | [diff] [blame] | 1 | // Copyright 2007-2010 Baptiste Lepilleur |
| 2 | // Distributed under MIT license, or public domain if desired and |
| 3 | // recognized in your jurisdiction. |
| 4 | // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE |
| 5 | |
| 6 | #ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED |
| 7 | # define CPPTL_JSON_ASSERTIONS_H_INCLUDED |
| 8 | |
Aaron Jacobs | a761530 | 2011-05-24 06:27:36 +0000 | [diff] [blame] | 9 | #include <stdlib.h> |
| 10 | #include <iostream> |
| 11 | |
Aaron Jacobs | e3d0eca | 2011-05-24 01:03:22 +0000 | [diff] [blame] | 12 | #if !defined(JSON_IS_AMALGAMATION) |
| 13 | # include <json/config.h> |
| 14 | #endif // if !defined(JSON_IS_AMALGAMATION) |
| 15 | |
Aaron Jacobs | 7c507d7 | 2011-09-14 08:41:37 +0000 | [diff] [blame^] | 16 | #if JSON_USE_EXCEPTION |
Aaron Jacobs | e3d0eca | 2011-05-24 01:03:22 +0000 | [diff] [blame] | 17 | #define JSON_ASSERT( condition ) assert( condition ); // @todo <= change this into an exception throw |
| 18 | #define JSON_FAIL_MESSAGE( message ) throw std::runtime_error( message ); |
Aaron Jacobs | 7c507d7 | 2011-09-14 08:41:37 +0000 | [diff] [blame^] | 19 | #else // JSON_USE_EXCEPTION |
Aaron Jacobs | e3d0eca | 2011-05-24 01:03:22 +0000 | [diff] [blame] | 20 | #define JSON_ASSERT( condition ) assert( condition ); |
Aaron Jacobs | 7b5edd9 | 2011-05-25 04:59:57 +0000 | [diff] [blame] | 21 | #define JSON_FAIL_MESSAGE( message ) { std::cerr << std::endl << message << std::endl; exit(123); } |
Aaron Jacobs | e3d0eca | 2011-05-24 01:03:22 +0000 | [diff] [blame] | 22 | #endif |
| 23 | |
| 24 | #define JSON_ASSERT_MESSAGE( condition, message ) if (!( condition )) { JSON_FAIL_MESSAGE( message ) } |
| 25 | |
| 26 | #endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED |