git repos / blockattack-game

blame: source/code/Libs/include/cereal/external/rapidjson/rapidjson.h

normal view · raw

6c5f2c01 sago007 2017-03-15 17:56 1
// Tencent is pleased to support the open source community by making RapidJSON available.
6c5f2c01 sago007 2017-03-15 17:56 2
// 
6c5f2c01 sago007 2017-03-15 17:56 3
// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
6c5f2c01 sago007 2017-03-15 17:56 4
//
6c5f2c01 sago007 2017-03-15 17:56 5
// Licensed under the MIT License (the "License"); you may not use this file except
6c5f2c01 sago007 2017-03-15 17:56 6
// in compliance with the License. You may obtain a copy of the License at
6c5f2c01 sago007 2017-03-15 17:56 7
//
6c5f2c01 sago007 2017-03-15 17:56 8
// http://opensource.org/licenses/MIT
6c5f2c01 sago007 2017-03-15 17:56 9
//
6c5f2c01 sago007 2017-03-15 17:56 10
// Unless required by applicable law or agreed to in writing, software distributed 
6c5f2c01 sago007 2017-03-15 17:56 11
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
6c5f2c01 sago007 2017-03-15 17:56 12
// CONDITIONS OF ANY KIND, either express or implied. See the License for the 
6c5f2c01 sago007 2017-03-15 17:56 13
// specific language governing permissions and limitations under the License.
6c5f2c01 sago007 2017-03-15 17:56 14
6c5f2c01 sago007 2017-03-15 17:56 15
#ifndef CEREAL_RAPIDJSON_CEREAL_RAPIDJSON_H_
6c5f2c01 sago007 2017-03-15 17:56 16
#define CEREAL_RAPIDJSON_CEREAL_RAPIDJSON_H_
6c5f2c01 sago007 2017-03-15 17:56 17
6c5f2c01 sago007 2017-03-15 17:56 18
/*!\file rapidjson.h
6c5f2c01 sago007 2017-03-15 17:56 19
    \brief common definitions and configuration
6c5f2c01 sago007 2017-03-15 17:56 20
    
6c5f2c01 sago007 2017-03-15 17:56 21
    \see CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 22
 */
6c5f2c01 sago007 2017-03-15 17:56 23
6c5f2c01 sago007 2017-03-15 17:56 24
/*! \defgroup CEREAL_RAPIDJSON_CONFIG RapidJSON configuration
6c5f2c01 sago007 2017-03-15 17:56 25
    \brief Configuration macros for library features
6c5f2c01 sago007 2017-03-15 17:56 26
6c5f2c01 sago007 2017-03-15 17:56 27
    Some RapidJSON features are configurable to adapt the library to a wide
6c5f2c01 sago007 2017-03-15 17:56 28
    variety of platforms, environments and usage scenarios.  Most of the
6c5f2c01 sago007 2017-03-15 17:56 29
    features can be configured in terms of overriden or predefined
6c5f2c01 sago007 2017-03-15 17:56 30
    preprocessor macros at compile-time.
6c5f2c01 sago007 2017-03-15 17:56 31
6c5f2c01 sago007 2017-03-15 17:56 32
    Some additional customization is available in the \ref CEREAL_RAPIDJSON_ERRORS APIs.
6c5f2c01 sago007 2017-03-15 17:56 33
6c5f2c01 sago007 2017-03-15 17:56 34
    \note These macros should be given on the compiler command-line
6c5f2c01 sago007 2017-03-15 17:56 35
          (where applicable)  to avoid inconsistent values when compiling
6c5f2c01 sago007 2017-03-15 17:56 36
          different translation units of a single application.
6c5f2c01 sago007 2017-03-15 17:56 37
 */
6c5f2c01 sago007 2017-03-15 17:56 38
6c5f2c01 sago007 2017-03-15 17:56 39
#include <cstdlib>  // malloc(), realloc(), free(), size_t
6c5f2c01 sago007 2017-03-15 17:56 40
#include <cstring>  // memset(), memcpy(), memmove(), memcmp()
6c5f2c01 sago007 2017-03-15 17:56 41
6c5f2c01 sago007 2017-03-15 17:56 42
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 43
// CEREAL_RAPIDJSON_VERSION_STRING
6c5f2c01 sago007 2017-03-15 17:56 44
//
6c5f2c01 sago007 2017-03-15 17:56 45
// ALWAYS synchronize the following 3 macros with corresponding variables in /CMakeLists.txt.
6c5f2c01 sago007 2017-03-15 17:56 46
//
6c5f2c01 sago007 2017-03-15 17:56 47
6c5f2c01 sago007 2017-03-15 17:56 48
//!@cond CEREAL_RAPIDJSON_HIDDEN_FROM_DOXYGEN
6c5f2c01 sago007 2017-03-15 17:56 49
// token stringification
6c5f2c01 sago007 2017-03-15 17:56 50
#define CEREAL_RAPIDJSON_STRINGIFY(x) CEREAL_RAPIDJSON_DO_STRINGIFY(x)
6c5f2c01 sago007 2017-03-15 17:56 51
#define CEREAL_RAPIDJSON_DO_STRINGIFY(x) #x
6c5f2c01 sago007 2017-03-15 17:56 52
//!@endcond
6c5f2c01 sago007 2017-03-15 17:56 53
6c5f2c01 sago007 2017-03-15 17:56 54
/*! \def CEREAL_RAPIDJSON_MAJOR_VERSION
6c5f2c01 sago007 2017-03-15 17:56 55
    \ingroup CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 56
    \brief Major version of RapidJSON in integer.
6c5f2c01 sago007 2017-03-15 17:56 57
*/
6c5f2c01 sago007 2017-03-15 17:56 58
/*! \def CEREAL_RAPIDJSON_MINOR_VERSION
6c5f2c01 sago007 2017-03-15 17:56 59
    \ingroup CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 60
    \brief Minor version of RapidJSON in integer.
6c5f2c01 sago007 2017-03-15 17:56 61
*/
6c5f2c01 sago007 2017-03-15 17:56 62
/*! \def CEREAL_RAPIDJSON_PATCH_VERSION
6c5f2c01 sago007 2017-03-15 17:56 63
    \ingroup CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 64
    \brief Patch version of RapidJSON in integer.
6c5f2c01 sago007 2017-03-15 17:56 65
*/
6c5f2c01 sago007 2017-03-15 17:56 66
/*! \def CEREAL_RAPIDJSON_VERSION_STRING
6c5f2c01 sago007 2017-03-15 17:56 67
    \ingroup CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 68
    \brief Version of RapidJSON in "<major>.<minor>.<patch>" string format.
6c5f2c01 sago007 2017-03-15 17:56 69
*/
6c5f2c01 sago007 2017-03-15 17:56 70
#define CEREAL_RAPIDJSON_MAJOR_VERSION 1
6c5f2c01 sago007 2017-03-15 17:56 71
#define CEREAL_RAPIDJSON_MINOR_VERSION 0
6c5f2c01 sago007 2017-03-15 17:56 72
#define CEREAL_RAPIDJSON_PATCH_VERSION 2
6c5f2c01 sago007 2017-03-15 17:56 73
#define CEREAL_RAPIDJSON_VERSION_STRING \
6c5f2c01 sago007 2017-03-15 17:56 74
    CEREAL_RAPIDJSON_STRINGIFY(CEREAL_RAPIDJSON_MAJOR_VERSION.CEREAL_RAPIDJSON_MINOR_VERSION.CEREAL_RAPIDJSON_PATCH_VERSION)
6c5f2c01 sago007 2017-03-15 17:56 75
6c5f2c01 sago007 2017-03-15 17:56 76
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 77
// CEREAL_RAPIDJSON_NAMESPACE_(BEGIN|END)
6c5f2c01 sago007 2017-03-15 17:56 78
/*! \def CEREAL_RAPIDJSON_NAMESPACE
6c5f2c01 sago007 2017-03-15 17:56 79
    \ingroup CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 80
    \brief   provide custom rapidjson namespace
6c5f2c01 sago007 2017-03-15 17:56 81
6c5f2c01 sago007 2017-03-15 17:56 82
    In order to avoid symbol clashes and/or "One Definition Rule" errors
6c5f2c01 sago007 2017-03-15 17:56 83
    between multiple inclusions of (different versions of) RapidJSON in
6c5f2c01 sago007 2017-03-15 17:56 84
    a single binary, users can customize the name of the main RapidJSON
6c5f2c01 sago007 2017-03-15 17:56 85
    namespace.
6c5f2c01 sago007 2017-03-15 17:56 86
6c5f2c01 sago007 2017-03-15 17:56 87
    In case of a single nesting level, defining \c CEREAL_RAPIDJSON_NAMESPACE
6c5f2c01 sago007 2017-03-15 17:56 88
    to a custom name (e.g. \c MyRapidJSON) is sufficient.  If multiple
6c5f2c01 sago007 2017-03-15 17:56 89
    levels are needed, both \ref CEREAL_RAPIDJSON_NAMESPACE_BEGIN and \ref
6c5f2c01 sago007 2017-03-15 17:56 90
    CEREAL_RAPIDJSON_NAMESPACE_END need to be defined as well:
6c5f2c01 sago007 2017-03-15 17:56 91
6c5f2c01 sago007 2017-03-15 17:56 92
    \code
6c5f2c01 sago007 2017-03-15 17:56 93
    // in some .cpp file
6c5f2c01 sago007 2017-03-15 17:56 94
    #define CEREAL_RAPIDJSON_NAMESPACE my::rapidjson
6c5f2c01 sago007 2017-03-15 17:56 95
    #define CEREAL_RAPIDJSON_NAMESPACE_BEGIN namespace my { namespace rapidjson {
6c5f2c01 sago007 2017-03-15 17:56 96
    #define CEREAL_RAPIDJSON_NAMESPACE_END   } }
6c5f2c01 sago007 2017-03-15 17:56 97
    #include "rapidjson/..."
6c5f2c01 sago007 2017-03-15 17:56 98
    \endcode
6c5f2c01 sago007 2017-03-15 17:56 99
6c5f2c01 sago007 2017-03-15 17:56 100
    \see rapidjson
6c5f2c01 sago007 2017-03-15 17:56 101
 */
