Skip to content

Commit

Permalink
Canonical flag name
Browse files Browse the repository at this point in the history
  • Loading branch information
xpahos committed Feb 12, 2020
1 parent 021e9fa commit 45bf580
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doc/dom.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Parse flags | Meaning
`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` and `-Infinity` as `double` values (relaxed JSON syntax).
`kParseEscapedApostrophe` | Allow escaped apostrophe in strings(relaxed JSON syntax).
`kParseEscapedApostropheFlag` | Allow escaped apostrophe in strings(relaxed JSON syntax).
By using a non-type template parameter, instead of a function parameter, C++ compiler can generate code which is optimized for specified combinations, improving speed, and reducing code size (if only using a single specialization). The downside is the flags needed to be determined in compile-time.
Expand Down
4 changes: 2 additions & 2 deletions include/rapidjson/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ enum ParseFlag {
kParseNumbersAsStringsFlag = 64, //!< Parse all numbers (ints/doubles) as strings.
kParseTrailingCommasFlag = 128, //!< Allow trailing commas at the end of objects and arrays.
kParseNanAndInfFlag = 256, //!< Allow parsing NaN, Inf, Infinity, -Inf and -Infinity as doubles.
kParseEscapedApostrophe = 512, //!< Allow escaped apostrophe in strings.
kParseEscapedApostropheFlag = 512, //!< Allow escaped apostrophe in strings.
kParseDefaultFlags = RAPIDJSON_PARSE_DEFAULT_FLAGS //!< Default parse flags. Can be customized by defining RAPIDJSON_PARSE_DEFAULT_FLAGS
};

Expand Down Expand Up @@ -1015,7 +1015,7 @@ class GenericReader {
is.Take();
os.Put(static_cast<typename TEncoding::Ch>(escape[static_cast<unsigned char>(e)]));
}
else if ((parseFlags & kParseEscapedApostrophe) && RAPIDJSON_LIKELY(e == '\'')) { // Allow escaped apostrophe
else if ((parseFlags & kParseEscapedApostropheFlag) && RAPIDJSON_LIKELY(e == '\'')) { // Allow escaped apostrophe
is.Take();
os.Put('\'');
}
Expand Down
2 changes: 1 addition & 1 deletion test/unittest/readertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,7 @@ TEST(Reader, EscapedApostrophe) {
{
StringStream s(json);
Reader reader;
ParseResult r = reader.Parse<kParseEscapedApostrophe>(s, h);
ParseResult r = reader.Parse<kParseEscapedApostropheFlag>(s, h);
EXPECT_FALSE(reader.HasParseError());
EXPECT_EQ(kParseErrorNone, r.Code());
EXPECT_EQ(0u, r.Offset());
Expand Down

0 comments on commit 45bf580

Please sign in to comment.