All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
RapidJSON configuration

Configuration macros for library features. More...

Macros

#define RAPIDJSON_NO_INT64DEFINE
 Use external 64-bit integer types. More...
 
#define RAPIDJSON_ENDIAN
 Endianness of the machine. More...
 
#define RAPIDJSON_ALIGN(x)   ((x + 3u) & ~3u)
 Data alignment of the machine. More...
 
#define RAPIDJSON_SIMD
 Enable SSE2/SSE4.2 optimization. More...
 
#define RAPIDJSON_NO_SIZETYPEDEFINE
 User-provided SizeType definition. More...
 
#define RAPIDJSON_ASSERT(x)   assert(x)
 Assertion. More...
 
#define RAPIDJSON_HAS_STDSTRING
 Enable RapidJSON support for std::string. 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 overriden 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

#define RAPIDJSON_ALIGN (   x)    ((x + 3u) & ~3u)

Data alignment of the machine.

Parameters
xpointer to align

Some machines require strict data alignment. Currently the default uses 4 bytes alignment. User can customize by defining the RAPIDJSON_ALIGN function macro.,

#define RAPIDJSON_ASSERT (   x)    assert(x)

Assertion.

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

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

Endianness of the machine.

GCC 4.6 provided macro for detecting endianness of the target machine. But other compilers may not have this. User can define RAPIDJSON_ENDIAN to either RAPIDJSON_LITTLEENDIAN or RAPIDJSON_BIGENDIAN.

Default detection implemented with reference to

#define 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.

#define RAPIDJSON_NO_INT64DEFINE

Use external 64-bit integer types.

RapidJSON requires the 64-bit integer types int64_t and uint64_t types to be available at global scope.

If users have their own definition, define RAPIDJSON_NO_INT64DEFINE to prevent RapidJSON from defining its own types.

#define RAPIDJSON_NO_SIZETYPEDEFINE

User-provided SizeType definition.

In order to avoid using 32-bit size types for indexing strings and arrays, define this preprocessor symbol and provide the type rapidjson::SizeType before including RapidJSON:

1 #define RAPIDJSON_NO_SIZETYPEDEFINE
2 namespace rapidjson { typedef ::std::size_t SizeType; }
3 #include "rapidjson/..."
See also
rapidjson::SizeType
#define RAPIDJSON_SIMD

Enable SSE2/SSE4.2 optimization.

RapidJSON supports optimized implementations for some parsing operations based on the SSE2 or SSE4.2 SIMD extensions on modern Intel-compatible processors.

To enable these optimizations, two different symbols can be defined;

1 // Enable SSE2 optimization.
2 #define RAPIDJSON_SSE2
3 
4 // Enable SSE4.2 optimization.
5 #define RAPIDJSON_SSE42

RAPIDJSON_SSE42 takes precedence, if both are defined.

If any of these symbols is defined, RapidJSON defines the macro RAPIDJSON_SIMD to indicate the availability of the optimized code.