6c5f2c01 sago007 2017-03-15 17:56 102
/*! \def CEREAL_RAPIDJSON_NAMESPACE_BEGIN
6c5f2c01 sago007 2017-03-15 17:56 103
    \ingroup CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 104
    \brief   provide custom rapidjson namespace (opening expression)
6c5f2c01 sago007 2017-03-15 17:56 105
    \see CEREAL_RAPIDJSON_NAMESPACE
6c5f2c01 sago007 2017-03-15 17:56 106
*/
6c5f2c01 sago007 2017-03-15 17:56 107
/*! \def CEREAL_RAPIDJSON_NAMESPACE_END
6c5f2c01 sago007 2017-03-15 17:56 108
    \ingroup CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 109
    \brief   provide custom rapidjson namespace (closing expression)
6c5f2c01 sago007 2017-03-15 17:56 110
    \see CEREAL_RAPIDJSON_NAMESPACE
6c5f2c01 sago007 2017-03-15 17:56 111
*/
6c5f2c01 sago007 2017-03-15 17:56 112
#ifndef CEREAL_RAPIDJSON_NAMESPACE
6c5f2c01 sago007 2017-03-15 17:56 113
#define CEREAL_RAPIDJSON_NAMESPACE rapidjson
6c5f2c01 sago007 2017-03-15 17:56 114
#endif
6c5f2c01 sago007 2017-03-15 17:56 115
#ifndef CEREAL_RAPIDJSON_NAMESPACE_BEGIN
6c5f2c01 sago007 2017-03-15 17:56 116
#define CEREAL_RAPIDJSON_NAMESPACE_BEGIN namespace CEREAL_RAPIDJSON_NAMESPACE {
6c5f2c01 sago007 2017-03-15 17:56 117
#endif
6c5f2c01 sago007 2017-03-15 17:56 118
#ifndef CEREAL_RAPIDJSON_NAMESPACE_END
6c5f2c01 sago007 2017-03-15 17:56 119
#define CEREAL_RAPIDJSON_NAMESPACE_END }
6c5f2c01 sago007 2017-03-15 17:56 120
#endif
6c5f2c01 sago007 2017-03-15 17:56 121
6c5f2c01 sago007 2017-03-15 17:56 122
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 123
// CEREAL_RAPIDJSON_HAS_STDSTRING
6c5f2c01 sago007 2017-03-15 17:56 124
6c5f2c01 sago007 2017-03-15 17:56 125
#ifndef CEREAL_RAPIDJSON_HAS_STDSTRING
6c5f2c01 sago007 2017-03-15 17:56 126
#ifdef CEREAL_RAPIDJSON_DOXYGEN_RUNNING
6c5f2c01 sago007 2017-03-15 17:56 127
#define CEREAL_RAPIDJSON_HAS_STDSTRING 1 // force generation of documentation
6c5f2c01 sago007 2017-03-15 17:56 128
#else
6c5f2c01 sago007 2017-03-15 17:56 129
#define CEREAL_RAPIDJSON_HAS_STDSTRING 0 // no std::string support by default
6c5f2c01 sago007 2017-03-15 17:56 130
#endif
6c5f2c01 sago007 2017-03-15 17:56 131
/*! \def CEREAL_RAPIDJSON_HAS_STDSTRING
6c5f2c01 sago007 2017-03-15 17:56 132
    \ingroup CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 133
    \brief Enable RapidJSON support for \c std::string
6c5f2c01 sago007 2017-03-15 17:56 134
6c5f2c01 sago007 2017-03-15 17:56 135
    By defining this preprocessor symbol to \c 1, several convenience functions for using
6c5f2c01 sago007 2017-03-15 17:56 136
    \ref rapidjson::GenericValue with \c std::string are enabled, especially
6c5f2c01 sago007 2017-03-15 17:56 137
    for construction and comparison.
6c5f2c01 sago007 2017-03-15 17:56 138
6c5f2c01 sago007 2017-03-15 17:56 139
    \hideinitializer
6c5f2c01 sago007 2017-03-15 17:56 140
*/
6c5f2c01 sago007 2017-03-15 17:56 141
#endif // !defined(CEREAL_RAPIDJSON_HAS_STDSTRING)
6c5f2c01 sago007 2017-03-15 17:56 142
6c5f2c01 sago007 2017-03-15 17:56 143
#if CEREAL_RAPIDJSON_HAS_STDSTRING
6c5f2c01 sago007 2017-03-15 17:56 144
#include <string>
6c5f2c01 sago007 2017-03-15 17:56 145
#endif // CEREAL_RAPIDJSON_HAS_STDSTRING
6c5f2c01 sago007 2017-03-15 17:56 146
6c5f2c01 sago007 2017-03-15 17:56 147
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 148
// CEREAL_RAPIDJSON_NO_INT64DEFINE
6c5f2c01 sago007 2017-03-15 17:56 149
6c5f2c01 sago007 2017-03-15 17:56 150
/*! \def CEREAL_RAPIDJSON_NO_INT64DEFINE
6c5f2c01 sago007 2017-03-15 17:56 151
    \ingroup CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 152
    \brief Use external 64-bit integer types.
6c5f2c01 sago007 2017-03-15 17:56 153
6c5f2c01 sago007 2017-03-15 17:56 154
    RapidJSON requires the 64-bit integer types \c int64_t and  \c uint64_t types
6c5f2c01 sago007 2017-03-15 17:56 155
    to be available at global scope.
6c5f2c01 sago007 2017-03-15 17:56 156
6c5f2c01 sago007 2017-03-15 17:56 157
    If users have their own definition, define CEREAL_RAPIDJSON_NO_INT64DEFINE to
6c5f2c01 sago007 2017-03-15 17:56 158
    prevent RapidJSON from defining its own types.
6c5f2c01 sago007 2017-03-15 17:56 159
*/
6c5f2c01 sago007 2017-03-15 17:56 160
#ifndef CEREAL_RAPIDJSON_NO_INT64DEFINE
6c5f2c01 sago007 2017-03-15 17:56 161
//!@cond CEREAL_RAPIDJSON_HIDDEN_FROM_DOXYGEN
6c5f2c01 sago007 2017-03-15 17:56 162
#if defined(_MSC_VER) && (_MSC_VER < 1800)	// Visual Studio 2013
6c5f2c01 sago007 2017-03-15 17:56 163
#include "msinttypes/stdint.h"
6c5f2c01 sago007 2017-03-15 17:56 164
#include "msinttypes/inttypes.h"
6c5f2c01 sago007 2017-03-15 17:56 165
#else
6c5f2c01 sago007 2017-03-15 17:56 166
// Other compilers should have this.
6c5f2c01 sago007 2017-03-15 17:56 167
#include <stdint.h>
6c5f2c01 sago007 2017-03-15 17:56 168
#include <inttypes.h>
6c5f2c01 sago007 2017-03-15 17:56 169
#endif
6c5f2c01 sago007 2017-03-15 17:56 170
//!@endcond
6c5f2c01 sago007 2017-03-15 17:56 171
#ifdef CEREAL_RAPIDJSON_DOXYGEN_RUNNING
6c5f2c01 sago007 2017-03-15 17:56 172
#define CEREAL_RAPIDJSON_NO_INT64DEFINE
6c5f2c01 sago007 2017-03-15 17:56 173
#endif
6c5f2c01 sago007 2017-03-15 17:56 174
#endif // CEREAL_RAPIDJSON_NO_INT64TYPEDEF
6c5f2c01 sago007 2017-03-15 17:56 175
6c5f2c01 sago007 2017-03-15 17:56 176
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 177
// CEREAL_RAPIDJSON_FORCEINLINE
6c5f2c01 sago007 2017-03-15 17:56 178
6c5f2c01 sago007 2017-03-15 17:56 179
#ifndef CEREAL_RAPIDJSON_FORCEINLINE
6c5f2c01 sago007 2017-03-15 17:56 180
//!@cond CEREAL_RAPIDJSON_HIDDEN_FROM_DOXYGEN
6c5f2c01 sago007 2017-03-15 17:56 181
#if defined(_MSC_VER) && defined(NDEBUG)
6c5f2c01 sago007 2017-03-15 17:56 182
#define CEREAL_RAPIDJSON_FORCEINLINE __forceinline
6c5f2c01 sago007 2017-03-15 17:56 183
#elif defined(__GNUC__) && __GNUC__ >= 4 && defined(NDEBUG)
6c5f2c01 sago007 2017-03-15 17:56 184
#define CEREAL_RAPIDJSON_FORCEINLINE __attribute__((always_inline))
6c5f2c01 sago007 2017-03-15 17:56 185
#else
6c5f2c01 sago007 2017-03-15 17:56 186
#define CEREAL_RAPIDJSON_FORCEINLINE
6c5f2c01 sago007 2017-03-15 17:56 187
#endif
6c5f2c01 sago007 2017-03-15 17:56 188
//!@endcond
6c5f2c01 sago007 2017-03-15 17:56 189
#endif // CEREAL_RAPIDJSON_FORCEINLINE
6c5f2c01 sago007 2017-03-15 17:56 190
6c5f2c01 sago007 2017-03-15 17:56 191
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 192
// CEREAL_RAPIDJSON_ENDIAN
6c5f2c01 sago007 2017-03-15 17:56 193
#define CEREAL_RAPIDJSON_LITTLEENDIAN  0   //!< Little endian machine
6c5f2c01 sago007 2017-03-15 17:56 194
#define CEREAL_RAPIDJSON_BIGENDIAN     1   //!< Big endian machine
6c5f2c01 sago007 2017-03-15 17:56 195
6c5f2c01 sago007 2017-03-15 17:56 196
//! Endianness of the machine.
6c5f2c01 sago007 2017-03-15 17:56 197
/*!
6c5f2c01 sago007 2017-03-15 17:56 198
    \def CEREAL_RAPIDJSON_ENDIAN
6c5f2c01 sago007 2017-03-15 17:56 199
    \ingroup CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 200
6c5f2c01 sago007 2017-03-15 17:56 201
    GCC 4.6 provided macro for detecting endianness of the target machine. But other
6c5f2c01 sago007 2017-03-15 17:56 202
    compilers may not have this. User can define CEREAL_RAPIDJSON_ENDIAN to either
6c5f2c01 sago007 2017-03-15 17:56 203
    \ref CEREAL_RAPIDJSON_LITTLEENDIAN or \ref CEREAL_RAPIDJSON_BIGENDIAN.
6c5f2c01 sago007 2017-03-15 17:56 204
6c5f2c01 sago007 2017-03-15 17:56 205
    Default detection implemented with reference to
6c5f2c01 sago007 2017-03-15 17:56 206
    \li https://gcc.gnu.org/onlinedocs/gcc-4.6.0/cpp/Common-Predefined-Macros.html
6c5f2c01 sago007 2017-03-15 17:56 207
    \li http://www.boost.org/doc/libs/1_42_0/boost/detail/endian.hpp
6c5f2c01 sago007 2017-03-15 17:56 208
*/
6c5f2c01 sago007 2017-03-15 17:56 209
#ifndef CEREAL_RAPIDJSON_ENDIAN
6c5f2c01 sago007 2017-03-15 17:56 210
// Detect with GCC 4.6's macro
6c5f2c01 sago007 2017-03-15 17:56 211
#  ifdef __BYTE_ORDER__
6c5f2c01 sago007 2017-03-15 17:56 212
#    if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
6c5f2c01 sago007 2017-03-15 17:56 213
#      define CEREAL_RAPIDJSON_ENDIAN CEREAL_RAPIDJSON_LITTLEENDIAN
6c5f2c01 sago007 2017-03-15 17:56 214
#    elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
6c5f2c01 sago007 2017-03-15 17:56 215
#      define CEREAL_RAPIDJSON_ENDIAN CEREAL_RAPIDJSON_BIGENDIAN
6c5f2c01 sago007 2017-03-15 17:56 216
#    else
6c5f2c01 sago007 2017-03-15 17:56 217
#      error Unknown machine endianess detected. User needs to define CEREAL_RAPIDJSON_ENDIAN.
6c5f2c01 sago007 2017-03-15 17:56 218
#    endif // __BYTE_ORDER__
6c5f2c01 sago007 2017-03-15 17:56 219
// Detect with GLIBC's endian.h
6c5f2c01 sago007 2017-03-15 17:56 220
#  elif defined(__GLIBC__)
6c5f2c01 sago007 2017-03-15 17:56 221
#    include <endian.h>
6c5f2c01 sago007 2017-03-15 17:56 222
#    if (__BYTE_ORDER == __LITTLE_ENDIAN)
6c5f2c01 sago007 2017-03-15 17:56 223
#      define CEREAL_RAPIDJSON_ENDIAN CEREAL_RAPIDJSON_LITTLEENDIAN
6c5f2c01 sago007 2017-03-15 17:56 224
#    elif (__BYTE_ORDER == __BIG_ENDIAN)
6c5f2c01 sago007 2017-03-15 17:56 225
#      define CEREAL_RAPIDJSON_ENDIAN CEREAL_RAPIDJSON_BIGENDIAN
6c5f2c01 sago007 2017-03-15 17:56 226
#    else
6c5f2c01 sago007 2017-03-15 17:56 227
#      error Unknown machine endianess detected. User needs to define CEREAL_RAPIDJSON_ENDIAN.
6c5f2c01 sago007 2017-03-15 17:56 228
#   endif // __GLIBC__
6c5f2c01 sago007 2017-03-15 17:56 229
// Detect with _LITTLE_ENDIAN and _BIG_ENDIAN macro
6c5f2c01 sago007 2017-03-15 17:56 230
#  elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
6c5f2c01 sago007 2017-03-15 17:56 231
#    define CEREAL_RAPIDJSON_ENDIAN CEREAL_RAPIDJSON_LITTLEENDIAN
6c5f2c01 sago007 2017-03-15 17:56 232
#  elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
6c5f2c01 sago007 2017-03-15 17:56 233
#    define CEREAL_RAPIDJSON_ENDIAN CEREAL_RAPIDJSON_BIGENDIAN
6c5f2c01 sago007 2017-03-15 17:56 234
// Detect with architecture macros
6c5f2c01 sago007 2017-03-15 17:56 235
#  elif defined(__sparc) || defined(__sparc__) || defined(_POWER) || defined(__powerpc__) || defined(__ppc__) || defined(__hpux) || defined(__hppa) || defined(_MIPSEB) || defined(_POWER) || defined(__s390__)
6c5f2c01 sago007 2017-03-15 17:56 236
#    define CEREAL_RAPIDJSON_ENDIAN CEREAL_RAPIDJSON_BIGENDIAN
6c5f2c01 sago007 2017-03-15 17:56 237
#  elif defined(__i386__) || defined(__alpha__) || defined(__ia64) || defined(__ia64__) || defined(_M_IX86) || defined(_M_IA64) || defined(_M_ALPHA) || defined(__amd64) || defined(__amd64__) || defined(_M_AMD64) || defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || defined(__bfin__)
6c5f2c01 sago007 2017-03-15 17:56 238
#    define CEREAL_RAPIDJSON_ENDIAN CEREAL_RAPIDJSON_LITTLEENDIAN
6c5f2c01 sago007 2017-03-15 17:56 239
#  elif defined(_MSC_VER) && defined(_M_ARM)
6c5f2c01 sago007 2017-03-15 17:56 240
#    define CEREAL_RAPIDJSON_ENDIAN CEREAL_RAPIDJSON_LITTLEENDIAN
6c5f2c01 sago007 2017-03-15 17:56 241
#  elif defined(CEREAL_RAPIDJSON_DOXYGEN_RUNNING)
6c5f2c01 sago007 2017-03-15 17:56 242
#    define CEREAL_RAPIDJSON_ENDIAN
6c5f2c01 sago007 2017-03-15 17:56 243
#  else
6c5f2c01 sago007 2017-03-15 17:56 244
#    error Unknown machine endianess detected. User needs to define CEREAL_RAPIDJSON_ENDIAN.   
6c5f2c01 sago007 2017-03-15 17:56 245
#  endif
6c5f2c01 sago007 2017-03-15 17:56 246
#endif // CEREAL_RAPIDJSON_ENDIAN
6c5f2c01 sago007 2017-03-15 17:56 247
6c5f2c01 sago007 2017-03-15 17:56 248
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 249
// CEREAL_RAPIDJSON_64BIT
6c5f2c01 sago007 2017-03-15 17:56 250
6c5f2c01 sago007 2017-03-15 17:56 251
//! Whether using 64-bit architecture
6c5f2c01 sago007 2017-03-15 17:56 252
#ifndef CEREAL_RAPIDJSON_64BIT
6c5f2c01 sago007 2017-03-15 17:56 253
#if defined(__LP64__) || (defined(__x86_64__) && defined(__ILP32__)) || defined(_WIN64) || defined(__EMSCRIPTEN__)
6c5f2c01 sago007 2017-03-15 17:56 254
#define CEREAL_RAPIDJSON_64BIT 1
6c5f2c01 sago007 2017-03-15 17:56 255
#else
6c5f2c01 sago007 2017-03-15 17:56 256
#define CEREAL_RAPIDJSON_64BIT 0
6c5f2c01 sago007 2017-03-15 17:56 257
#endif
6c5f2c01 sago007 2017-03-15 17:56 258
#endif // CEREAL_RAPIDJSON_64BIT
6c5f2c01 sago007 2017-03-15 17:56 259
6c5f2c01 sago007 2017-03-15 17:56 260
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 261
// CEREAL_RAPIDJSON_ALIGN
6c5f2c01 sago007 2017-03-15 17:56 262
6c5f2c01 sago007 2017-03-15 17:56 263
//! Data alignment of the machine.
6c5f2c01 sago007 2017-03-15 17:56 264
/*! \ingroup CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 265
    \param x pointer to align
6c5f2c01 sago007 2017-03-15 17:56 266
6c5f2c01 sago007 2017-03-15 17:56 267
    Some machines require strict data alignment. Currently the default uses 4 bytes
6c5f2c01 sago007 2017-03-15 17:56 268
    alignment on 32-bit platforms and 8 bytes alignment for 64-bit platforms.
6c5f2c01 sago007 2017-03-15 17:56 269
    User can customize by defining the CEREAL_RAPIDJSON_ALIGN function macro.
6c5f2c01 sago007 2017-03-15 17:56 270
*/
6c5f2c01 sago007 2017-03-15 17:56 271
#ifndef CEREAL_RAPIDJSON_ALIGN
6c5f2c01 sago007 2017-03-15 17:56 272
#if CEREAL_RAPIDJSON_64BIT == 1
6c5f2c01 sago007 2017-03-15 17:56 273
#define CEREAL_RAPIDJSON_ALIGN(x) (((x) + static_cast<uint64_t>(7u)) & ~static_cast<uint64_t>(7u))
6c5f2c01 sago007 2017-03-15 17:56 274
#else
6c5f2c01 sago007 2017-03-15 17:56 275
#define CEREAL_RAPIDJSON_ALIGN(x) (((x) + 3u) & ~3u)
6c5f2c01 sago007 2017-03-15 17:56 276
#endif
6c5f2c01 sago007 2017-03-15 17:56 277
#endif
6c5f2c01 sago007 2017-03-15 17:56 278
6c5f2c01 sago007 2017-03-15 17:56 279
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 280
// CEREAL_RAPIDJSON_UINT64_C2
6c5f2c01 sago007 2017-03-15 17:56 281
6c5f2c01 sago007 2017-03-15 17:56 282
//! Construct a 64-bit literal by a pair of 32-bit integer.
6c5f2c01 sago007 2017-03-15 17:56 283
/*!
6c5f2c01 sago007 2017-03-15 17:56 284
    64-bit literal with or without ULL suffix is prone to compiler warnings.
6c5f2c01 sago007 2017-03-15 17:56 285
    UINT64_C() is C macro which cause compilation problems.
6c5f2c01 sago007 2017-03-15 17:56 286
    Use this macro to define 64-bit constants by a pair of 32-bit integer.
6c5f2c01 sago007 2017-03-15 17:56 287
*/
6c5f2c01 sago007 2017-03-15 17:56 288
#ifndef CEREAL_RAPIDJSON_UINT64_C2
6c5f2c01 sago007 2017-03-15 17:56 289
#define CEREAL_RAPIDJSON_UINT64_C2(high32, low32) ((static_cast<uint64_t>(high32) << 32) | static_cast<uint64_t>(low32))
6c5f2c01 sago007 2017-03-15 17:56 290
#endif
6c5f2c01 sago007 2017-03-15 17:56 291
6c5f2c01 sago007 2017-03-15 17:56 292
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 293
// CEREAL_RAPIDJSON_48BITPOINTER_OPTIMIZATION
6c5f2c01 sago007 2017-03-15 17:56 294
6c5f2c01 sago007 2017-03-15 17:56 295
//! Use only lower 48-bit address for some pointers.
6c5f2c01 sago007 2017-03-15 17:56 296
/*!
6c5f2c01 sago007 2017-03-15 17:56 297
    \ingroup CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 298
6c5f2c01 sago007 2017-03-15 17:56 299
    This optimization uses the fact that current X86-64 architecture only implement lower 48-bit virtual address.
6c5f2c01 sago007 2017-03-15 17:56 300
    The higher 16-bit can be used for storing other data.
6c5f2c01 sago007 2017-03-15 17:56 301
    \c GenericValue uses this optimization to reduce its size form 24 bytes to 16 bytes in 64-bit architecture.
6c5f2c01 sago007 2017-03-15 17:56 302
*/
6c5f2c01 sago007 2017-03-15 17:56 303
#ifndef CEREAL_RAPIDJSON_48BITPOINTER_OPTIMIZATION
6c5f2c01 sago007 2017-03-15 17:56 304
#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
6c5f2c01 sago007 2017-03-15 17:56 305
#define CEREAL_RAPIDJSON_48BITPOINTER_OPTIMIZATION 1
6c5f2c01 sago007 2017-03-15 17:56 306
#else
6c5f2c01 sago007 2017-03-15 17:56 307
#define CEREAL_RAPIDJSON_48BITPOINTER_OPTIMIZATION 0
6c5f2c01 sago007 2017-03-15 17:56 308
#endif
6c5f2c01 sago007 2017-03-15 17:56 309
#endif // CEREAL_RAPIDJSON_48BITPOINTER_OPTIMIZATION
6c5f2c01 sago007 2017-03-15 17:56 310
6c5f2c01 sago007 2017-03-15 17:56 311
#if CEREAL_RAPIDJSON_48BITPOINTER_OPTIMIZATION == 1
6c5f2c01 sago007 2017-03-15 17:56 312
#if CEREAL_RAPIDJSON_64BIT != 1
6c5f2c01 sago007 2017-03-15 17:56 313
#error CEREAL_RAPIDJSON_48BITPOINTER_OPTIMIZATION can only be set to 1 when CEREAL_RAPIDJSON_64BIT=1
6c5f2c01 sago007 2017-03-15 17:56 314
#endif
6c5f2c01 sago007 2017-03-15 17:56 315
#define CEREAL_RAPIDJSON_SETPOINTER(type, p, x) (p = reinterpret_cast<type *>((reinterpret_cast<uintptr_t>(p) & static_cast<uintptr_t>(CEREAL_RAPIDJSON_UINT64_C2(0xFFFF0000, 0x00000000))) | reinterpret_cast<uintptr_t>(reinterpret_cast<const void*>(x))))
6c5f2c01 sago007 2017-03-15 17:56 316
#define CEREAL_RAPIDJSON_GETPOINTER(type, p) (reinterpret_cast<type *>(reinterpret_cast<uintptr_t>(p) & static_cast<uintptr_t>(CEREAL_RAPIDJSON_UINT64_C2(0x0000FFFF, 0xFFFFFFFF))))
6c5f2c01 sago007 2017-03-15 17:56 317
#else
6c5f2c01 sago007 2017-03-15 17:56 318
#define CEREAL_RAPIDJSON_SETPOINTER(type, p, x) (p = (x))
6c5f2c01 sago007 2017-03-15 17:56 319
#define CEREAL_RAPIDJSON_GETPOINTER(type, p) (p)
6c5f2c01 sago007 2017-03-15 17:56 320
#endif
6c5f2c01 sago007 2017-03-15 17:56 321
6c5f2c01 sago007 2017-03-15 17:56 322
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 323
// CEREAL_RAPIDJSON_SSE2/CEREAL_RAPIDJSON_SSE42/CEREAL_RAPIDJSON_SIMD
6c5f2c01 sago007 2017-03-15 17:56 324
6c5f2c01 sago007 2017-03-15 17:56 325
/*! \def CEREAL_RAPIDJSON_SIMD
6c5f2c01 sago007 2017-03-15 17:56 326
    \ingroup CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 327
    \brief Enable SSE2/SSE4.2 optimization.
6c5f2c01 sago007 2017-03-15 17:56 328
6c5f2c01 sago007 2017-03-15 17:56 329
    RapidJSON supports optimized implementations for some parsing operations
6c5f2c01 sago007 2017-03-15 17:56 330
    based on the SSE2 or SSE4.2 SIMD extensions on modern Intel-compatible
6c5f2c01 sago007 2017-03-15 17:56 331
    processors.
6c5f2c01 sago007 2017-03-15 17:56 332
6c5f2c01 sago007 2017-03-15 17:56 333
    To enable these optimizations, two different symbols can be defined;
6c5f2c01 sago007 2017-03-15 17:56 334
    \code
6c5f2c01 sago007 2017-03-15 17:56 335
    // Enable SSE2 optimization.
6c5f2c01 sago007 2017-03-15 17:56 336
    #define CEREAL_RAPIDJSON_SSE2
6c5f2c01 sago007 2017-03-15 17:56 337
6c5f2c01 sago007 2017-03-15 17:56 338
    // Enable SSE4.2 optimization.
6c5f2c01 sago007 2017-03-15 17:56 339
    #define CEREAL_RAPIDJSON_SSE42
6c5f2c01 sago007 2017-03-15 17:56 340
    \endcode
6c5f2c01 sago007 2017-03-15 17:56 341
6c5f2c01 sago007 2017-03-15 17:56 342
    \c CEREAL_RAPIDJSON_SSE42 takes precedence, if both are defined.
6c5f2c01 sago007 2017-03-15 17:56 343
6c5f2c01 sago007 2017-03-15 17:56 344
    If any of these symbols is defined, RapidJSON defines the macro
6c5f2c01 sago007 2017-03-15 17:56 345
    \c CEREAL_RAPIDJSON_SIMD to indicate the availability of the optimized code.
6c5f2c01 sago007 2017-03-15 17:56 346
*/
6c5f2c01 sago007 2017-03-15 17:56 347
#if defined(CEREAL_RAPIDJSON_SSE2) || defined(CEREAL_RAPIDJSON_SSE42) \
6c5f2c01 sago007 2017-03-15 17:56 348
    || defined(CEREAL_RAPIDJSON_DOXYGEN_RUNNING)
