Base Framework
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Parser Class Reference

#include <base/string/Parser.h>

Inherited by JSON::JSONParser, and YAML::YAMLParser.

Public Member Functions

 Parser () noexcept
 
 Parser (const uint8 *_src, const uint8 *_end) noexcept
 
 Parser (const String &text) noexcept
 
const uint8 * getCurrent () const noexcept
 
MemorySize getAvailable () const noexcept
 
bool hasMore () const noexcept
 
uint8 peekByte () const
 
char peek () const
 
bool peek (char ch) const
 
void unwind ()
 
void skip ()
 
unsigned int getUCS4Bytes () const noexcept
 
ucs4 peekUCS4 () const
 
ucs4 readUCS4 ()
 
void read (ucs4 ch)
 
void skipUCS4 ()
 
unsigned int readDigit ()
 
unsigned int readDigits (unsigned int count)
 
unsigned int getNumberOfDigits () const noexcept
 
char read ()
 
void read (char ch)
 
void read (const char *text)
 
void skipJSONSpaces ()
 
void skipAny (const char *chars)
 

Static Public Member Functions

static bool doesMatchPattern (const String &pattern, const String &text) noexcept
 

Protected Attributes

const uint8 * src = nullptr
 
const uint8 * end = nullptr
 

Detailed Description

Parser.

Constructor & Destructor Documentation

◆ Parser() [1/3]

Parser::Parser ( )
inlinenoexcept

Constructs parser.

◆ Parser() [2/3]

Parser::Parser ( const uint8 *  _src,
const uint8 *  _end 
)
inlinenoexcept

Constructs parser.

◆ Parser() [3/3]

Parser::Parser ( const String text)
inlinenoexcept

Constructs parser.

Member Function Documentation

◆ doesMatchPattern()

static bool Parser::doesMatchPattern ( const String pattern,
const String text 
)
staticnoexcept

Returns true if the string matches the given pattern (using * and ?).

◆ getAvailable()

MemorySize Parser::getAvailable ( ) const
inlinenoexcept

Returns the available bytes.

◆ getCurrent()

const uint8* Parser::getCurrent ( ) const
inlinenoexcept

Returns the current marker.

◆ getNumberOfDigits()

unsigned int Parser::getNumberOfDigits ( ) const
inlinenoexcept

Returns the number of available digits.

◆ getUCS4Bytes()

unsigned int Parser::getUCS4Bytes ( ) const
noexcept

Returns the number of bytes in the next UTF-8 encoded char. Returns 0 for invalid encoding.

◆ hasMore()

bool Parser::hasMore ( ) const
inlinenoexcept

Returns true if more chars available.

◆ peek() [1/2]

char Parser::peek ( ) const
inline

Returns the next char without reading it.

◆ peek() [2/2]

bool Parser::peek ( char  ch) const
inline

Returns true if the next char is as expected without reading it.

◆ peekByte()

uint8 Parser::peekByte ( ) const
inline

Returns the next byte without reading it.

◆ peekUCS4()

ucs4 Parser::peekUCS4 ( ) const

Peeks the next UCS4 character.

◆ read() [1/4]

char Parser::read ( )
inline

Returns the next char.

◆ read() [2/4]

void Parser::read ( char  ch)
inline

Reads the given char.

◆ read() [3/4]

void Parser::read ( const char *  text)
inline

Reads the given text.

◆ read() [4/4]

void Parser::read ( ucs4  ch)
inline

Reads the given char.

◆ readDigit()

unsigned int Parser::readDigit ( )
inline

Reads a digit 0-9.

◆ readDigits()

unsigned int Parser::readDigits ( unsigned int  count)
inline

Reads n digits (up to 9).

◆ readUCS4()

ucs4 Parser::readUCS4 ( )

Returns the next UCS4 char assuming UTF8 encoding.

◆ skip()

void Parser::skip ( )
inline

Skip next char.

◆ skipAny()

void Parser::skipAny ( const char *  chars)
inline

Skip any of the given chars until no more.

◆ skipJSONSpaces()

void Parser::skipJSONSpaces ( )
inline

Skips JSON space.

◆ skipUCS4()

void Parser::skipUCS4 ( )
inline

Skips the next UTF-8 encoded character.

◆ unwind()

void Parser::unwind ( )
inline

Rewinds 1 byte.