RapidJSON: rapidjson::GenericReader< SourceEncoding, TargetEncoding, StackAllocator > 模板类 参考

类 | Public 类型 | Public 成员函数 | Protected 成员函数 | 所有成员列表
rapidjson::GenericReader< SourceEncoding, TargetEncoding, StackAllocator > 模板类 参考

SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator. 更多...

`#include <reader.h>`

## Public 类型
typedef SourceEncoding::Ch | Ch
| SourceEncoding character type

## Public 成员函数
| GenericReader (StackAllocator *stackAllocator=0, size_t stackCapacity=kDefaultStackCapacity)
| Constructor. 更多...
template<unsigned parseFlags, typename InputStream , typename Handler >
ParseResult | Parse (InputStream &is, Handler &handler)
| Parse JSON text. 更多...
template<typename InputStream , typename Handler >
ParseResult | Parse (InputStream &is, Handler &handler)
| Parse JSON text (with kParseDefaultFlags) 更多...
void | IterativeParseInit ()
| Initialize JSON text token-by-token parsing
template<unsigned parseFlags, typename InputStream , typename Handler >
bool | IterativeParseNext (InputStream &is, Handler &handler)
| Parse one token from JSON text 更多...
RAPIDJSON_FORCEINLINE bool | IterativeParseComplete () const
| Check if token-by-token parsing JSON text is complete 更多...
bool | HasParseError () const
| Whether a parse error has occurred in the last parsing.
ParseErrorCode | GetParseErrorCode () const
| Get the ParseErrorCode of last parsing.
size_t | GetErrorOffset () const
| Get the position of last parsing error in input, 0 otherwise.

## Protected 成员函数
void | SetParseError (ParseErrorCode code, size_t offset)

## 详细描述

### template<typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>
class rapidjson::GenericReader< SourceEncoding, TargetEncoding, StackAllocator >

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.

模板参数

  SourceEncoding | Encoding of the input stream.
  TargetEncoding | Encoding of the parse output.
  StackAllocator | Allocator type for stack.

## 构造及析构函数说明

## ◆ GenericReader()

template<typename SourceEncoding , typename TargetEncoding , typename StackAllocator = CrtAllocator>

rapidjson::GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::GenericReader | ( | StackAllocator * | stackAllocator = `0`,
|  | size_t | stackCapacity = `kDefaultStackCapacity`
| ) |  |
| inline

Constructor.

参数

  stackAllocator | Optional allocator for allocating stack memory. (Only use for non-destructive parsing)
  stackCapacity | stack capacity in bytes for storing a single decoded string. (Only use for non-destructive parsing)

## 成员函数说明

## ◆ IterativeParseComplete()

template<typename SourceEncoding , typename TargetEncoding , typename StackAllocator = CrtAllocator>

RAPIDJSON_FORCEINLINE bool rapidjson::GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::IterativeParseComplete | ( |  | ) | const
| inline

Check if token-by-token parsing JSON text is complete

返回
  Whether the JSON has been fully decoded.

## ◆ IterativeParseNext()

template<typename SourceEncoding , typename TargetEncoding , typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream , typename Handler >

bool rapidjson::GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::IterativeParseNext | ( | InputStream & | is,
|  | Handler & | handler
| ) |  |
| inline

Parse one token from JSON text

模板参数

  InputStream | Type of input stream, implementing Stream concept
  Handler | Type of handler, implementing Handler concept.

参数

  is | Input stream to be parsed.
  handler | The handler to receive events.

返回
  Whether the parsing is successful.

## ◆ Parse() [1/2]

template<typename SourceEncoding , typename TargetEncoding , typename StackAllocator = CrtAllocator>
template<unsigned parseFlags, typename InputStream , typename Handler >

ParseResult rapidjson::GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::Parse | ( | InputStream & | is,
|  | Handler & | handler
| ) |  |
| inline

Parse JSON text.

模板参数

  parseFlags | Combination of ParseFlag.
  InputStream | Type of input stream, implementing Stream concept.
  Handler | Type of handler, implementing Handler concept.

参数

  is | Input stream to be parsed.
  handler | The handler to receive events.

返回
  Whether the parsing is successful.

## ◆ Parse() [2/2]

template<typename SourceEncoding , typename TargetEncoding , typename StackAllocator = CrtAllocator>
template<typename InputStream , typename Handler >

ParseResult rapidjson::GenericReader< SourceEncoding, TargetEncoding, StackAllocator >::Parse | ( | InputStream & | is,
|  | Handler & | handler
| ) |  |
| inline

Parse JSON text (with kParseDefaultFlags)

模板参数

  InputStream | Type of input stream, implementing Stream concept
  Handler | Type of handler, implementing Handler concept.

参数

  is | Input stream to be parsed.
  handler | The handler to receive events.

返回
  Whether the parsing is successful.

该类的文档由以下文件生成:

- include/rapidjson/fwd.h
- include/rapidjson/reader.h