Skip to content

Commit

Permalink
Remove an invalid Document::ParseInsitu() API
Browse files Browse the repository at this point in the history
  • Loading branch information
miloyip committed Apr 13, 2015
1 parent 35d0577 commit e7f1c6d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 32 deletions.
14 changes: 5 additions & 9 deletions doc/dom.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,29 +84,25 @@ template <typename InputStream>
GenericDocument& GenericDocument::ParseStream(InputStream& is);

// (4) In situ parsing
template <unsigned parseFlags, typename SourceEncoding>
GenericDocument& GenericDocument::ParseInsitu(Ch* str);

// (5) In situ parsing, using same Encoding of Document
template <unsigned parseFlags>
GenericDocument& GenericDocument::ParseInsitu(Ch* str);

// (6) In situ parsing, using default parse flags
// (5) In situ parsing, using default parse flags
GenericDocument& GenericDocument::ParseInsitu(Ch* str);

// (7) Normal parsing of a string
// (6) Normal parsing of a string
template <unsigned parseFlags, typename SourceEncoding>
GenericDocument& GenericDocument::Parse(const Ch* str);

// (8) Normal parsing of a string, using same Encoding of Document
// (7) Normal parsing of a string, using same Encoding of Document
template <unsigned parseFlags>
GenericDocument& GenericDocument::Parse(const Ch* str);

// (9) Normal parsing of a string, using default parse flags
// (8) Normal parsing of a string, using default parse flags
GenericDocument& GenericDocument::Parse(const Ch* str);
~~~~~~~~~~
The examples of [tutorial](doc/tutorial.md) uses (9) for normal parsing of string. The examples of [stream](doc/stream.md) uses the first three. *In situ* parsing will be described soon.
The examples of [tutorial](doc/tutorial.md) uses (8) for normal parsing of string. The examples of [stream](doc/stream.md) uses the first three. *In situ* parsing will be described soon.
The `parseFlags` are combination of the following bit-flags:
Expand Down
14 changes: 5 additions & 9 deletions doc/dom.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,29 +84,25 @@ template <typename InputStream>
GenericDocument& GenericDocument::ParseStream(InputStream& is);

// (4) 原位解析
template <unsigned parseFlags, typename SourceEncoding>
GenericDocument& GenericDocument::ParseInsitu(Ch* str);

// (5) 原位解析,使用Document的编码
template <unsigned parseFlags>
GenericDocument& GenericDocument::ParseInsitu(Ch* str);

// (6) 原位解析,使用缺省标志
// (5) 原位解析,使用缺省标志
GenericDocument& GenericDocument::ParseInsitu(Ch* str);

// (7) 正常解析一个字符串
// (6) 正常解析一个字符串
template <unsigned parseFlags, typename SourceEncoding>
GenericDocument& GenericDocument::Parse(const Ch* str);

// (8) 正常解析一个字符串,使用Document的编码
// (7) 正常解析一个字符串,使用Document的编码
template <unsigned parseFlags>
GenericDocument& GenericDocument::Parse(const Ch* str);

// (9) 正常解析一个字符串,使用缺省标志
// (8) 正常解析一个字符串,使用缺省标志
GenericDocument& GenericDocument::Parse(const Ch* str);
~~~~~~~~~~
[教程](tutorial.md)中的例使用(9)去正常解析字符串。而[流](stream.md)的例子使用前3个函数。我们将稍后介绍原位(*In situ*) 解析。
[教程](tutorial.md)中的例使用(8)去正常解析字符串。而[流](stream.md)的例子使用前3个函数。我们将稍后介绍原位(*In situ*) 解析。
`parseFlags`是以下位标置的组合:
Expand Down
17 changes: 3 additions & 14 deletions include/rapidjson/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -1770,34 +1770,23 @@ class GenericDocument : public GenericValue<Encoding, Allocator> {
//!@name Parse in-place from mutable string
//!@{

//! Parse JSON text from a mutable string (with Encoding conversion)
/*! \tparam parseFlags Combination of \ref ParseFlag.
\tparam SourceEncoding Transcoding from input Encoding
\param str Mutable zero-terminated string to be parsed.
\return The document itself for fluent API.
*/
template <unsigned parseFlags, typename SourceEncoding>
GenericDocument& ParseInsitu(Ch* str) {
GenericInsituStringStream<Encoding> s(str);
return ParseStream<parseFlags | kParseInsituFlag, SourceEncoding>(s);
}

//! Parse JSON text from a mutable string
/*! \tparam parseFlags Combination of \ref ParseFlag.
\param str Mutable zero-terminated string to be parsed.
\return The document itself for fluent API.
*/
template <unsigned parseFlags>
GenericDocument& ParseInsitu(Ch* str) {
return ParseInsitu<parseFlags, Encoding>(str);
GenericInsituStringStream<Encoding> s(str);
return ParseStream<parseFlags | kParseInsituFlag, SourceEncoding>(s);
}

//! Parse JSON text from a mutable string (with \ref kParseDefaultFlags)
/*! \param str Mutable zero-terminated string to be parsed.
\return The document itself for fluent API.
*/
GenericDocument& ParseInsitu(Ch* str) {
return ParseInsitu<kParseDefaultFlags, Encoding>(str);
return ParseInsitu<kParseDefaultFlags>(str);
}
//!@}

Expand Down

0 comments on commit e7f1c6d

Please sign in to comment.