JsonCpp project page Classes Namespace JsonCpp home page

config.h
Go to the documentation of this file.
1 // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
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 JSON_CONFIG_H_INCLUDED
7 #define JSON_CONFIG_H_INCLUDED
8 #include <stddef.h>
9 #include <string> //typedef String
10 #include <stdint.h> //typedef int64_t, uint64_t
11 
13 //# define JSON_IN_CPPTL 1
14 
16 //# define JSON_USE_CPPTL 1
20 //# define JSON_USE_CPPTL_SMALLMAP 1
21 
22 // If non-zero, the library uses exceptions to report bad input instead of C
23 // assertion macros. The default is to use exceptions.
24 #ifndef JSON_USE_EXCEPTION
25 #define JSON_USE_EXCEPTION 1
26 #endif
27 
31 // #define JSON_IS_AMALGAMATION
32 
33 #ifdef JSON_IN_CPPTL
34 #include <cpptl/config.h>
35 #ifndef JSON_USE_CPPTL
36 #define JSON_USE_CPPTL 1
37 #endif
38 #endif
39 
40 #ifdef JSON_IN_CPPTL
41 #define JSON_API CPPTL_API
42 #elif defined(JSON_DLL_BUILD)
43 #if defined(_MSC_VER) || defined(__MINGW32__)
44 #define JSON_API __declspec(dllexport)
45 #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
46 #endif // if defined(_MSC_VER)
47 #elif defined(JSON_DLL)
48 #if defined(_MSC_VER) || defined(__MINGW32__)
49 #define JSON_API __declspec(dllimport)
50 #define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
51 #endif // if defined(_MSC_VER)
52 #endif // ifdef JSON_IN_CPPTL
53 #if !defined(JSON_API)
54 #define JSON_API
55 #endif
56 
57 // If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
58 // integer
59 // Storages, and 64 bits integer support is disabled.
60 // #define JSON_NO_INT64 1
61 
62 #if defined(_MSC_VER) // MSVC
63 # if _MSC_VER <= 1200 // MSVC 6
64  // Microsoft Visual Studio 6 only support conversion from __int64 to double
65  // (no conversion from unsigned __int64).
66 # define JSON_USE_INT64_DOUBLE_CONVERSION 1
67  // Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
68  // characters in the debug information)
69  // All projects I've ever seen with VS6 were using this globally (not bothering
70  // with pragma push/pop).
71 # pragma warning(disable : 4786)
72 # endif // MSVC 6
73 
74 # if _MSC_VER >= 1500 // MSVC 2008
75 # define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
77 # endif
78 
79 #endif // defined(_MSC_VER)
80 
81 // In c++11 the override keyword allows you to explicitly define that a function
82 // is intended to override the base-class version. This makes the code more
83 // managable and fixes a set of common hard-to-find bugs.
84 #if __cplusplus >= 201103L
85 # define JSONCPP_OVERRIDE override
86 # define JSONCPP_NOEXCEPT noexcept
87 #elif defined(_MSC_VER) && _MSC_VER > 1600 && _MSC_VER < 1900
88 # define JSONCPP_OVERRIDE override
89 # define JSONCPP_NOEXCEPT throw()
90 #elif defined(_MSC_VER) && _MSC_VER >= 1900
91 # define JSONCPP_OVERRIDE override
92 # define JSONCPP_NOEXCEPT noexcept
93 #else
94 # define JSONCPP_OVERRIDE
95 # define JSONCPP_NOEXCEPT throw()
96 #endif
97 
98 #ifndef JSON_HAS_RVALUE_REFERENCES
99 
100 #if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
101 #define JSON_HAS_RVALUE_REFERENCES 1
102 #endif // MSVC >= 2010
103 
104 #ifdef __clang__
105 #if __has_feature(cxx_rvalue_references)
106 #define JSON_HAS_RVALUE_REFERENCES 1
107 #endif // has_feature
108 
109 #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
110 #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
111 #define JSON_HAS_RVALUE_REFERENCES 1
112 #endif // GXX_EXPERIMENTAL
113 
114 #endif // __clang__ || __GNUC__
115 
116 #endif // not defined JSON_HAS_RVALUE_REFERENCES
117 
118 #ifndef JSON_HAS_RVALUE_REFERENCES
119 #define JSON_HAS_RVALUE_REFERENCES 0
120 #endif
121 
122 #ifdef __clang__
123 # if __has_extension(attribute_deprecated_with_message)
124 # define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
125 # endif
126 #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
127 # if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
128 # define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
129 # elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
130 # define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
131 # endif // GNUC version
132 #endif // __clang__ || __GNUC__
133 
134 #if !defined(JSONCPP_DEPRECATED)
135 #define JSONCPP_DEPRECATED(message)
136 #endif // if !defined(JSONCPP_DEPRECATED)
137 
138 #if __GNUC__ >= 6
139 # define JSON_USE_INT64_DOUBLE_CONVERSION 1
140 #endif
141 
142 #if !defined(JSON_IS_AMALGAMATION)
143 
144 # include "version.h"
145 
146 # if JSONCPP_USING_SECURE_MEMORY
147 # include "allocator.h" //typedef Allocator
148 # endif
149 
150 #endif // if !defined(JSON_IS_AMALGAMATION)
151 
152 namespace Json {
153 typedef int Int;
154 typedef unsigned int UInt;
155 #if defined(JSON_NO_INT64)
156 typedef int LargestInt;
157 typedef unsigned int LargestUInt;
158 #undef JSON_HAS_INT64
159 #else // if defined(JSON_NO_INT64)
160 // For Microsoft Visual use specific types as long long is not supported
161 #if defined(_MSC_VER) // Microsoft Visual Studio
162 typedef __int64 Int64;
163 typedef unsigned __int64 UInt64;
164 #else // if defined(_MSC_VER) // Other platforms, use long long
165 typedef int64_t Int64;
166 typedef uint64_t UInt64;
167 #endif // if defined(_MSC_VER)
170 #define JSON_HAS_INT64
171 #endif // if defined(JSON_NO_INT64)
172 #if JSONCPP_USING_SECURE_MEMORY
173 #define JSONCPP_STRING std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> >
174 #define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
175 #define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char>>
176 #define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
177 #define JSONCPP_ISTREAM std::istream
178 #else
179 #define JSONCPP_STRING std::string
180 #define JSONCPP_OSTRINGSTREAM std::ostringstream
181 #define JSONCPP_OSTREAM std::ostream
182 #define JSONCPP_ISTRINGSTREAM std::istringstream
183 #define JSONCPP_ISTREAM std::istream
184 #endif // if JSONCPP_USING_SECURE_MEMORY
185 } // end namespace Json
186 
187 #endif // JSON_CONFIG_H_INCLUDED
Int64 LargestInt
Definition: config.h:168
unsigned __int64 UInt64
Definition: config.h:163
UInt64 LargestUInt
Definition: config.h:169
JSON (JavaScript Object Notation).
Definition: allocator.h:14
unsigned int UInt
Definition: config.h:154
__int64 Int64
Definition: config.h:162
int Int
Definition: config.h:153