Orcus
Protected Types | Protected Member Functions | Protected Attributes | List of all members
orcus::parser_base Class Reference
Inheritance diagram for orcus::parser_base:
orcus::css::parser_base orcus::csv::parser_base orcus::json::parser_base orcus::sax::parser_base orcus::yaml::parser_base orcus::css_parser< _Handler > orcus::csv_parser< _Handler > orcus::json_parser< _Handler > orcus::sax_parser< _Handler, _Config > orcus::sax_parser< handler_wrapper > orcus::yaml_parser< _Handler >

Protected Types

using numeric_parser_type = std::function< double(const char *&, size_t)>
 

Protected Member Functions

 parser_base (const char *p, size_t n, bool transient_stream)
 
void set_numeric_parser (const numeric_parser_type &func)
 
bool transient_stream () const
 
bool has_char () const
 
bool has_next () const
 
void next (size_t inc=1)
 
void prev (size_t dec=1)
 
char cur_char () const
 
char next_char () const
 
void skip (const char *chars_to_skip, size_t n_chars_to_skip)
 
void skip_space_and_control ()
 
bool parse_expected (const char *expected, size_t n_expected)
 
double parse_double ()
 
size_t remaining_size () const
 
size_t available_size () const
 
std::ptrdiff_t offset () const
 

Protected Attributes

const char *const mp_begin
 
const char * mp_char
 
const char * mp_end
 
const bool m_transient_stream
 

Member Function Documentation

◆ available_size()

size_t orcus::parser_base::available_size ( ) const
inlineprotected

Determine the number of characters available from the current character to the end of the buffer. The current character is included.

Returns
number of characters available including the current character.

◆ offset()

std::ptrdiff_t orcus::parser_base::offset ( ) const
protected

Return the current offset from the beginning of the character stream.

Returns
current offset from the beginning of the character stream.

◆ parse_double()

double orcus::parser_base::parse_double ( )
protected

Try to parse the next characters as double, or return NaN in case of failure.

Returns
double value on success, or NaN on failure.

◆ parse_expected()

bool orcus::parser_base::parse_expected ( const char *  expected,
size_t  n_expected 
)
protected

Parse and check next characters to see if it matches specified character sequence.

Parameters
expectedsequence of characters to match against.
n_expectedlength of the character sequence.
Returns
true if it matches specified character sequence, false otherwise.

◆ remaining_size()

size_t orcus::parser_base::remaining_size ( ) const
protected

Determine the number of characters remaining after the current character. For instance, if the current character is on the last character in the stream, this method will return 0, whereas if it's on the first character, it will return the total length - 1.

Returns
number of characters remaining after the current character.

◆ skip_space_and_control()

void orcus::parser_base::skip_space_and_control ( )
protected

Skip all characters that are 0-32 in ASCII range