6c5f2c01 sago007 2017-03-15 17:56 349
#define CEREAL_RAPIDJSON_SIMD
6c5f2c01 sago007 2017-03-15 17:56 350
#endif
6c5f2c01 sago007 2017-03-15 17:56 351
6c5f2c01 sago007 2017-03-15 17:56 352
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 353
// CEREAL_RAPIDJSON_NO_SIZETYPEDEFINE
6c5f2c01 sago007 2017-03-15 17:56 354
6c5f2c01 sago007 2017-03-15 17:56 355
#ifndef CEREAL_RAPIDJSON_NO_SIZETYPEDEFINE
6c5f2c01 sago007 2017-03-15 17:56 356
/*! \def CEREAL_RAPIDJSON_NO_SIZETYPEDEFINE
6c5f2c01 sago007 2017-03-15 17:56 357
    \ingroup CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 358
    \brief User-provided \c SizeType definition.
6c5f2c01 sago007 2017-03-15 17:56 359
6c5f2c01 sago007 2017-03-15 17:56 360
    In order to avoid using 32-bit size types for indexing strings and arrays,
6c5f2c01 sago007 2017-03-15 17:56 361
    define this preprocessor symbol and provide the type rapidjson::SizeType
6c5f2c01 sago007 2017-03-15 17:56 362
    before including RapidJSON:
6c5f2c01 sago007 2017-03-15 17:56 363
    \code
6c5f2c01 sago007 2017-03-15 17:56 364
    #define CEREAL_RAPIDJSON_NO_SIZETYPEDEFINE
6c5f2c01 sago007 2017-03-15 17:56 365
    namespace rapidjson { typedef ::std::size_t SizeType; }
6c5f2c01 sago007 2017-03-15 17:56 366
    #include "rapidjson/..."
6c5f2c01 sago007 2017-03-15 17:56 367
    \endcode
6c5f2c01 sago007 2017-03-15 17:56 368
6c5f2c01 sago007 2017-03-15 17:56 369
    \see rapidjson::SizeType
6c5f2c01 sago007 2017-03-15 17:56 370
*/
6c5f2c01 sago007 2017-03-15 17:56 371
#ifdef CEREAL_RAPIDJSON_DOXYGEN_RUNNING
6c5f2c01 sago007 2017-03-15 17:56 372
#define CEREAL_RAPIDJSON_NO_SIZETYPEDEFINE
6c5f2c01 sago007 2017-03-15 17:56 373
#endif
6c5f2c01 sago007 2017-03-15 17:56 374
CEREAL_RAPIDJSON_NAMESPACE_BEGIN
6c5f2c01 sago007 2017-03-15 17:56 375
//! Size type (for string lengths, array sizes, etc.)
6c5f2c01 sago007 2017-03-15 17:56 376
/*! RapidJSON uses 32-bit array/string indices even on 64-bit platforms,
6c5f2c01 sago007 2017-03-15 17:56 377
    instead of using \c size_t. Users may override the SizeType by defining
6c5f2c01 sago007 2017-03-15 17:56 378
    \ref CEREAL_RAPIDJSON_NO_SIZETYPEDEFINE.
6c5f2c01 sago007 2017-03-15 17:56 379
*/
6c5f2c01 sago007 2017-03-15 17:56 380
typedef unsigned SizeType;
6c5f2c01 sago007 2017-03-15 17:56 381
CEREAL_RAPIDJSON_NAMESPACE_END
6c5f2c01 sago007 2017-03-15 17:56 382
#endif
6c5f2c01 sago007 2017-03-15 17:56 383
6c5f2c01 sago007 2017-03-15 17:56 384
// always import std::size_t to rapidjson namespace
6c5f2c01 sago007 2017-03-15 17:56 385
CEREAL_RAPIDJSON_NAMESPACE_BEGIN
6c5f2c01 sago007 2017-03-15 17:56 386
using std::size_t;
6c5f2c01 sago007 2017-03-15 17:56 387
CEREAL_RAPIDJSON_NAMESPACE_END
6c5f2c01 sago007 2017-03-15 17:56 388
6c5f2c01 sago007 2017-03-15 17:56 389
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 390
// CEREAL_RAPIDJSON_ASSERT
6c5f2c01 sago007 2017-03-15 17:56 391
6c5f2c01 sago007 2017-03-15 17:56 392
//! Assertion.
6c5f2c01 sago007 2017-03-15 17:56 393
/*! \ingroup CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 394
    By default, rapidjson uses C \c assert() for internal assertions.
6c5f2c01 sago007 2017-03-15 17:56 395
    User can override it by defining CEREAL_RAPIDJSON_ASSERT(x) macro.
6c5f2c01 sago007 2017-03-15 17:56 396
6c5f2c01 sago007 2017-03-15 17:56 397
    \note Parsing errors are handled and can be customized by the
6c5f2c01 sago007 2017-03-15 17:56 398
          \ref CEREAL_RAPIDJSON_ERRORS APIs.
6c5f2c01 sago007 2017-03-15 17:56 399
*/
6c5f2c01 sago007 2017-03-15 17:56 400
#ifndef CEREAL_RAPIDJSON_ASSERT
6c5f2c01 sago007 2017-03-15 17:56 401
#include <cassert>
6c5f2c01 sago007 2017-03-15 17:56 402
#define CEREAL_RAPIDJSON_ASSERT(x) assert(x)
6c5f2c01 sago007 2017-03-15 17:56 403
#endif // CEREAL_RAPIDJSON_ASSERT
6c5f2c01 sago007 2017-03-15 17:56 404
6c5f2c01 sago007 2017-03-15 17:56 405
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 406
// CEREAL_RAPIDJSON_STATIC_ASSERT
6c5f2c01 sago007 2017-03-15 17:56 407
6c5f2c01 sago007 2017-03-15 17:56 408
// Adopt from boost
6c5f2c01 sago007 2017-03-15 17:56 409
#ifndef CEREAL_RAPIDJSON_STATIC_ASSERT
6c5f2c01 sago007 2017-03-15 17:56 410
#ifndef __clang__
6c5f2c01 sago007 2017-03-15 17:56 411
//!@cond CEREAL_RAPIDJSON_HIDDEN_FROM_DOXYGEN
6c5f2c01 sago007 2017-03-15 17:56 412
#endif
6c5f2c01 sago007 2017-03-15 17:56 413
CEREAL_RAPIDJSON_NAMESPACE_BEGIN
6c5f2c01 sago007 2017-03-15 17:56 414
template <bool x> struct STATIC_ASSERTION_FAILURE;
6c5f2c01 sago007 2017-03-15 17:56 415
template <> struct STATIC_ASSERTION_FAILURE<true> { enum { value = 1 }; };
6c5f2c01 sago007 2017-03-15 17:56 416
template<int x> struct StaticAssertTest {};
6c5f2c01 sago007 2017-03-15 17:56 417
CEREAL_RAPIDJSON_NAMESPACE_END
6c5f2c01 sago007 2017-03-15 17:56 418
6c5f2c01 sago007 2017-03-15 17:56 419
#define CEREAL_RAPIDJSON_JOIN(X, Y) CEREAL_RAPIDJSON_DO_JOIN(X, Y)
6c5f2c01 sago007 2017-03-15 17:56 420
#define CEREAL_RAPIDJSON_DO_JOIN(X, Y) CEREAL_RAPIDJSON_DO_JOIN2(X, Y)
6c5f2c01 sago007 2017-03-15 17:56 421
#define CEREAL_RAPIDJSON_DO_JOIN2(X, Y) X##Y
6c5f2c01 sago007 2017-03-15 17:56 422
6c5f2c01 sago007 2017-03-15 17:56 423
#if defined(__GNUC__)
6c5f2c01 sago007 2017-03-15 17:56 424
#define CEREAL_RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE __attribute__((unused))
6c5f2c01 sago007 2017-03-15 17:56 425
#else
6c5f2c01 sago007 2017-03-15 17:56 426
#define CEREAL_RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE 
6c5f2c01 sago007 2017-03-15 17:56 427
#endif
6c5f2c01 sago007 2017-03-15 17:56 428
#ifndef __clang__
6c5f2c01 sago007 2017-03-15 17:56 429
//!@endcond
6c5f2c01 sago007 2017-03-15 17:56 430
#endif
6c5f2c01 sago007 2017-03-15 17:56 431
6c5f2c01 sago007 2017-03-15 17:56 432
/*! \def CEREAL_RAPIDJSON_STATIC_ASSERT
6c5f2c01 sago007 2017-03-15 17:56 433
    \brief (Internal) macro to check for conditions at compile-time
6c5f2c01 sago007 2017-03-15 17:56 434
    \param x compile-time condition
6c5f2c01 sago007 2017-03-15 17:56 435
    \hideinitializer
6c5f2c01 sago007 2017-03-15 17:56 436
 */
6c5f2c01 sago007 2017-03-15 17:56 437
#define CEREAL_RAPIDJSON_STATIC_ASSERT(x) \
6c5f2c01 sago007 2017-03-15 17:56 438
    typedef ::CEREAL_RAPIDJSON_NAMESPACE::StaticAssertTest< \
6c5f2c01 sago007 2017-03-15 17:56 439
      sizeof(::CEREAL_RAPIDJSON_NAMESPACE::STATIC_ASSERTION_FAILURE<bool(x) >)> \
6c5f2c01 sago007 2017-03-15 17:56 440
    CEREAL_RAPIDJSON_JOIN(StaticAssertTypedef, __LINE__) CEREAL_RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE
6c5f2c01 sago007 2017-03-15 17:56 441
#endif
6c5f2c01 sago007 2017-03-15 17:56 442
6c5f2c01 sago007 2017-03-15 17:56 443
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 444
// CEREAL_RAPIDJSON_LIKELY, CEREAL_RAPIDJSON_UNLIKELY
6c5f2c01 sago007 2017-03-15 17:56 445
6c5f2c01 sago007 2017-03-15 17:56 446
//! Compiler branching hint for expression with high probability to be true.
6c5f2c01 sago007 2017-03-15 17:56 447
/*!
6c5f2c01 sago007 2017-03-15 17:56 448
    \ingroup CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 449
    \param x Boolean expression likely to be true.
6c5f2c01 sago007 2017-03-15 17:56 450
*/
6c5f2c01 sago007 2017-03-15 17:56 451
#ifndef CEREAL_RAPIDJSON_LIKELY
6c5f2c01 sago007 2017-03-15 17:56 452
#if defined(__GNUC__) || defined(__clang__)
6c5f2c01 sago007 2017-03-15 17:56 453
#define CEREAL_RAPIDJSON_LIKELY(x) __builtin_expect(!!(x), 1)
6c5f2c01 sago007 2017-03-15 17:56 454
#else
6c5f2c01 sago007 2017-03-15 17:56 455
#define CEREAL_RAPIDJSON_LIKELY(x) (x)
6c5f2c01 sago007 2017-03-15 17:56 456
#endif
6c5f2c01 sago007 2017-03-15 17:56 457
#endif
6c5f2c01 sago007 2017-03-15 17:56 458
6c5f2c01 sago007 2017-03-15 17:56 459
//! Compiler branching hint for expression with low probability to be true.
6c5f2c01 sago007 2017-03-15 17:56 460
/*!
6c5f2c01 sago007 2017-03-15 17:56 461
    \ingroup CEREAL_RAPIDJSON_CONFIG
6c5f2c01 sago007 2017-03-15 17:56 462
    \param x Boolean expression unlikely to be true.
6c5f2c01 sago007 2017-03-15 17:56 463
*/
6c5f2c01 sago007 2017-03-15 17:56 464
#ifndef CEREAL_RAPIDJSON_UNLIKELY
6c5f2c01 sago007 2017-03-15 17:56 465
#if defined(__GNUC__) || defined(__clang__)
6c5f2c01 sago007 2017-03-15 17:56 466
#define CEREAL_RAPIDJSON_UNLIKELY(x) __builtin_expect(!!(x), 0)
6c5f2c01 sago007 2017-03-15 17:56 467
#else
6c5f2c01 sago007 2017-03-15 17:56 468
#define CEREAL_RAPIDJSON_UNLIKELY(x) (x)
6c5f2c01 sago007 2017-03-15 17:56 469
#endif
6c5f2c01 sago007 2017-03-15 17:56 470
#endif
6c5f2c01 sago007 2017-03-15 17:56 471
6c5f2c01 sago007 2017-03-15 17:56 472
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 473
// Helpers
6c5f2c01 sago007 2017-03-15 17:56 474
6c5f2c01 sago007 2017-03-15 17:56 475
//!@cond CEREAL_RAPIDJSON_HIDDEN_FROM_DOXYGEN
6c5f2c01 sago007 2017-03-15 17:56 476
6c5f2c01 sago007 2017-03-15 17:56 477
#define CEREAL_RAPIDJSON_MULTILINEMACRO_BEGIN do {  
6c5f2c01 sago007 2017-03-15 17:56 478
#define CEREAL_RAPIDJSON_MULTILINEMACRO_END \
6c5f2c01 sago007 2017-03-15 17:56 479
} while((void)0, 0)
6c5f2c01 sago007 2017-03-15 17:56 480
6c5f2c01 sago007 2017-03-15 17:56 481
// adopted from Boost
6c5f2c01 sago007 2017-03-15 17:56 482
#define CEREAL_RAPIDJSON_VERSION_CODE(x,y,z) \
6c5f2c01 sago007 2017-03-15 17:56 483
  (((x)*100000) + ((y)*100) + (z))
