NDDEM
Macros
RapidJSON configuration

Configuration macros for library features. More...

Macros

#define CEREAL_RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY   (64 * 1024)
 User-defined kDefaultChunkCapacity definition. More...
 
#define CEREAL_RAPIDJSON_MAJOR_VERSION   1
 Major version of RapidJSON in integer. More...
 
#define CEREAL_RAPIDJSON_MINOR_VERSION   1
 Minor version of RapidJSON in integer. More...
 
#define CEREAL_RAPIDJSON_PATCH_VERSION   0
 Patch version of RapidJSON in integer. More...
 
#define CEREAL_RAPIDJSON_VERSION_STRING    CEREAL_RAPIDJSON_STRINGIFY(CEREAL_RAPIDJSON_MAJOR_VERSION.CEREAL_RAPIDJSON_MINOR_VERSION.CEREAL_RAPIDJSON_PATCH_VERSION)
 Version of RapidJSON in "<major>.<minor>.<patch>" string format. More...
 
#define CEREAL_RAPIDJSON_NAMESPACE   rapidjson
 provide custom rapidjson namespace More...
 
#define CEREAL_RAPIDJSON_NAMESPACE_BEGIN   namespace CEREAL_RAPIDJSON_NAMESPACE {
 provide custom rapidjson namespace (opening expression) More...
 
#define CEREAL_RAPIDJSON_NAMESPACE_END   }
 provide custom rapidjson namespace (closing expression) More...
 
#define CEREAL_RAPIDJSON_HAS_STDSTRING
 Enable RapidJSON support for std::string. More...
 
#define CEREAL_RAPIDJSON_ALIGN(x)   (((x) + static_cast<size_t>(7u)) & ~static_cast<size_t>(7u))
 Data alignment of the machine. More...
 
#define CEREAL_RAPIDJSON_48BITPOINTER_OPTIMIZATION   0
 Use only lower 48-bit address for some pointers. More...
 
#define CEREAL_RAPIDJSON_ASSERT(x)   assert(x)
 Assertion. More...
 
#define CEREAL_RAPIDJSON_LIKELY(x)   (x)
 Compiler branching hint for expression with high probability to be true. More...
 
#define CEREAL_RAPIDJSON_UNLIKELY(x)   (x)
 Compiler branching hint for expression with low probability to be true. More...
 
#define CEREAL_RAPIDJSON_NOEXCEPT_ASSERT(x)   CEREAL_RAPIDJSON_ASSERT(x)
 Assertion (in non-throwing contexts). More...
 

Detailed Description

Configuration macros for library features.

Some RapidJSON features are configurable to adapt the library to a wide variety of platforms, environments and usage scenarios. Most of the features can be configured in terms of overridden or predefined preprocessor macros at compile-time.

Some additional customization is available in the RapidJSON error handling APIs.

Note
These macros should be given on the compiler command-line (where applicable) to avoid inconsistent values when compiling different translation units of a single application.

Macro Definition Documentation

◆ CEREAL_RAPIDJSON_48BITPOINTER_OPTIMIZATION

#define CEREAL_RAPIDJSON_48BITPOINTER_OPTIMIZATION   0

Use only lower 48-bit address for some pointers.

This optimization uses the fact that current X86-64 architecture only implement lower 48-bit virtual address. The higher 16-bit can be used for storing other data. GenericValue uses this optimization to reduce its size form 24 bytes to 16 bytes in 64-bit architecture.

◆ CEREAL_RAPIDJSON_ALIGN

#define CEREAL_RAPIDJSON_ALIGN (   x)    (((x) + static_cast<size_t>(7u)) & ~static_cast<size_t>(7u))

Data alignment of the machine.

Parameters
xpointer to align

Some machines require strict data alignment. The default is 8 bytes. User can customize by defining the CEREAL_RAPIDJSON_ALIGN function macro.

◆ CEREAL_RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY

#define CEREAL_RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY   (64 * 1024)

User-defined kDefaultChunkCapacity definition.

User can define this as any size that is a power of 2.

◆ CEREAL_RAPIDJSON_ASSERT

#define CEREAL_RAPIDJSON_ASSERT (   x)    assert(x)

Assertion.

By default, rapidjson uses C assert() for internal assertions. User can override it by defining CEREAL_RAPIDJSON_ASSERT(x) macro.

Note
Parsing errors are handled and can be customized by the RapidJSON error handling APIs.

◆ CEREAL_RAPIDJSON_HAS_STDSTRING

#define CEREAL_RAPIDJSON_HAS_STDSTRING

Enable RapidJSON support for std::string.

By defining this preprocessor symbol to 1, several convenience functions for using rapidjson::GenericValue with std::string are enabled, especially for construction and comparison.

◆ CEREAL_RAPIDJSON_LIKELY

#define CEREAL_RAPIDJSON_LIKELY (   x)    (x)

Compiler branching hint for expression with high probability to be true.

Parameters
xBoolean expression likely to be true.

◆ CEREAL_RAPIDJSON_MAJOR_VERSION

#define CEREAL_RAPIDJSON_MAJOR_VERSION   1

Major version of RapidJSON in integer.

◆ CEREAL_RAPIDJSON_MINOR_VERSION

#define CEREAL_RAPIDJSON_MINOR_VERSION   1

Minor version of RapidJSON in integer.

◆ CEREAL_RAPIDJSON_NAMESPACE

#define CEREAL_RAPIDJSON_NAMESPACE   rapidjson

provide custom rapidjson namespace

In order to avoid symbol clashes and/or "One Definition Rule" errors between multiple inclusions of (different versions of) RapidJSON in a single binary, users can customize the name of the main RapidJSON namespace.

In case of a single nesting level, defining CEREAL_RAPIDJSON_NAMESPACE to a custom name (e.g. MyRapidJSON) is sufficient. If multiple levels are needed, both CEREAL_RAPIDJSON_NAMESPACE_BEGIN and CEREAL_RAPIDJSON_NAMESPACE_END need to be defined as well:

// in some .cpp file
#define CEREAL_RAPIDJSON_NAMESPACE my::rapidjson
#define CEREAL_RAPIDJSON_NAMESPACE_BEGIN namespace my { namespace rapidjson {
#define CEREAL_RAPIDJSON_NAMESPACE_END } }
#include "rapidjson/..."
See also
rapidjson

◆ CEREAL_RAPIDJSON_NAMESPACE_BEGIN

#define CEREAL_RAPIDJSON_NAMESPACE_BEGIN   namespace CEREAL_RAPIDJSON_NAMESPACE {

provide custom rapidjson namespace (opening expression)

See also
CEREAL_RAPIDJSON_NAMESPACE

◆ CEREAL_RAPIDJSON_NAMESPACE_END

#define CEREAL_RAPIDJSON_NAMESPACE_END   }

provide custom rapidjson namespace (closing expression)

See also
CEREAL_RAPIDJSON_NAMESPACE

◆ CEREAL_RAPIDJSON_NOEXCEPT_ASSERT

#define CEREAL_RAPIDJSON_NOEXCEPT_ASSERT (   x)    CEREAL_RAPIDJSON_ASSERT(x)

Assertion (in non-throwing contexts).

Some functions provide a noexcept guarantee, if the compiler supports it. In these cases, the CEREAL_RAPIDJSON_ASSERT macro cannot be overridden to throw an exception. This macro adds a separate customization point for such cases.

Defaults to C assert() (as CEREAL_RAPIDJSON_ASSERT), if noexcept is supported, and to CEREAL_RAPIDJSON_ASSERT otherwise.

◆ CEREAL_RAPIDJSON_PATCH_VERSION

#define CEREAL_RAPIDJSON_PATCH_VERSION   0

Patch version of RapidJSON in integer.

◆ CEREAL_RAPIDJSON_UNLIKELY

#define CEREAL_RAPIDJSON_UNLIKELY (   x)    (x)

Compiler branching hint for expression with low probability to be true.

Parameters
xBoolean expression unlikely to be true.

◆ CEREAL_RAPIDJSON_VERSION_STRING

#define CEREAL_RAPIDJSON_VERSION_STRING    CEREAL_RAPIDJSON_STRINGIFY(CEREAL_RAPIDJSON_MAJOR_VERSION.CEREAL_RAPIDJSON_MINOR_VERSION.CEREAL_RAPIDJSON_PATCH_VERSION)

Version of RapidJSON in "<major>.<minor>.<patch>" string format.