|
pjson 2.0.0
A small, owning JSON value for C++11
|
Configured, reusable JSON parser for DOM and SAX input. More...
#include <pjson_parser.h>
Classes | |
| struct | Error |
| Structured result for DOM and SAX parsing. More... | |
| struct | Options |
| Bounds parsing work and selects duplicate-key and number policies. More... | |
| struct | SaxHandler |
| Event sink for non-owning SAX parsing. More... | |
Public Member Functions | |
| pJsonParser (const Options &aOptions=Options()) | |
| Uses the default DOM allocator and default parser options. | |
| pJsonParser (pjson::Allocator &aAllocator, const Options &aOptions=Options()) | |
| Uses borrowed aAllocator, which must outlive this parser and its DOM results. | |
| ~pJsonParser () | |
| Releases the private parser configuration. | |
| pJsonParser (const pJsonParser &aOther) | |
| Copies the parser configuration while borrowing the same allocator. | |
| pJsonParser (pJsonParser &&aOther) noexcept | |
| Transfers parser configuration and leaves aOther usable with defaults. | |
| pJsonParser & | operator= (const pJsonParser &aOther) |
| Copies parser configuration while borrowing aOther's allocator. | |
| pJsonParser & | operator= (pJsonParser &&aOther) noexcept |
| Transfers parser configuration and leaves aOther usable with defaults. | |
| const Options & | options () const noexcept |
| Returns the immutable options used by every parse call. | |
| pjson::Allocator & | allocator () const noexcept |
| Returns the allocator used for DOM results. | |
| pjson | parse (const std::string &aInput) const |
| Parses one string document by value; failure returns JSON null. | |
| pjson | parse (const char *aInput, size_t aSize) const |
| Parses one exact byte span by value; failure returns JSON null. | |
| pjson | parse (const std::string &aInput, Error &aError) const |
| Parses one string document and resets/reports aError. | |
| pjson | parse (const char *aInput, size_t aSize, Error &aError) const |
| Parses one exact byte span and resets/reports aError. | |
| pjson | parseStream (std::istream &aInput) const |
| Buffers and parses one stream document by value. | |
| pjson | parseStream (std::istream &aInput, Error &aError) const |
| Buffers and parses one stream document and resets/reports aError. | |
| bool | parseSax (const std::string &aInput, SaxHandler &aHandler) const |
| Emits events for one string document. | |
| bool | parseSax (const char *aInput, size_t aSize, SaxHandler &aHandler) const |
| Emits events for one exact byte span. | |
| bool | parseSax (const std::string &aInput, SaxHandler &aHandler, Error &aError) const |
| Emits string-document events and resets/reports aError. | |
| bool | parseSax (const char *aInput, size_t aSize, SaxHandler &aHandler, Error &aError) const |
| Emits byte-span events and resets/reports aError. | |
| bool | parseSaxStream (std::istream &aInput, SaxHandler &aHandler) const |
| Incrementally emits events from a stream. | |
| bool | parseSaxStream (std::istream &aInput, SaxHandler &aHandler, Error &aError) const |
| Incrementally emits events from a stream and resets/reports aError. | |
Configured, reusable JSON parser for DOM and SAX input.
Configured parser that produces pjson values or SAX events.
The parser depends on the pjson DOM, while pjson itself has no parser dependency. A parser borrows its allocator, owns a copy of its options, and keeps no mutable per-call state, so it may be reused for many inputs.
pJsonParser is declared in <pjson_parser.h>. It owns parser options and borrows the selected pjson::Allocator, which must outlive the parser and all DOM values it creates. Parsing returns pjson by value. The parser stores no per-call mutable state and may be reused; callers must provide separate Error objects and SAX handlers for concurrent calls. The dependency is one-way: pJsonParser uses pjson, while the core pjson header and implementation do not include or call the parser.
Definition at line 15 of file pjson_parser.h.
Uses the default DOM allocator and default parser options.
|
explicit |
Uses borrowed aAllocator, which must outlive this parser and its DOM results.
| ByteDance::pJsonParser::~pJsonParser | ( | ) |
Releases the private parser configuration.
| ByteDance::pJsonParser::pJsonParser | ( | const pJsonParser & | aOther | ) |
Copies the parser configuration while borrowing the same allocator.
|
noexcept |
Transfers parser configuration and leaves aOther usable with defaults.
|
noexcept |
Returns the allocator used for DOM results.
| pJsonParser & ByteDance::pJsonParser::operator= | ( | const pJsonParser & | aOther | ) |
Copies parser configuration while borrowing aOther's allocator.
|
noexcept |
Transfers parser configuration and leaves aOther usable with defaults.
|
noexcept |
Returns the immutable options used by every parse call.
| pjson ByteDance::pJsonParser::parse | ( | const char * | aInput, |
| size_t | aSize | ||
| ) | const |
Parses one exact byte span by value; failure returns JSON null.
Parses one exact byte span and resets/reports aError.
| pjson ByteDance::pJsonParser::parse | ( | const std::string & | aInput | ) | const |
Parses one string document by value; failure returns JSON null.
Parses one string document and resets/reports aError.
| bool ByteDance::pJsonParser::parseSax | ( | const char * | aInput, |
| size_t | aSize, | ||
| SaxHandler & | aHandler | ||
| ) | const |
Emits events for one exact byte span.
| bool ByteDance::pJsonParser::parseSax | ( | const char * | aInput, |
| size_t | aSize, | ||
| SaxHandler & | aHandler, | ||
| Error & | aError | ||
| ) | const |
Emits byte-span events and resets/reports aError.
| bool ByteDance::pJsonParser::parseSax | ( | const std::string & | aInput, |
| SaxHandler & | aHandler | ||
| ) | const |
Emits events for one string document.
| bool ByteDance::pJsonParser::parseSax | ( | const std::string & | aInput, |
| SaxHandler & | aHandler, | ||
| Error & | aError | ||
| ) | const |
Emits string-document events and resets/reports aError.
| bool ByteDance::pJsonParser::parseSaxStream | ( | std::istream & | aInput, |
| SaxHandler & | aHandler | ||
| ) | const |
Incrementally emits events from a stream.
| bool ByteDance::pJsonParser::parseSaxStream | ( | std::istream & | aInput, |
| SaxHandler & | aHandler, | ||
| Error & | aError | ||
| ) | const |
Incrementally emits events from a stream and resets/reports aError.
| pjson ByteDance::pJsonParser::parseStream | ( | std::istream & | aInput | ) | const |
Buffers and parses one stream document by value.
Buffers and parses one stream document and resets/reports aError.