6c5f2c01 sago007 2017-03-15 17:56 484
6c5f2c01 sago007 2017-03-15 17:56 485
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 486
// CEREAL_RAPIDJSON_DIAG_PUSH/POP, CEREAL_RAPIDJSON_DIAG_OFF
6c5f2c01 sago007 2017-03-15 17:56 487
6c5f2c01 sago007 2017-03-15 17:56 488
#if defined(__GNUC__)
6c5f2c01 sago007 2017-03-15 17:56 489
#define CEREAL_RAPIDJSON_GNUC \
6c5f2c01 sago007 2017-03-15 17:56 490
    CEREAL_RAPIDJSON_VERSION_CODE(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__)
6c5f2c01 sago007 2017-03-15 17:56 491
#endif
6c5f2c01 sago007 2017-03-15 17:56 492
6c5f2c01 sago007 2017-03-15 17:56 493
#if defined(__clang__) || (defined(CEREAL_RAPIDJSON_GNUC) && CEREAL_RAPIDJSON_GNUC >= CEREAL_RAPIDJSON_VERSION_CODE(4,2,0))
6c5f2c01 sago007 2017-03-15 17:56 494
6c5f2c01 sago007 2017-03-15 17:56 495
#define CEREAL_RAPIDJSON_PRAGMA(x) _Pragma(CEREAL_RAPIDJSON_STRINGIFY(x))
6c5f2c01 sago007 2017-03-15 17:56 496
#define CEREAL_RAPIDJSON_DIAG_PRAGMA(x) CEREAL_RAPIDJSON_PRAGMA(GCC diagnostic x)
6c5f2c01 sago007 2017-03-15 17:56 497
#define CEREAL_RAPIDJSON_DIAG_OFF(x) \
6c5f2c01 sago007 2017-03-15 17:56 498
    CEREAL_RAPIDJSON_DIAG_PRAGMA(ignored CEREAL_RAPIDJSON_STRINGIFY(CEREAL_RAPIDJSON_JOIN(-W,x)))
6c5f2c01 sago007 2017-03-15 17:56 499
6c5f2c01 sago007 2017-03-15 17:56 500
// push/pop support in Clang and GCC>=4.6
6c5f2c01 sago007 2017-03-15 17:56 501
#if defined(__clang__) || (defined(CEREAL_RAPIDJSON_GNUC) && CEREAL_RAPIDJSON_GNUC >= CEREAL_RAPIDJSON_VERSION_CODE(4,6,0))
6c5f2c01 sago007 2017-03-15 17:56 502
#define CEREAL_RAPIDJSON_DIAG_PUSH CEREAL_RAPIDJSON_DIAG_PRAGMA(push)
6c5f2c01 sago007 2017-03-15 17:56 503
#define CEREAL_RAPIDJSON_DIAG_POP  CEREAL_RAPIDJSON_DIAG_PRAGMA(pop)
6c5f2c01 sago007 2017-03-15 17:56 504
#else // GCC >= 4.2, < 4.6
6c5f2c01 sago007 2017-03-15 17:56 505
#define CEREAL_RAPIDJSON_DIAG_PUSH /* ignored */
6c5f2c01 sago007 2017-03-15 17:56 506
#define CEREAL_RAPIDJSON_DIAG_POP /* ignored */
6c5f2c01 sago007 2017-03-15 17:56 507
#endif
6c5f2c01 sago007 2017-03-15 17:56 508
6c5f2c01 sago007 2017-03-15 17:56 509
#elif defined(_MSC_VER)
6c5f2c01 sago007 2017-03-15 17:56 510
6c5f2c01 sago007 2017-03-15 17:56 511
// pragma (MSVC specific)
6c5f2c01 sago007 2017-03-15 17:56 512
#define CEREAL_RAPIDJSON_PRAGMA(x) __pragma(x)
6c5f2c01 sago007 2017-03-15 17:56 513
#define CEREAL_RAPIDJSON_DIAG_PRAGMA(x) CEREAL_RAPIDJSON_PRAGMA(warning(x))
6c5f2c01 sago007 2017-03-15 17:56 514
6c5f2c01 sago007 2017-03-15 17:56 515
#define CEREAL_RAPIDJSON_DIAG_OFF(x) CEREAL_RAPIDJSON_DIAG_PRAGMA(disable: x)
6c5f2c01 sago007 2017-03-15 17:56 516
#define CEREAL_RAPIDJSON_DIAG_PUSH CEREAL_RAPIDJSON_DIAG_PRAGMA(push)
6c5f2c01 sago007 2017-03-15 17:56 517
#define CEREAL_RAPIDJSON_DIAG_POP  CEREAL_RAPIDJSON_DIAG_PRAGMA(pop)
6c5f2c01 sago007 2017-03-15 17:56 518
6c5f2c01 sago007 2017-03-15 17:56 519
#else
6c5f2c01 sago007 2017-03-15 17:56 520
6c5f2c01 sago007 2017-03-15 17:56 521
#define CEREAL_RAPIDJSON_DIAG_OFF(x) /* ignored */
6c5f2c01 sago007 2017-03-15 17:56 522
#define CEREAL_RAPIDJSON_DIAG_PUSH   /* ignored */
6c5f2c01 sago007 2017-03-15 17:56 523
#define CEREAL_RAPIDJSON_DIAG_POP    /* ignored */
6c5f2c01 sago007 2017-03-15 17:56 524
6c5f2c01 sago007 2017-03-15 17:56 525
#endif // CEREAL_RAPIDJSON_DIAG_*
6c5f2c01 sago007 2017-03-15 17:56 526
6c5f2c01 sago007 2017-03-15 17:56 527
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 528
// C++11 features
6c5f2c01 sago007 2017-03-15 17:56 529
6c5f2c01 sago007 2017-03-15 17:56 530
#ifndef CEREAL_RAPIDJSON_HAS_CXX11_RVALUE_REFS
6c5f2c01 sago007 2017-03-15 17:56 531
#if defined(__clang__)
6c5f2c01 sago007 2017-03-15 17:56 532
#if __has_feature(cxx_rvalue_references) && \
6c5f2c01 sago007 2017-03-15 17:56 533
    (defined(_LIBCPP_VERSION) || defined(__GLIBCXX__) && __GLIBCXX__ >= 20080306)
6c5f2c01 sago007 2017-03-15 17:56 534
#define CEREAL_RAPIDJSON_HAS_CXX11_RVALUE_REFS 1
6c5f2c01 sago007 2017-03-15 17:56 535
#else
6c5f2c01 sago007 2017-03-15 17:56 536
#define CEREAL_RAPIDJSON_HAS_CXX11_RVALUE_REFS 0
6c5f2c01 sago007 2017-03-15 17:56 537
#endif
6c5f2c01 sago007 2017-03-15 17:56 538
#elif (defined(CEREAL_RAPIDJSON_GNUC) && (CEREAL_RAPIDJSON_GNUC >= CEREAL_RAPIDJSON_VERSION_CODE(4,3,0)) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || \
6c5f2c01 sago007 2017-03-15 17:56 539
      (defined(_MSC_VER) && _MSC_VER >= 1600)
6c5f2c01 sago007 2017-03-15 17:56 540
6c5f2c01 sago007 2017-03-15 17:56 541
#define CEREAL_RAPIDJSON_HAS_CXX11_RVALUE_REFS 1
6c5f2c01 sago007 2017-03-15 17:56 542
#else
6c5f2c01 sago007 2017-03-15 17:56 543
#define CEREAL_RAPIDJSON_HAS_CXX11_RVALUE_REFS 0
6c5f2c01 sago007 2017-03-15 17:56 544
#endif
6c5f2c01 sago007 2017-03-15 17:56 545
#endif // CEREAL_RAPIDJSON_HAS_CXX11_RVALUE_REFS
6c5f2c01 sago007 2017-03-15 17:56 546
6c5f2c01 sago007 2017-03-15 17:56 547
#ifndef CEREAL_RAPIDJSON_HAS_CXX11_NOEXCEPT
6c5f2c01 sago007 2017-03-15 17:56 548
#if defined(__clang__)
6c5f2c01 sago007 2017-03-15 17:56 549
#define CEREAL_RAPIDJSON_HAS_CXX11_NOEXCEPT __has_feature(cxx_noexcept)
6c5f2c01 sago007 2017-03-15 17:56 550
#elif (defined(CEREAL_RAPIDJSON_GNUC) && (CEREAL_RAPIDJSON_GNUC >= CEREAL_RAPIDJSON_VERSION_CODE(4,6,0)) && defined(__GXX_EXPERIMENTAL_CXX0X__))
6c5f2c01 sago007 2017-03-15 17:56 551
//    (defined(_MSC_VER) && _MSC_VER >= ????) // not yet supported
6c5f2c01 sago007 2017-03-15 17:56 552
#define CEREAL_RAPIDJSON_HAS_CXX11_NOEXCEPT 1
6c5f2c01 sago007 2017-03-15 17:56 553
#else
6c5f2c01 sago007 2017-03-15 17:56 554
#define CEREAL_RAPIDJSON_HAS_CXX11_NOEXCEPT 0
6c5f2c01 sago007 2017-03-15 17:56 555
#endif
6c5f2c01 sago007 2017-03-15 17:56 556
#endif
6c5f2c01 sago007 2017-03-15 17:56 557
#if CEREAL_RAPIDJSON_HAS_CXX11_NOEXCEPT
6c5f2c01 sago007 2017-03-15 17:56 558
#define CEREAL_RAPIDJSON_NOEXCEPT noexcept
6c5f2c01 sago007 2017-03-15 17:56 559
#else
6c5f2c01 sago007 2017-03-15 17:56 560
#define CEREAL_RAPIDJSON_NOEXCEPT /* noexcept */
6c5f2c01 sago007 2017-03-15 17:56 561
#endif // CEREAL_RAPIDJSON_HAS_CXX11_NOEXCEPT
6c5f2c01 sago007 2017-03-15 17:56 562
6c5f2c01 sago007 2017-03-15 17:56 563
// no automatic detection, yet
6c5f2c01 sago007 2017-03-15 17:56 564
#ifndef CEREAL_RAPIDJSON_HAS_CXX11_TYPETRAITS
6c5f2c01 sago007 2017-03-15 17:56 565
#define CEREAL_RAPIDJSON_HAS_CXX11_TYPETRAITS 0
6c5f2c01 sago007 2017-03-15 17:56 566
#endif
6c5f2c01 sago007 2017-03-15 17:56 567
6c5f2c01 sago007 2017-03-15 17:56 568
#ifndef CEREAL_RAPIDJSON_HAS_CXX11_RANGE_FOR
6c5f2c01 sago007 2017-03-15 17:56 569
#if defined(__clang__)
6c5f2c01 sago007 2017-03-15 17:56 570
#define CEREAL_RAPIDJSON_HAS_CXX11_RANGE_FOR __has_feature(cxx_range_for)
6c5f2c01 sago007 2017-03-15 17:56 571
#elif (defined(CEREAL_RAPIDJSON_GNUC) && (CEREAL_RAPIDJSON_GNUC >= CEREAL_RAPIDJSON_VERSION_CODE(4,3,0)) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || \
6c5f2c01 sago007 2017-03-15 17:56 572
      (defined(_MSC_VER) && _MSC_VER >= 1700)
6c5f2c01 sago007 2017-03-15 17:56 573
#define CEREAL_RAPIDJSON_HAS_CXX11_RANGE_FOR 1
6c5f2c01 sago007 2017-03-15 17:56 574
#else
6c5f2c01 sago007 2017-03-15 17:56 575
#define CEREAL_RAPIDJSON_HAS_CXX11_RANGE_FOR 0
6c5f2c01 sago007 2017-03-15 17:56 576
#endif
6c5f2c01 sago007 2017-03-15 17:56 577
#endif // CEREAL_RAPIDJSON_HAS_CXX11_RANGE_FOR
6c5f2c01 sago007 2017-03-15 17:56 578
6c5f2c01 sago007 2017-03-15 17:56 579
//!@endcond
6c5f2c01 sago007 2017-03-15 17:56 580
6c5f2c01 sago007 2017-03-15 17:56 581
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 582
// new/delete
6c5f2c01 sago007 2017-03-15 17:56 583
6c5f2c01 sago007 2017-03-15 17:56 584
#ifndef CEREAL_RAPIDJSON_NEW
6c5f2c01 sago007 2017-03-15 17:56 585
///! customization point for global \c new
6c5f2c01 sago007 2017-03-15 17:56 586
#define CEREAL_RAPIDJSON_NEW(x) new x
6c5f2c01 sago007 2017-03-15 17:56 587
#endif
6c5f2c01 sago007 2017-03-15 17:56 588
#ifndef CEREAL_RAPIDJSON_DELETE
6c5f2c01 sago007 2017-03-15 17:56 589
///! customization point for global \c delete
6c5f2c01 sago007 2017-03-15 17:56 590
#define CEREAL_RAPIDJSON_DELETE(x) delete x
6c5f2c01 sago007 2017-03-15 17:56 591
#endif
6c5f2c01 sago007 2017-03-15 17:56 592
6c5f2c01 sago007 2017-03-15 17:56 593
///////////////////////////////////////////////////////////////////////////////
6c5f2c01 sago007 2017-03-15 17:56 594
// Type
6c5f2c01 sago007 2017-03-15 17:56 595
6c5f2c01 sago007 2017-03-15 17:56 596
/*! \namespace rapidjson
6c5f2c01 sago007 2017-03-15 17:56 597
    \brief main RapidJSON namespace
6c5f2c01 sago007 2017-03-15 17:56 598
    \see CEREAL_RAPIDJSON_NAMESPACE
6c5f2c01 sago007 2017-03-15 17:56 599
*/
6c5f2c01 sago007 2017-03-15 17:56 600
CEREAL_RAPIDJSON_NAMESPACE_BEGIN
6c5f2c01 sago007 2017-03-15 17:56 601
6c5f2c01 sago007 2017-03-15 17:56 602
//! Type of JSON value
6c5f2c01 sago007 2017-03-15 17:56 603
enum Type {
6c5f2c01 sago007 2017-03-15 17:56 604
    kNullType = 0,      //!< null
6c5f2c01 sago007 2017-03-15 17:56 605
    kFalseType = 1,     //!< false
6c5f2c01 sago007 2017-03-15 17:56 606
    kTrueType = 2,      //!< true
6c5f2c01 sago007 2017-03-15 17:56 607
    kObjectType = 3,    //!< object
6c5f2c01 sago007 2017-03-15 17:56 608
    kArrayType = 4,     //!< array 
6c5f2c01 sago007 2017-03-15 17:56 609
    kStringType = 5,    //!< string
6c5f2c01 sago007 2017-03-15 17:56 610
    kNumberType = 6     //!< number
6c5f2c01 sago007 2017-03-15 17:56 611
};
6c5f2c01 sago007 2017-03-15 17:56 612
6c5f2c01 sago007 2017-03-15 17:56 613
CEREAL_RAPIDJSON_NAMESPACE_END
6c5f2c01 sago007 2017-03-15 17:56 614
6c5f2c01 sago007 2017-03-15 17:56 615
#endif // CEREAL_RAPIDJSON_CEREAL_RAPIDJSON_H_
1970-01-01 00:00 616