Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::base::parser::IntegerParser Class Reference

Parser for positive integers, either decimal or hexadecimal. More...

#include "donner/base/parser/IntegerParser.h"

Classes

struct  Result
 Container for parse result, containing the parsed result and the number of characters that were consumed to parse it. More...
 

Static Public Member Functions

static ParseResult< ResultParse (std::string_view str)
 Parse a positive integer in decimal format.
 
static ParseResult< ResultParseHex (std::string_view str)
 Parse a positive integer in hexadecimal format, e.g.
 

Detailed Description

Parser for positive integers, either decimal or hexadecimal.


Class Documentation

◆ donner::base::parser::IntegerParser::Result

struct donner::base::parser::IntegerParser::Result

Container for parse result, containing the parsed result and the number of characters that were consumed to parse it.

Class Members
size_t consumedChars = 0 The number of characters of the input string that were consumed to parse the number.
uint32_t number = 0 The parsed result.

Member Function Documentation

◆ Parse()

ParseResult< IntegerParser::Result > donner::base::parser::IntegerParser::Parse ( std::string_view str)
static

Parse a positive integer in decimal format.

Parameters
strString to parse, not all characters may be consumed.
optionsParser options.
Returns
Result containing the number and the number of characters that were parsed.

◆ ParseHex()

ParseResult< IntegerParser::Result > donner::base::parser::IntegerParser::ParseHex ( std::string_view str)
static

Parse a positive integer in hexadecimal format, e.g.

'FFEE'. The input string should not start with a prefix (no '0x').

Parameters
strString to parse, not all characters may be consumed.
optionsParser options.
Returns
Result containing the number and the number of characters that were parsed.

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