dom.md (rapidjson-1.0.2) | : | dom.md (rapidjson-1.1.0) | ||
---|---|---|---|---|
skipping to change at line 118 | skipping to change at line 118 | |||
Parse flags | Meaning | Parse flags | Meaning | |||
------------------------------|----------------------------------- | ------------------------------|----------------------------------- | |||
`kParseNoFlags` | No flag is set. | `kParseNoFlags` | No flag is set. | |||
`kParseDefaultFlags` | Default parse flags. It is equal to macro `RAPID JSON_PARSE_DEFAULT_FLAGS`, which is defined as `kParseNoFlags`. | `kParseDefaultFlags` | Default parse flags. It is equal to macro `RAPID JSON_PARSE_DEFAULT_FLAGS`, which is defined as `kParseNoFlags`. | |||
`kParseInsituFlag` | In-situ(destructive) parsing. | `kParseInsituFlag` | In-situ(destructive) parsing. | |||
`kParseValidateEncodingFlag` | Validate encoding of JSON strings. | `kParseValidateEncodingFlag` | Validate encoding of JSON strings. | |||
`kParseIterativeFlag` | Iterative(constant complexity in terms of functi on call stack size) parsing. | `kParseIterativeFlag` | Iterative(constant complexity in terms of functi on call stack size) parsing. | |||
`kParseStopWhenDoneFlag` | After parsing a complete JSON root from stream, stop further processing the rest of stream. When this flag is used, parser will not generate `kParseErrorDocumentRootNotSingular` error. Using this flag for par sing multiple JSONs in the same stream. | `kParseStopWhenDoneFlag` | After parsing a complete JSON root from stream, stop further processing the rest of stream. When this flag is used, parser will not generate `kParseErrorDocumentRootNotSingular` error. Using this flag for par sing multiple JSONs in the same stream. | |||
`kParseFullPrecisionFlag` | Parse number in full precision (slower). If this flag is not set, the normal precision (faster) is used. Normal precision has ma ximum 3 [ULP](http://en.wikipedia.org/wiki/Unit_in_the_last_place) error. | `kParseFullPrecisionFlag` | Parse number in full precision (slower). If this flag is not set, the normal precision (faster) is used. Normal precision has ma ximum 3 [ULP](http://en.wikipedia.org/wiki/Unit_in_the_last_place) error. | |||
`kParseCommentsFlag` | Allow one-line `// ...` and multi-line `/* ... * | ||||
/` comments (relaxed JSON syntax). | ||||
`kParseNumbersAsStringsFlag` | Parse numerical type values as strings. | ||||
`kParseTrailingCommasFlag` | Allow trailing commas at the end of objects and | ||||
arrays (relaxed JSON syntax). | ||||
`kParseNanAndInfFlag` | Allow parsing `NaN`, `Inf`, `Infinity`, `-Inf` a | ||||
nd `-Infinity` as `double` values (relaxed JSON syntax). | ||||
By using a non-type template parameter, instead of a function parameter, C++ com piler can generate code which is optimized for specified combinations, improving speed, and reducing code size (if only using a single specialization). The down side is the flags needed to be determined in compile-time. | By using a non-type template parameter, instead of a function parameter, C++ com piler can generate code which is optimized for specified combinations, improving speed, and reducing code size (if only using a single specialization). The down side is the flags needed to be determined in compile-time. | |||
The `SourceEncoding` parameter defines what encoding is in the stream. This can be differed to the `Encoding` of the `Document`. See [Transcoding and Validation ](#TranscodingAndValidation) section for details. | The `SourceEncoding` parameter defines what encoding is in the stream. This can be differed to the `Encoding` of the `Document`. See [Transcoding and Validation ](#TranscodingAndValidation) section for details. | |||
And the `InputStream` is type of input stream. | And the `InputStream` is type of input stream. | |||
## Parse Error {#ParseError} | ## Parse Error {#ParseError} | |||
When the parse processing succeeded, the `Document` contains the parse results. When there is an error, the original DOM is *unchanged*. And the error state of parsing can be obtained by `bool HasParseError()`, `ParseErrorCode GetParseErro r()` and `size_t GetParseOffet()`. | When the parse processing succeeded, the `Document` contains the parse results. When there is an error, the original DOM is *unchanged*. And the error state of parsing can be obtained by `bool HasParseError()`, `ParseErrorCode GetParseErro r()` and `size_t GetParseOffset()`. | |||
Parse Error Code | Description | Parse Error Code | Description | |||
--------------------------------------------|----------------------------------- ---------------- | --------------------------------------------|----------------------------------- ---------------- | |||
`kParseErrorNone` | No error. | `kParseErrorNone` | No error. | |||
`kParseErrorDocumentEmpty` | The document is empty. | `kParseErrorDocumentEmpty` | The document is empty. | |||
`kParseErrorDocumentRootNotSingular` | The document root must not follow by other values. | `kParseErrorDocumentRootNotSingular` | The document root must not follow by other values. | |||
`kParseErrorValueInvalid` | Invalid value. | `kParseErrorValueInvalid` | Invalid value. | |||
`kParseErrorObjectMissName` | Missing a name for object member. | `kParseErrorObjectMissName` | Missing a name for object member. | |||
`kParseErrorObjectMissColon` | Missing a colon after a name of ob ject member. | `kParseErrorObjectMissColon` | Missing a colon after a name of ob ject member. | |||
`kParseErrorObjectMissCommaOrCurlyBracket` | Missing a comma or `}` after an ob ject member. | `kParseErrorObjectMissCommaOrCurlyBracket` | Missing a comma or `}` after an ob ject member. | |||
skipping to change at line 162 | skipping to change at line 166 | |||
Here shows an example of parse error handling. | Here shows an example of parse error handling. | |||
~~~~~~~~~~cpp | ~~~~~~~~~~cpp | |||
#include "rapidjson/document.h" | #include "rapidjson/document.h" | |||
#include "rapidjson/error/en.h" | #include "rapidjson/error/en.h" | |||
// ... | // ... | |||
Document d; | Document d; | |||
if (d.Parse(json).HasParseError()) { | if (d.Parse(json).HasParseError()) { | |||
fprintf(stderr, "\nError(offset %u): %s\n", | fprintf(stderr, "\nError(offset %u): %s\n", | |||
(unsigned)reader.GetErrorOffset(), | (unsigned)d.GetErrorOffset(), | |||
GetParseError_En(reader.GetParseErrorCode())); | GetParseError_En(d.GetParseError())); | |||
// ... | // ... | |||
} | } | |||
~~~~~~~~~~ | ~~~~~~~~~~ | |||
## In Situ Parsing {#InSituParsing} | ## In Situ Parsing {#InSituParsing} | |||
From [Wikipedia](http://en.wikipedia.org/wiki/In_situ): | From [Wikipedia](http://en.wikipedia.org/wiki/In_situ): | |||
> *In situ* ... is a Latin phrase that translates literally to "on site" or "in position". It means "locally", "on site", "on the premises" or "in place" to des cribe an event where it takes place, and is used in many different contexts. | > *In situ* ... is a Latin phrase that translates literally to "on site" or "in position". It means "locally", "on site", "on the premises" or "in place" to des cribe an event where it takes place, and is used in many different contexts. | |||
> ... | > ... | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 10 lines changed or added |