AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
ReaderContext Class Reference

JSON reader context. More...

#include <readerContext.hpp>

Inheritance diagram for ReaderContext:
Collaboration diagram for ReaderContext:

Public Member Functions

 ReaderContext ()=delete
 ReaderContext (const ReaderContext &context)=delete
 ReaderContext (ReaderContext &&context)=delete
 ReaderContext (std::istream &is, const anch::json::MappingOptions &options)
virtual ~ReaderContext () noexcept
char discard ()
void parseUnknown ()
bool next (char &current)
void back ()
void enterLevel ()
void leaveLevel () noexcept

Public Attributes

std::istream & input
anch::json::MappingOptions options
std::string pbuf
uint32_t offset
std::size_t bufferSize
char * buffer
std::size_t read
std::size_t depth

Protected Member Functions

virtual std::streamsize refillBuffer ()
void checkPayloadSize () const

Detailed Description

JSON reader context.

Context is used to store mapping options and deserialization buffers

Author
Vincent Lachenal
Since
0.1

Constructor & Destructor Documentation

◆ ReaderContext() [1/4]

Forbids ReaderContext default constructor

◆ ReaderContext() [2/4]

Forbids ReaderContext copy constructor

Parameters
contextthe context not to copy

◆ ReaderContext() [3/4]

Forbids ReaderContext move constructor

Parameters
contextthe context not to move

◆ ReaderContext() [4/4]

ReaderContext constructor

Parameters
isthe input stream to read
optionsthe mapping options to use
Exceptions
anch::json::MappingErrorinput is bigger than max_payload option

◆ ~ReaderContext()

virtual anch::json::ReaderContext::~ReaderContext ( )
virtualnoexcept

ReaderContext destructor
Delete buffers

Member Function Documentation

◆ back()

Go to previous character.

◆ checkPayloadSize()

Check that the number of read characters does not exceed max_payload option (when not 0 )

Exceptions
anch::json::MappingErrorinput is bigger than max_payload option

◆ discard()

Discard character until found undiscardable character or fail according to options

Returns
the next undiscardable character
Exceptions
anch::json::MappingErrorpotential overflow ...

◆ enterLevel()

Enter object or array: increment nesting depth.
Use DepthGuard to leave level automatically.

Exceptions
anch::json::MappingErrordepth is greater than max_depth option (when not 0 )

◆ leaveLevel()

Leave object or array: decrement nesting depth.

◆ next()

bool anch::json::ReaderContext::next ( char & current)

Get next character in buffer.
If buffer has reached its end, it will refill buffer with the input stream.

Parameters
currentthe character to write in
Returns
true if buffer end has been reached
Exceptions
anch::json::MappingErrorno more character available

◆ parseUnknown()

Parse unknown value or fail according to options

Exceptions
anch::json::MappingErrorunknown fields are not allowed or parsing error

◆ refillBuffer()

virtual std::streamsize anch::json::ReaderContext::refillBuffer ( )
protectedvirtual

Refill buffer from input stream

Returns
the number of read characters
Exceptions
anch::json::MappingErrorinput is bigger than max_payload option

Member Data Documentation

◆ buffer

Parser buffer

◆ bufferSize

Parser buffer size (default to 1024)

◆ depth

Current nesting depth of objects and arrays

◆ input

The input stream to parse

◆ offset

The current offset

◆ options

◆ pbuf

Primitive value buffer

◆ read

Global number of read characters


The documentation for this class was generated from the following file: