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

Parser for floating point numbers in SVG or CSS, corresponding to the CSS3 <number-token> definition from https://www.w3.org/TR/css-syntax-3/#number-token-diagram. More...

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

Classes

struct  Options
 Options to modify the parsing behavior. More...
 
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, Options options=Options())
 Parse an SVG number.
 

Detailed Description

Parser for floating point numbers in SVG or CSS, corresponding to the CSS3 <number-token> definition from https://www.w3.org/TR/css-syntax-3/#number-token-diagram.


Class Documentation

◆ donner::base::parser::NumberParser::Result

struct donner::base::parser::NumberParser::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.
double number = 0.0 The parsed result.

Member Function Documentation

◆ Parse()

ParseResult< NumberParser::Result > donner::base::parser::NumberParser::Parse ( std::string_view str,
Options options = Options() )
static

Parse an SVG number.

This corresponds from the CSS3 <number-token> production: https://www.w3.org/TR/css-syntax-3/#number-token-diagram

It contains:

  • Optionally a sign, '-' or '+'
  • Zero or more decimal digits followed by a dot '.', followed by zero or more decimal digits
  • Optionally, an exponent composed of 'e' or 'E' followed by an integer.
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: