summaryrefslogtreecommitdiff
path: root/rapidjsonwrapper.h
blob: 18e6bd8f9094d77a1e038ec21f6a2708eb27ddd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
#include <exception>
#include <stdexcept>

#if defined(__GNUC__) && __GNUC__ >= 8
// Disable warnings from rapidjson performance optimizations
	#pragma GCC diagnostic push
	#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif

struct GenericException;
struct ParseException;

struct GenericException : public std::exception
{
	GenericException() : std::exception() {}
	virtual const char* what() const throw() { return "Exception while parsing json."; }
};

#ifdef __SSE2__
#define RAPIDJSON_SSE2 1
#endif

#ifdef __ARM_NEON__
#define RAPIDJSON_NEON 1
#endif

#define RAPIDJSON_HAS_STDSTRING      0
#define RAPIDJSON_HAS_CXX11_NOEXCEPT 0
#define RAPIDJSON_ASSERT(x) \
	do \
	{ \
		if (!(x)) \
			throw GenericException(); \
	} while (0);
#define RAPIDJSON_PARSE_ERROR_NORETURN(parseErrorCode, offset) \
	throw ParseException(parseErrorCode, #parseErrorCode, offset)

#include "rapidjson/error/error.h"
struct ParseException : public std::runtime_error, public rapidjson::ParseResult
{
	ParseException(rapidjson::ParseErrorCode code, const char* msg, size_t offset) :
	    std::runtime_error(msg), ParseResult(code, offset)
	{}
};

#include "rapidjson/error/en.h"
#include "rapidjson/rapidjson.h"
#include "rapidjson/document.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h"
#include "rapidjson/prettywriter.h"

#if defined(__GNUC__) && __GNUC__ >= 8
	#pragma GCC diagnostic pop
#endif