Skip to content

Commit

Permalink
Merge pull request #714 from miloyip/version1.1.0
Browse files Browse the repository at this point in the history
Version 1.1.0
  • Loading branch information
miloyip authored Aug 25, 2016
2 parents ab791ae + 17254e0 commit f54b0e4
Show file tree
Hide file tree
Showing 26 changed files with 162 additions and 57 deletions.
27 changes: 22 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## 1.1.0 - 2016-08-25

### Added
* Add GenericDocument ctor overload to specify JSON type (#369)
* Add FAQ (#372, #373, #374, #376)
* Add forward declaration header `fwd.h`
* Add @PlatformIO Library Registry manifest file (#400)
* Implement assignment operator for BigInteger (#404)
* Add comments support (#443)
Expand All @@ -33,11 +36,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
* Add parse-by-parts example (#556, #562)
* Support parse number as string (#564, #589)
* Add kFormatSingleLineArray for PrettyWriter (#577)
* Added optional support for trailing commas #584
* Added optional support for trailing commas (#584)
* Added filterkey and filterkeydom examples (#615)
* Added npm docs (#639)
* Allow options for writing and parsing NaN/Infinity (#641)
* Add std::string overload to PrettyWriter::Key() when RAPIDJSON_HAS_STDSTRING is defined (#698)

### Fixed
* Fix gcc/clang/vc warnings (#350, #394, #397, #444, #447, #473, #515, #582, #589, #595)
* Fix documentation (#482, #511, #550, #557)
* Fix gcc/clang/vc warnings (#350, #394, #397, #444, #447, #473, #515, #582, #589, #595, #667)
* Fix documentation (#482, #511, #550, #557, #614, #635, #660)
* Fix emscripten alignment issue (#535)
* Fix missing allocator to uses of AddMember in document (#365)
* CMake will no longer complain that the minimum CMake version is not specified (#501)
Expand All @@ -56,14 +63,23 @@ This project adheres to [Semantic Versioning](http://semver.org/).
* Fix a crash bug in regex (#605)
* Fix schema "required" keyword cannot handle duplicated keys (#609)
* Fix cmake CMP0054 warning (#612)
* Added missing include guards in istreamwrapper.h and ostreamwrapper.h (#634)
* Fix undefined behaviour (#646)
* Fix buffer overrun using PutN (#673)
* Fix rapidjson::value::Get<std::string>() may returns wrong data (#681)
* Add Flush() for all value types (#689)
* Handle malloc() fail in PoolAllocator (#691)
* Fix builds on x32 platform. #703

### Changed
* Clarify problematic JSON license (#392)
* Move Travis to container based infrastructure (#504, #558)
* Make whitespace array more compact (#513)
* Optimize Writer::WriteString() with SIMD (#544)
* x86-64 48-bit pointer optimization for GenericValue (#546)

* Define RAPIDJSON_HAS_CXX11_RVALUE_REFS directly in clang (#617)
* Make GenericSchemaDocument constructor explicit (#674)
* Optimize FindMember when use std::string (#690)

## [1.0.2] - 2015-05-14

Expand Down Expand Up @@ -135,7 +151,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## 0.1 - 2011-11-18

[Unreleased]: https://github.com/miloyip/rapidjson/compare/v1.0.2...HEAD
[Unreleased]: https://github.com/miloyip/rapidjson/compare/v1.1.0...HEAD
[1.1.0]: https://github.com/miloyip/rapidjson/compare/v1.0.2...v1.1.0
[1.0.2]: https://github.com/miloyip/rapidjson/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/miloyip/rapidjson/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/miloyip/rapidjson/compare/v1.0-beta...v1.0.0
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules)
PROJECT(RapidJSON CXX)

set(LIB_MAJOR_VERSION "1")
set(LIB_MINOR_VERSION "0")
set(LIB_PATCH_VERSION "2")
set(LIB_MINOR_VERSION "1")
set(LIB_PATCH_VERSION "0")
set(LIB_VERSION_STRING "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_PATCH_VERSION}")

# compile in release with debug info mode by default
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
os: Visual Studio 2015 CTP
version: 1.0.2.{build}
version: 1.1.0.{build}

configuration:
- Debug
Expand Down
1 change: 1 addition & 0 deletions doc/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ WARN_LOGFILE =
# Note: If this tag is empty the current directory is searched.

INPUT = readme.md \
CHANGELOG.md \
include/rapidjson/rapidjson.h \
include/ \
doc/features.md \
Expand Down
1 change: 1 addition & 0 deletions doc/Doxyfile.zh-cn.in
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ WARN_LOGFILE =
# Note: If this tag is empty the current directory is searched.

INPUT = readme.zh-cn.md \
CHANGELOG.md \
include/rapidjson/rapidjson.h \
include/ \
doc/features.zh-cn.md \
Expand Down
15 changes: 8 additions & 7 deletions doc/dom.zh-cn.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DOM

文档对象模型(Document Object Model, DOM)是一种罝于内存中的 JSON 表示方式,以供查询及操作。我们己于 [教程](doc/tutorial.md) 中介绍了 DOM 的基本用法,本节将讲述一些细节及高级用法。
文档对象模型(Document Object Model, DOM)是一种罝于内存中的 JSON 表示方式,以供查询及操作。我们己于 [教程](doc/tutorial.zh-cn.md) 中介绍了 DOM 的基本用法,本节将讲述一些细节及高级用法。

[TOC]

Expand Down Expand Up @@ -31,7 +31,7 @@ typedef GenericDocument<UTF8<> > Document;
## 编码 {#Encoding}
`Encoding` 参数指明在内存中的 JSON String 使用哪种编码。可行的选项有 `UTF8`、`UTF16`、`UTF32`。要注意这 3 个类型其实也是模板类。`UTF8<>` 等同 `UTF8<char>`,这代表它使用 `char` 来存储字符串。更多细节可以参考 [编码](encoding.md)。
`Encoding` 参数指明在内存中的 JSON String 使用哪种编码。可行的选项有 `UTF8`、`UTF16`、`UTF32`。要注意这 3 个类型其实也是模板类。`UTF8<>` 等同 `UTF8<char>`,这代表它使用 `char` 来存储字符串。更多细节可以参考 [编码](doc/encoding.zh-cn.md)。
这里是一个例子。假设一个 Windows 应用软件希望查询存储于 JSON 中的本地化字符串。Windows 中含 Unicode 的函数使用 UTF-16(宽字符)编码。无论 JSON 文件使用哪种编码,我们都可以把字符串以 UTF-16 形式存储在内存。
Expand Down Expand Up @@ -102,7 +102,7 @@ GenericDocument& GenericDocument::Parse(const Ch* str);
GenericDocument& GenericDocument::Parse(const Ch* str);
~~~~~~~~~~
[教程](tutorial.md) 中的例使用 (8) 去正常解析字符串。而 [流](stream.md) 的例子使用前 3 个函数。我们将稍后介绍原位(*In situ*) 解析。
[教程](doc/tutorial.zh-cn.md) 中的例使用 (8) 去正常解析字符串。而 [流](doc/stream.zh-cn.md) 的例子使用前 3 个函数。我们将稍后介绍原位(*In situ*) 解析。
`parseFlags` 是以下位标置的组合:
Expand All @@ -118,6 +118,7 @@ GenericDocument& GenericDocument::Parse(const Ch* str);
`kParseCommentsFlag` | 容许单行 `// ...` 及多行 `/* ... */` 注释(放宽的 JSON 语法)。
`kParseNumbersAsStringsFlag` | 把数字类型解析成字符串。
`kParseTrailingCommasFlag` | 容许在对象和数组结束前含有逗号(放宽的 JSON 语法)。
`kParseNanAndInfFlag` | 容许 `NaN`、`Inf`、`Infinity`、`-Inf` 及 `-Infinity` 作为 `double` 值(放宽的 JSON 语法)。
由于使用了非类型模板参数,而不是函数参数,C++ 编译器能为个别组合生成代码,以改善性能及减少代码尺寸(当只用单种特化)。缺点是需要在编译期决定标志。
Expand Down Expand Up @@ -230,9 +231,9 @@ JSON string 会被打上 const-string 的标志。但它们可能并非真正的
## 转码与校验 {#TranscodingAndValidation}
RapidJSON 内部支持不同 Unicode 格式(正式的术语是 UCS 变换格式)间的转换。在 DOM 解析时,流的来源编码与 DOM 的编码可以不同。例如,来源流可能含有 UTF-8 的 JSON,而 DOM 则使用 UTF-16 编码。在 [EncodedInputStream](doc/stream.md) 一节里有一个例子。
RapidJSON 内部支持不同 Unicode 格式(正式的术语是 UCS 变换格式)间的转换。在 DOM 解析时,流的来源编码与 DOM 的编码可以不同。例如,来源流可能含有 UTF-8 的 JSON,而 DOM 则使用 UTF-16 编码。在 [EncodedInputStream](doc/stream.zh-cn.md) 一节里有一个例子。
当从 DOM 输出一个 JSON 至输出流之时,也可以使用转码功能。在 [EncodedOutputStream](doc/stream.md) 一节里有一个例子。
当从 DOM 输出一个 JSON 至输出流之时,也可以使用转码功能。在 [EncodedOutputStream](doc/stream.zh-cn.md) 一节里有一个例子。
在转码过程中,会把来源 string 解码成 Unicode 码点,然后把码点编码成目标格式。在解码时,它会校验来源 string 的字节序列是否合法。若遇上非合法序列,解析器会停止并返回 `kParseErrorStringInvalidEncoding` 错误。
Expand All @@ -256,9 +257,9 @@ d.Accept(writer);

使用者可以创建自定义的处理器,去把 DOM 转换成其它格式。例如,一个把 DOM 转换成 XML 的处理器。

要知道更多关于 SAX 事件与处理器,可参阅 [SAX](doc/sax.md)
要知道更多关于 SAX 事件与处理器,可参阅 [SAX](doc/sax.zh-cn.md)

## 使用者缓冲区{ #UserBuffer}
## 使用者缓冲区 {#UserBuffer}

许多应用软件可能需要尽量减少内存分配。

Expand Down
2 changes: 1 addition & 1 deletion doc/encoding.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ typedef GenericDocument<UTF16<> > WDocument;
typedef GenericValue<UTF16<> > WValue;
~~~~~~~~~~

可以在 [DOM's Encoding](doc/stream.md) 一节看到更详细的使用例子。
可以在 [DOM's Encoding](doc/stream.zh-cn.md) 一节看到更详细的使用例子。

## 字符类型 {#CharacterType}

Expand Down
8 changes: 4 additions & 4 deletions doc/faq.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@

4. 什么是原位(*in situ*)解析?

原位解析会把 JSON 字符串直接解码至输入的 JSON 中。这是一个优化,可减少内存消耗及提升性能,但输入的 JSON 会被更改。进一步细节请参考 [原位解析](doc/dom.md)
原位解析会把 JSON 字符串直接解码至输入的 JSON 中。这是一个优化,可减少内存消耗及提升性能,但输入的 JSON 会被更改。进一步细节请参考 [原位解析](doc/dom.zh-cn.md)

5. 什么时候会产生解析错误?

当输入的 JSON 包含非法语法,或不能表示一个值(如 Number 太大),或解析器的处理器中断解析过程,解析器都会产生一个错误。详情请参考 [解析错误](doc/dom.md)
当输入的 JSON 包含非法语法,或不能表示一个值(如 Number 太大),或解析器的处理器中断解析过程,解析器都会产生一个错误。详情请参考 [解析错误](doc/dom.zh-cn.md)

6. 有什么错误信息?

Expand Down Expand Up @@ -171,7 +171,7 @@

2. 怎样去复制一个值?

有两个 API 可用:含 allocator 的构造函数,以及 `CopyFrom()`。可参考 [深复制 Value](doc/tutorial.md) 里的用例。
有两个 API 可用:含 allocator 的构造函数,以及 `CopyFrom()`。可参考 [深复制 Value](doc/tutorial.zh-cn.md) 里的用例。

3. 为什么我需要提供字符串的长度?

Expand Down Expand Up @@ -239,7 +239,7 @@

[字节顺序标记(byte order mark, BOM)](http://en.wikipedia.org/wiki/Byte_order_mark) 有时会出现于文件/流的开始,以表示其 UTF 编码类型。

RapidJSON 的 `EncodedInputStream` 可检测/跳过 BOM。`EncodedOutputStream` 可选择是否写入 BOM。可参考 [编码流](doc/stream.md) 中的例子。
RapidJSON 的 `EncodedInputStream` 可检测/跳过 BOM。`EncodedOutputStream` 可选择是否写入 BOM。可参考 [编码流](doc/stream.zh-cn.md) 中的例子。

5. 为什么会涉及大端/小端?

Expand Down
8 changes: 6 additions & 2 deletions doc/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
## Standard compliance

* RapidJSON should be fully RFC4627/ECMA-404 compliance.
* Support JSON Pointer (RFC6901).
* Support JSON Schema Draft v4.
* Support Unicode surrogate.
* Support null character (`"\u0000"`)
* For example, `["Hello\u0000World"]` can be parsed and handled gracefully. There is API for getting/setting lengths of string.
* Support optional relaxed syntax.
* Single line (`// ...`) and multiple line (`/* ... */`) comments (`kParseCommentsFlag`).
* Trailing commas at the end of objects and arrays (`kParseTrailingCommasFlag`).
* [NPM compliant](doc/npm.md).
* `NaN`, `Inf`, `Infinity`, `-Inf` and `-Infinity` as `double` values (`kParseNanAndInfFlag`)
* [NPM compliant](http://github.com/miloyip/rapidjson/blob/master/doc/npm.md).

## Unicode

Expand Down Expand Up @@ -70,7 +73,7 @@
* Only store pointer instead of copying
* Optimization for "short" strings
* Store short string in `Value` internally without additional allocation.
* For UTF-8 string: maximum 11 characters in 32-bit, 15 characters in 64-bit.
* For UTF-8 string: maximum 11 characters in 32-bit, 21 characters in 64-bit (13 characters in x86-64).
* Optionally support `std::string` (define `RAPIDJSON_HAS_STDSTRING=1`)

## Generation
Expand Down Expand Up @@ -98,3 +101,4 @@
* Some C++11 support (optional)
* Rvalue reference
* `noexcept` specifier
* Range-based for loop
9 changes: 7 additions & 2 deletions doc/features.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@
## 符合标准

* RapidJSON 应完全符合 RFC4627/ECMA-404 标准。
* 支持 JSON Pointer (RFC6901).
* 支持 JSON Schema Draft v4.
* 支持 Unicod 代理对(surrogate pair)。
* 支持空字符(`"\u0000"`)。
* 例如,可以优雅地解析及处理 `["Hello\u0000World"]`。含读写字符串长度的 API。
* 支持放宽的可选语法
* 支持可选的放宽语法
* 单行(`// ...`)及多行(`/* ... */`) 注释 (`kParseCommentsFlag`)。
* 在对象和数组结束前含逗号 (`kParseTrailingCommasFlag`)。
* `NaN``Inf``Infinity``-Inf``-Infinity` 作为 `double` 值 (`kParseNanAndInfFlag`)
* [NPM 兼容](https://github.com/miloyip/rapidjson/blob/master/doc/npm.md).

## Unicode

Expand Down Expand Up @@ -68,7 +72,7 @@
* 只储存指针,不作复制
* 优化“短”字符串
*`Value` 内储存短字符串,无需额外分配。
* 对 UTF-8 字符串来说,32 位架构下可存储最多 11 字符,64 位下 15 字符。
* 对 UTF-8 字符串来说,32 位架构下可存储最多 11 字符,64 位下 21 字符(x86-64 下 13 字符)
* 可选地支持 `std::string`(定义 `RAPIDJSON_HAS_STDSTRING=1`

## 生成
Expand Down Expand Up @@ -96,3 +100,4 @@
* 一些 C++11 的支持(可选)
* 右值引用(rvalue reference)
* `noexcept` 修饰符
* 范围 for 循环
6 changes: 3 additions & 3 deletions doc/internals.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Number is a bit more complicated. For normal integer values, it can contains `kI

## Short-String Optimization {#ShortString}

Kosta (@Kosta-Github) provided a very neat short-string optimization. The optimization idea is given as follow. Excluding the `flags_`, a `Value` has 12 or 16 bytes (32-bit or 64-bit) for storing actual data. Instead of storing a pointer to a string, it is possible to store short strings in these space internally. For encoding with 1-byte character type (e.g. `char`), it can store maximum 11 or 15 characters string inside the `Value` type.
[Kosta](https://github.com/Kosta-Github) provided a very neat short-string optimization. The optimization idea is given as follow. Excluding the `flags_`, a `Value` has 12 or 16 bytes (32-bit or 64-bit) for storing actual data. Instead of storing a pointer to a string, it is possible to store short strings in these space internally. For encoding with 1-byte character type (e.g. `char`), it can store maximum 11 or 15 characters string inside the `Value` type.

| ShortString (Ch=char) | |32-bit|64-bit|
|---------------------|-------------------------------------|:----:|:----:|
Expand All @@ -126,7 +126,7 @@ A special technique is applied. Instead of storing the length of string directly

This optimization can reduce memory usage for copy-string. It can also improve cache-coherence thus improve runtime performance.

# Allocator {#Allocator}
# Allocator {#InternalAllocator}

`Allocator` is a concept in RapidJSON:
~~~cpp
Expand Down Expand Up @@ -158,7 +158,7 @@ Note that `Malloc()` and `Realloc()` are member functions but `Free()` is static

Internally, it allocates chunks of memory from the base allocator (by default `CrtAllocator`) and stores the chunks as a singly linked list. When user requests an allocation, it allocates memory from the following order:

1. User supplied buffer if it is available. (See [User Buffer section in DOM](dom.md))
1. User supplied buffer if it is available. (See [User Buffer section in DOM](doc/dom.md))
2. If user supplied buffer is full, use the current memory chunk.
3. If the current block is full, allocate a new block of memory.

Expand Down
2 changes: 1 addition & 1 deletion doc/performance.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Performance

There is a [native JSON benchmark collection] [1] which evaluates speed, memory usage and code size of various operations among 20 JSON libaries.
There is a [native JSON benchmark collection] [1] which evaluates speed, memory usage and code size of various operations among 37 JSON libaries.

[1]: https://github.com/miloyip/nativejson-benchmark

Expand Down
2 changes: 1 addition & 1 deletion doc/performance.zh-cn.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 性能

有一个 [native JSON benchmark collection][1] 项目,能评估 20 个 JSON 库在不同操作下的速度、內存用量及代码大小。
有一个 [native JSON benchmark collection][1] 项目,能评估 37 个 JSON 库在不同操作下的速度、內存用量及代码大小。

[1]: https://github.com/miloyip/nativejson-benchmark

Expand Down
2 changes: 1 addition & 1 deletion doc/pointer.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pointer

## Status: experimental, shall be included in v1.1
(This feature was released in v1.1.0)

JSON Pointer is a standardized ([RFC6901]) way to select a value inside a JSON Document (DOM). This can be analogous to XPath for XML document. However, JSON Pointer is much simpler, and a single JSON Pointer only pointed to a single value.

Expand Down
2 changes: 1 addition & 1 deletion doc/pointer.zh-cn.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pointer

## 状态: 实验性,应该会合进 v1.1
(本功能于 v1.1.0 发布)

JSON Pointer 是一个标准化([RFC6901])的方式去选取一个 JSON Document(DOM)中的值。这类似于 XML 的 XPath。然而,JSON Pointer 简单得多,而且每个 JSON Pointer 仅指向单个值。

Expand Down
17 changes: 13 additions & 4 deletions doc/sax.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Note that, the default character type of `UTF16` is `wchar_t`. So this `reader`n

The third template parameter `Allocator` is the allocator type for internal data structure (actually a stack).

## Parsing {#Parsing}
## Parsing {#SaxParsing}

The one and only one function of `Reader` is to parse JSON.

Expand Down Expand Up @@ -244,7 +244,7 @@ Anyway, using `Writer` API is even simpler than generating a JSON by ad hoc meth
~~~~~~~~~~cpp
namespace rapidjson {

template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename Allocator = CrtAllocator<> >
template<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename Allocator = CrtAllocator<>, unsigned writeFlags = kWriteDefaultFlags>
class Writer {
public:
Writer(OutputStream& os, Allocator* allocator = 0, size_t levelDepth = kDefaultLevelDepth)
Expand All @@ -260,7 +260,16 @@ The `SourceEncoding` template parameter specifies the encoding to be used in `St
The `TargetEncoding` template parameter specifies the encoding in the output stream.
The last one, `Allocator` is the type of allocator, which is used for allocating internal data structure (a stack).
The `Allocator` is the type of allocator, which is used for allocating internal data structure (a stack).
The `writeFlags` are combination of the following bit-flags:
Parse flags | Meaning
------------------------------|-----------------------------------
`kWriteNoFlags` | No flag is set.
`kWriteDefaultFlags` | Default write flags. It is equal to macro `RAPIDJSON_WRITE_DEFAULT_FLAGS`, which is defined as `kWriteNoFlags`.
`kWriteValidateEncodingFlag` | Validate encoding of JSON strings.
`kWriteNanAndInfFlag` | Allow writing of `Infinity`, `-Infinity` and `NaN`.
Besides, the constructor of `Writer` has a `levelDepth` parameter. This parameter affects the initial memory allocated for storing information per hierarchy level.
Expand All @@ -278,7 +287,7 @@ A `Writer` can only output a single JSON, which can be any JSON type at the root
When a JSON is complete, the `Writer` cannot accept any new events. Otherwise the output will be invalid (i.e. having more than one root). To reuse the `Writer` object, user can call `Writer::Reset(OutputStream& os)` to reset all internal states of the `Writer` with a new output stream.
# Techniques {#Techniques}
# Techniques {#SaxTechniques}
## Parsing JSON to Custom Data Structure {#CustomDataStructure}
Expand Down
Loading

0 comments on commit f54b0e4

Please sign in to comment.