|
template<unsigned parseFlags, typename Stream , typename Handler > |
void | ParseObject (Stream &stream, Handler &handler) |
|
template<unsigned parseFlags, typename Stream , typename Handler > |
void | ParseArray (Stream &stream, Handler &handler) |
|
template<unsigned parseFlags, typename Stream , typename Handler > |
void | ParseNaNNull_ (Stream &stream, Handler &handler) |
|
template<unsigned parseFlags, typename Stream , typename Handler > |
void | ParseInfinity (Stream &stream, Handler &handler) |
|
template<unsigned parseFlags, typename Stream , typename Handler > |
void | ParseTrue (Stream &stream, Handler &handler) |
|
template<unsigned parseFlags, typename Stream , typename Handler > |
void | ParseFalse (Stream &stream, Handler &handler) |
|
template<typename Stream > |
unsigned | ParseHex4 (Stream &stream) |
|
template<class Ch > |
std::enable_if< to_int(std::numeric_limits< Ch >::max())< to_int(256), bool >::type characterOk(Ch) { return true;} template< class Ch > typename std::enable_if< to_int(std::numeric_limits< Ch >::max()) >=to_int(256), bool >::type | characterOk (Ch c) |
|
template<unsigned parseFlags, typename Stream , typename Handler > |
void | ParseString (Stream &stream, Handler &handler) |
|
template<unsigned parseFlags, typename Stream , typename Handler > |
void | ParseNumber (Stream &stream, Handler &handler) |
|
template<unsigned parseFlags, typename Stream , typename Handler > |
void | ParseValue (Stream &stream, Handler &handler) |
|
template<typename Encoding, typename Allocator = MemoryPoolAllocator<>>
class rapidjson::GenericReader< Encoding, Allocator >
SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.
GenericReader parses JSON text from a stream, and send events synchronously to an object implementing Handler concept.
It needs to allocate a stack for storing a single decoded string during non-destructive parsing.
For in-situ parsing, the decoded string is directly written to the source text string, no temporary buffer is required.
A GenericReader object can be reused for parsing multiple JSON text.
- Template Parameters
-
Encoding | Encoding of both the stream and the parse output. |
Allocator | Allocator type for stack. |
template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
template<unsigned parseFlags, typename Stream , typename Handler >
Parse JSON text.
- Template Parameters
-
parseFlags | Combination of ParseFlag. |
Stream | Type of input stream. |
Handler | Type of handler which must implement Handler concept. |
- Parameters
-
stream | Input stream to be parsed. |
handler | The handler to receive events. |
- Returns
- Whether the parsing is successful.
230 #pragma warning(push)
231 #pragma warning(disable : 4611)
243 if (stream.Peek() ==
'\0')
246 switch (stream.Peek()) {
247 case '{': ParseObject<parseFlags>(stream, handler);
break;
248 case '[': ParseArray<parseFlags>(stream, handler);
break;
253 if (stream.Peek() !=
'\0' && stream.Peek() !=
static_cast<Ch>(std::char_traits<Ch>::eof()))
jmp_buf jmpbuf_
setjmp buffer for fast exit from nested parsing function calls.
Definition: reader.h:734
Encoding::Ch Ch
Definition: reader.h:208
void SkipWhitespace(Stream &stream)
Skip the JSON white spaces in a stream.
Definition: reader.h:105
#define RAPIDJSON_PARSE_ERROR(msg, offset)
Definition: reader.h:29
References rapidjson::GenericReader< Encoding, Allocator >::errorOffset_, rapidjson::GenericReader< Encoding, Allocator >::jmpbuf_, rapidjson::GenericReader< Encoding, Allocator >::parseError_, RAPIDJSON_PARSE_ERROR, rapidjson::SkipWhitespace(), and rapidjson::GenericReader< Encoding, Allocator >::stack_.
template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
template<unsigned parseFlags, typename Stream , typename Handler >
540 if (
s.Peek() ==
'-') {
547 bool try64bit =
false;
548 if (
s.Peek() ==
'0') {
552 else if (
s.Peek() >=
'1' &&
s.Peek() <=
'9') {
556 while (
s.Peek() >=
'0' &&
s.Peek() <=
'9') {
557 if (
i >= 214748364) {
558 if (
i != 214748364 ||
s.Peek() >
'8') {
563 i =
i * 10 + (
s.Take() -
'0');
566 while (
s.Peek() >=
'0' &&
s.Peek() <=
'9') {
567 if (
i >= 429496729) {
568 if (
i != 429496729 ||
s.Peek() >
'5') {
573 i =
i * 10 + (
s.Take() -
'0');
583 bool useDouble =
false;
587 while (
s.Peek() >=
'0' &&
s.Peek() <=
'9') {
588 if (i64 >= 922337203685477580uLL)
589 if (i64 != 922337203685477580uLL ||
s.Peek() >
'8') {
593 i64 = i64 * 10 + (
s.Take() -
'0');
596 while (
s.Peek() >=
'0' &&
s.Peek() <=
'9') {
597 if (i64 >= 1844674407370955161uLL)
598 if (i64 != 1844674407370955161uLL ||
s.Peek() >
'5') {
602 i64 = i64 * 10 + (
s.Take() -
'0');
610 while (
s.Peek() >=
'0' &&
s.Peek() <=
'9') {
615 d = d * 10 + (
s.Take() -
'0');
621 if (
s.Peek() ==
'.') {
623 d = try64bit ? (
double)i64 : (
double)
i;
628 if (
s.Peek() >=
'0' &&
s.Peek() <=
'9') {
629 d = d * 10 + (
s.Take() -
'0');
637 while (
s.Peek() >=
'0' &&
s.Peek() <=
'9') {
639 d = d * 10 + (
s.Peek() -
'0');
648 if (
s.Peek() ==
'e' ||
s.Peek() ==
'E') {
650 d = try64bit ? (
double)i64 : (
double)
i;
655 bool expMinus =
false;
658 else if (
s.Peek() ==
'-') {
663 if (
s.Peek() >=
'0' &&
s.Peek() <=
'9') {
664 exp =
s.Take() -
'0';
665 while (
s.Peek() >=
'0' &&
s.Peek() <=
'9') {
666 exp =
exp * 10 + (
s.Take() -
'0');
669 std::stringstream ss;
670 ss.precision( std::numeric_limits<double>::max_digits10 );
676 if( std::fpclassify( dd ) == FP_SUBNORMAL )
677 handler.Double( dd );
697 handler.Double(minus ? -d : d);
708 handler.Int(-(
int)
i);
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 exp(const bfloat16 &a)
Definition: BFloat16.h:615
std::int64_t int64_t
Definition: Meta.h:43
std::uint64_t uint64_t
Definition: Meta.h:42
double Pow10(int n)
Computes integer powers of 10 in double (10.0^n).
Definition: pow10.h:12
References Eigen::bfloat16_impl::exp(), i, rapidjson::internal::Pow10(), RAPIDJSON_PARSE_ERROR, and s.
template<typename Encoding , typename Allocator = MemoryPoolAllocator<>>
template<unsigned parseFlags, typename Stream , typename Handler >
439 #define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
441 Z16,
Z16, 0, 0,
'\"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
'/',
442 Z16,
Z16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
'\\', 0, 0, 0,
443 0, 0,
'\b', 0, 0, 0,
'\f', 0, 0, 0, 0, 0, 0, 0,
'\n', 0,
444 0, 0,
'\r', 0,
'\t', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
459 #define RAPIDJSON_PUT(x) \
461 if (parseFlags & kParseInsituFlag) \
464 *stack_.template Push<Ch>() = x; \
477 if (codepoint >= 0xD800 && codepoint <= 0xDBFF) {
478 if (
s.Take() !=
'\\' ||
s.Take() !=
'u') {
483 if (codepoint2 < 0xDC00 || codepoint2 > 0xDFFF) {
487 codepoint = (((codepoint - 0xD800) << 10) | (codepoint2 - 0xDC00)) + 0x10000;
491 SizeType count =
SizeType(Encoding::Encode(buffer, codepoint) - &buffer[0]);
497 memcpy(
stack_.template Push<Ch>(count), buffer, count *
sizeof(
Ch));
508 size_t length =
s.PutEnd(head);
511 handler.String(head,
SizeType(length),
false);
515 handler.String(
stack_.template Pop<Ch>(len), len - 1,
true);
520 else if (
c ==
'\0') {
524 else if ((
unsigned)
c < 0x20) {
static void escape(void *p)
Definition: BenchTimer.h:30
Array< double, 1, 3 > e(1./3., 0.5, 2.)
unsigned ParseHex4(Stream &stream)
Definition: reader.h:384
std::enable_if< to_int(std::numeric_limits< Ch >::max())< to_int(256), bool >::type characterOk(Ch) { return true;} template< class Ch > typename std::enable_if< to_int(std::numeric_limits< Ch >::max()) >=to_int(256), bool >::type characterOk(Ch c)
Definition: reader.h:432
@ kParseInsituFlag
In-situ(destructive) parsing.
Definition: reader.h:44
References calibrate::c, rapidjson::GenericReader< Encoding, Allocator >::characterOk(), e(), escape(), i, rapidjson::kParseInsituFlag, rapidjson::GenericReader< Encoding, Allocator >::ParseHex4(), RAPIDJSON_ASSERT, RAPIDJSON_PARSE_ERROR, RAPIDJSON_PUT, s, rapidjson::GenericReader< Encoding, Allocator >::stack_, and Z16.