blob: 84eb5d7e293a65bd5eb960c04712183949509346 [file] [log] [blame]
Aaron Jacobse3d0eca2011-05-24 01:03:22 +00001// 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 Jacobsa7615302011-05-24 06:27:36 +00009#include <stdlib.h>
10#include <iostream>
11
Aaron Jacobse3d0eca2011-05-24 01:03:22 +000012#if !defined(JSON_IS_AMALGAMATION)
13# include <json/config.h>
14#endif // if !defined(JSON_IS_AMALGAMATION)
15
Aaron Jacobs7c507d72011-09-14 08:41:37 +000016#if JSON_USE_EXCEPTION
Aaron Jacobse3d0eca2011-05-24 01:03:22 +000017#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 Jacobs7c507d72011-09-14 08:41:37 +000019#else // JSON_USE_EXCEPTION
Aaron Jacobse3d0eca2011-05-24 01:03:22 +000020#define JSON_ASSERT( condition ) assert( condition );
Aaron Jacobs7b5edd92011-05-25 04:59:57 +000021#define JSON_FAIL_MESSAGE( message ) { std::cerr << std::endl << message << std::endl; exit(123); }
Aaron Jacobse3d0eca2011-05-24 01:03:22 +000022#endif
23
24#define JSON_ASSERT_MESSAGE( condition, message ) if (!( condition )) { JSON_FAIL_MESSAGE( message ) }
25
26#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED