Configuration macros for library features. More...
Macros | |
#define | RAPIDJSON_MAJOR_VERSION 1 |
Major version of RapidJSON in integer. | |
#define | RAPIDJSON_MINOR_VERSION 1 |
Minor version of RapidJSON in integer. | |
#define | RAPIDJSON_PATCH_VERSION 0 |
Patch version of RapidJSON in integer. | |
#define | RAPIDJSON_VERSION_STRING RAPIDJSON_STRINGIFY(RAPIDJSON_MAJOR_VERSION.RAPIDJSON_MINOR_VERSION.RAPIDJSON_PATCH_VERSION) |
Version of RapidJSON in "<major>.<minor>.<patch>" string format. | |
#define | RAPIDJSON_NAMESPACE rapidjson |
provide custom rapidjson namespace More... | |
#define | RAPIDJSON_HAS_STDSTRING |
Enable RapidJSON support for std::string . More... | |
#define | RAPIDJSON_USE_MEMBERSMAP |
Enable RapidJSON support for object members handling in a std::multimap . More... | |
#define | RAPIDJSON_NO_INT64DEFINE |
Use external 64-bit integer types. More... | |
#define | RAPIDJSON_ENDIAN |
Endianness of the machine. More... | |
#define | RAPIDJSON_ALIGN(x) (((x) + static_cast<size_t>(7u)) & ~static_cast<size_t>(7u)) |
Data alignment of the machine. More... | |
#define | RAPIDJSON_48BITPOINTER_OPTIMIZATION 0 |
Use only lower 48-bit address for some pointers. More... | |
#define | RAPIDJSON_SIMD |
Enable SSE2/SSE4.2/Neon optimization. More... | |
#define | RAPIDJSON_NO_SIZETYPEDEFINE |
User-provided SizeType definition. More... | |
#define | RAPIDJSON_ASSERT(x) assert(x) |
Assertion. More... | |
#define | RAPIDJSON_LIKELY(x) (x) |
Compiler branching hint for expression with high probability to be true. More... | |
#define | RAPIDJSON_UNLIKELY(x) (x) |
Compiler branching hint for expression with low probability to be true. More... | |
#define | RAPIDJSON_NOEXCEPT_ASSERT(x) RAPIDJSON_ASSERT(x) |
Assertion (in non-throwing contexts). More... | |
#define | RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY (64 * 1024) |
User-defined kDefaultChunkCapacity definition. More... | |
#define | RAPIDJSON_DEFAULT_ALLOCATOR MemoryPoolAllocator<CrtAllocator> |
Allows to choose default allocator. More... | |
#define | RAPIDJSON_DEFAULT_STACK_ALLOCATOR CrtAllocator |
Allows to choose default stack allocator for Document. More... | |
#define | RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY 16 |
User defined kDefaultObjectCapacity value. More... | |
#define | RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY 16 |
User defined kDefaultArrayCapacity value. More... | |
#define | RAPIDJSON_PARSE_DEFAULT_FLAGS kParseNoFlags |
User-defined kParseDefaultFlags definition. More... | |
#define | RAPIDJSON_VALIDATE_DEFAULT_FLAGS kValidateNoFlags |
User-defined kValidateDefaultFlags definition. More... | |
#define | RAPIDJSON_WRITE_DEFAULT_FLAGS kWriteNoFlags |
User-defined kWriteDefaultFlags definition. More... | |
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.
#define 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.
#define RAPIDJSON_ALIGN | ( | x | ) | (((x) + static_cast<size_t>(7u)) & ~static_cast<size_t>(7u)) |
Data alignment of the machine.
x | pointer to align |
Some machines require strict data alignment. The default is 8 bytes. User can customize by defining the RAPIDJSON_ALIGN function macro.
#define RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY (64 * 1024) |
User-defined kDefaultChunkCapacity definition.
User can define this as any size
that is a power of 2.
#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.
#define RAPIDJSON_DEFAULT_ALLOCATOR MemoryPoolAllocator<CrtAllocator> |
Allows to choose default allocator.
User can define this to use CrtAllocator or MemoryPoolAllocator.
#define RAPIDJSON_DEFAULT_STACK_ALLOCATOR CrtAllocator |
Allows to choose default stack allocator for Document.
User can define this to use CrtAllocator or MemoryPoolAllocator.
#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_LIKELY | ( | x | ) | (x) |
Compiler branching hint for expression with high probability to be true.
x | Boolean expression likely to be true. |
#define 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 RAPIDJSON_NAMESPACE
to a custom name (e.g. MyRapidJSON
) is sufficient. If multiple levels are needed, both RAPIDJSON_NAMESPACE_BEGIN and RAPIDJSON_NAMESPACE_END need to be defined as well:
#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:
#define RAPIDJSON_NOEXCEPT_ASSERT | ( | x | ) | RAPIDJSON_ASSERT(x) |
Assertion (in non-throwing contexts).
Some functions provide a noexcept
guarantee, if the compiler supports it. In these cases, the 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 RAPIDJSON_ASSERT), if noexcept
is supported, and to RAPIDJSON_ASSERT otherwise.
#define RAPIDJSON_PARSE_DEFAULT_FLAGS kParseNoFlags |
User-defined kParseDefaultFlags definition.
User can define this as any ParseFlag
combinations.
#define RAPIDJSON_SIMD |
Enable SSE2/SSE4.2/Neon optimization.
RapidJSON supports optimized implementations for some parsing operations based on the SSE2, SSE4.2 or NEon SIMD extensions on modern Intel or ARM compatible processors.
To enable these optimizations, three different symbols can be defined;
Enable ARM Neon optimization. #define RAPIDJSON_NEON
RAPIDJSON_SSE42
takes precedence over SSE2, 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.
#define RAPIDJSON_UNLIKELY | ( | x | ) | (x) |
Compiler branching hint for expression with low probability to be true.
x | Boolean expression unlikely to be true. |
#define RAPIDJSON_USE_MEMBERSMAP |
Enable RapidJSON support for object members handling in a std::multimap
.
By defining this preprocessor symbol to 1
, rapidjson::GenericValue object members are stored in a std::multimap
for faster lookup and deletion times, a trade off with a slightly slower insertion time and a small object allocat(or)ed memory overhead.
#define RAPIDJSON_VALIDATE_DEFAULT_FLAGS kValidateNoFlags |
User-defined kValidateDefaultFlags definition.
User can define this as any ValidateFlag
combinations.
#define RAPIDJSON_VALUE_DEFAULT_ARRAY_CAPACITY 16 |
User defined kDefaultArrayCapacity value.
User can define this as any natural number.
#define RAPIDJSON_VALUE_DEFAULT_OBJECT_CAPACITY 16 |
User defined kDefaultObjectCapacity value.
User can define this as any natural number.
#define RAPIDJSON_WRITE_DEFAULT_FLAGS kWriteNoFlags |
User-defined kWriteDefaultFlags definition.
User can define this as any WriteFlag
combinations.