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

Parsers for shared data types such as NumberParser and LengthParser. More...

Classes

struct  FileOffset
 Error context for a failed parse, such as the error reason, line, and character offset. More...
 
class  LengthParser
 Parser for CSS <length-percentage> strings, such as "10px", "30%", "10em", etc. More...
 
class  LengthParserImpl
 Implementation of the LengthParser. More...
 
class  NumberParser
 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...
 
struct  ParseError
 Error context for a failed parse, such as the error reason, line, and character offset. More...
 
class  ParserBase
 Base class for parsers, containing common functionality such as maintaining the current parse location, skipping whitespace, and parsing numbers. More...
 
class  ParseResult
 A parser result, which may contain a result of type T, or an error, or both. More...
 

Functions

std::ostream & operator<< (std::ostream &os, const ParseError &error)
 Ostream output operator for ParseError, outputs the error message.
 
template<typename T >
void PrintTo (const ParseResult< T > &result, std::ostream *os)
 Outputs a ParseResult to a stream for debugging purposes.
 
 MATCHER (NoParseError, "")
 Matches if the result does not contain a ParseError.
 
 MATCHER_P (ParseErrorIs, errorMessageMatcher, "")
 Given a ParseResult, matches if it contains an error with the given message.
 
 MATCHER_P2 (ParseErrorPos, line, offset, "")
 Given a ParseResult, matches if it contains an error at the given offset.
 
 MATCHER (ParseErrorEndOfString, "")
 Matches if a ParseResult contains an error at the end of the string.
 
 MATCHER_P (ParseResultIs, resultMatcher, "")
 Matches if a ParseResult contains a result that matches the given value, and that it does not contain an error.
 
 MATCHER_P2 (ParseResultAndError, resultMatcher, errorMessageMatcher, "")
 Matches if a ParseResult contains a result that matches the given value, and that it does not contain an error.
 

Detailed Description

Parsers for shared data types such as NumberParser and LengthParser.

Function Documentation

◆ MATCHER_P() [1/2]

donner::base::parser::MATCHER_P ( ParseErrorIs ,
errorMessageMatcher ,
""  )

Given a ParseResult, matches if it contains an error with the given message.

Usage:

EXPECT_THAT(error, ParseErrorIs("My message"));
EXPECT_THAT(error, ParseErrorIs(StartsWith("Err")));
A parser result, which may contain a result of type T, or an error, or both.
Definition ParseResult.h:17
Parameters
errorMessageMatcherMessage to match with, either a string or a gmock matcher.

◆ MATCHER_P() [2/2]

donner::base::parser::MATCHER_P ( ParseResultIs ,
resultMatcher ,
""  )

Matches if a ParseResult contains a result that matches the given value, and that it does not contain an error.

Parameters
resultMatcherValue to match with.

◆ MATCHER_P2() [1/2]

donner::base::parser::MATCHER_P2 ( ParseErrorPos ,
line ,
offset ,
""  )

Given a ParseResult, matches if it contains an error at the given offset.

Parameters
lineLine number of the error.
offsetColumn offset of the error.

◆ MATCHER_P2() [2/2]

donner::base::parser::MATCHER_P2 ( ParseResultAndError ,
resultMatcher ,
errorMessageMatcher ,
""  )

Matches if a ParseResult contains a result that matches the given value, and that it does not contain an error.

Parameters
resultMatcherResult to match with.
errorMessageMatcherParse error message to match with, either a string or a gmock matcher.