载入中...
搜索中...
未找到
宏定义
RapidJSON configuration

Configuration macros for library features 更多...

## 宏定义
#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
#define | RAPIDJSON_HAS_STDSTRING
| Enable RapidJSON support for `std::string`
#define | RAPIDJSON_NO_INT64DEFINE
| Use external 64-bit integer types.
#define | RAPIDJSON_ENDIAN
| Endianness of the machine.
#define | RAPIDJSON_ALIGN(x)
| Data alignment of the machine.
#define | RAPIDJSON_48BITPOINTER_OPTIMIZATION 0
| Use only lower 48-bit address for some pointers.
#define | RAPIDJSON_SIMD
| Enable SSE2/SSE4.2 optimization.
#define | RAPIDJSON_NO_SIZETYPEDEFINE
| User-provided `SizeType` definition.
#define | RAPIDJSON_ASSERT(x)
| Assertion.
#define | RAPIDJSON_LIKELY(x)
| Compiler branching hint for expression with high probability to be true.
#define | RAPIDJSON_UNLIKELY(x)
| Compiler branching hint for expression with low probability to be true.
#define | RAPIDJSON_PARSE_DEFAULT_FLAGS kParseNoFlags
| User-defined kParseDefaultFlags definition.
#define | RAPIDJSON_WRITE_DEFAULT_FLAGS kWriteNoFlags
| User-defined kWriteDefaultFlags definition.

## 详细描述

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.

注解
  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.

## 宏定义说明

## ◆ RAPIDJSON_48BITPOINTER_OPTIMIZATION

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

## ◆ RAPIDJSON_ALIGN

#define RAPIDJSON_ALIGN | ( |  | x | ) |

值:
(((x) + 3u) & ~3u)

Data alignment of the machine.

参数

  x | pointer to align

Some machines require strict data alignment. Currently the default uses 4 bytes alignment on 32-bit platforms and 8 bytes alignment for 64-bit platforms. User can customize by defining the RAPIDJSON_ALIGN function macro.

## ◆ RAPIDJSON_ASSERT

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

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

## ◆ RAPIDJSON_ENDIAN

#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

- https://gcc.gnu.org/onlinedocs/gcc-4.6.0/cpp/Common-Predefined-Macros.html
- http://www.boost.org/doc/libs/1_42_0/boost/detail/endian.hpp

## ◆ RAPIDJSON_HAS_STDSTRING

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

## ◆ RAPIDJSON_LIKELY

#define RAPIDJSON_LIKELY | ( |  | x | ) |

值:
(x)

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

参数

  x | Boolean expression likely to be true.

## ◆ RAPIDJSON_NAMESPACE

#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:

// in some .cpp file
#define RAPIDJSON_NAMESPACE my::rapidjson
#define RAPIDJSON_NAMESPACE_BEGIN namespace my { namespace rapidjson {
#define RAPIDJSON_NAMESPACE_END } }
#include "rapidjson/..."

参见
  rapidjson

## ◆ RAPIDJSON_NO_INT64DEFINE

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

## ◆ RAPIDJSON_NO_SIZETYPEDEFINE

#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_NO_SIZETYPEDEFINE
namespace rapidjson { typedef ::std::size_t SizeType; }
#include "rapidjson/..."
rapidjson
main RapidJSON namespace
定义 rapidjson.h:374
rapidjson::SizeType
unsigned SizeType
Size type (for string lengths, array sizes, etc.)
定义 rapidjson.h:380

参见
  rapidjson::SizeType

## ◆ RAPIDJSON_PARSE_DEFAULT_FLAGS

#define RAPIDJSON_PARSE_DEFAULT_FLAGS kParseNoFlags

User-defined kParseDefaultFlags definition.

User can define this as any `ParseFlag` combinations.

## ◆ RAPIDJSON_SIMD

#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;

// Enable SSE2 optimization.
#define RAPIDJSON_SSE2
// Enable SSE4.2 optimization.
#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.

## ◆ RAPIDJSON_UNLIKELY

#define RAPIDJSON_UNLIKELY | ( |  | x | ) |

值:
(x)

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

参数

  x | Boolean expression unlikely to be true.

## ◆ RAPIDJSON_WRITE_DEFAULT_FLAGS

#define RAPIDJSON_WRITE_DEFAULT_FLAGS kWriteNoFlags

User-defined kWriteDefaultFlags definition.

User can define this as any `WriteFlag` combinations.