RapidJSON configuration
Configuration macros for library features.
Defines
Use only lower 48-bit address for some pointers.
RAPIDJSON_ALIGN(x) (((x) + static_cast<size_t>(7u)) & ~static_cast<size_t>(7u))
Data alignment of the machine.
RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY() (64 * 1024)
User-defined kDefaultChunkCapacity definition.
RAPIDJSON_ASSERT(x) assert(x)
Assertion.
Enable RapidJSON support for
std::string.
RAPIDJSON_LIKELY(x) (x)
Compiler branching hint for expression with high probability to be true.
Major version of RapidJSON in integer.
Minor version of RapidJSON in integer.
RAPIDJSON_NAMESPACE() rapidjson
provide custom rapidjson namespace
RAPIDJSON_NAMESPACE_BEGIN() namespace {
provide custom rapidjson namespace (opening expression)
provide custom rapidjson namespace (closing expression)
RAPIDJSON_NOEXCEPT_ASSERT(x) (x)
Assertion (in non-throwing contexts).
Patch version of RapidJSON in integer.
RAPIDJSON_UNLIKELY(x) (x)
Compiler branching hint for expression with low probability to be true.
RAPIDJSON_VERSION_STRING() RAPIDJSON_STRINGIFY()
Version of RapidJSON in "
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.
Defines
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.
GenericValueuses this optimization to reduce its size form 24 bytes to 16 bytes in 64-bit architecture.
RAPIDJSON_ALIGN(x) (((x) + static_cast<size_t>(7u)) & ~static_cast<size_t>(7u))
Data alignment of the machine.
Parameters:
x | pointer to align |
RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY() (64 * 1024)
User-defined kDefaultChunkCapacity definition.
User can define this as any
sizethat is a power of 2.
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.
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::stringare enabled, especially for construction and comparison.
RAPIDJSON_LIKELY(x) (x)
Compiler branching hint for expression with high probability to be true.
Parameters:
x | Boolean expression likely to be true. |
RAPIDJSON_MAJOR_VERSION() 1
Major version of RapidJSON in integer.
RAPIDJSON_MINOR_VERSION() 1
Minor version of RapidJSON in integer.
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_NAMESPACEto 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:
// in some .cpp file #define RAPIDJSON_NAMESPACE my::rapidjson #define RAPIDJSON_NAMESPACE_BEGIN namespace my { namespace rapidjson { #define RAPIDJSON_NAMESPACE_END } } #include "rapidjson/..."
RAPIDJSON_NAMESPACE_BEGIN() namespace {
provide custom rapidjson namespace (opening expression)
RAPIDJSON_NAMESPACE_END() }
provide custom rapidjson namespace (closing expression)
RAPIDJSON_NOEXCEPT_ASSERT(x) (x)
Assertion (in non-throwing contexts).
Some functions provide a
noexceptguarantee, 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
noexceptis supported, and to RAPIDJSON_ASSERT otherwise.
RAPIDJSON_PATCH_VERSION() 0
Patch version of RapidJSON in integer.
RAPIDJSON_UNLIKELY(x) (x)
Compiler branching hint for expression with low probability to be true.
Parameters:
x | Boolean expression unlikely to be true. |
RAPIDJSON_VERSION_STRING() RAPIDJSON_STRINGIFY()
Version of RapidJSON in "