JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
Loading...
Searching...
No Matches

A simple parser for certain CSS subsets. More...

#include <jkqtpcsstools.h>

Collaboration diagram for JKQTPCSSParser:
[legend]

Classes

struct  GeneralError
 
struct  NumberWithUnit
 encodes a number with its unit, e.g. 100% or 45deg or ... More...
 
struct  RawErrorTag_t
 
struct  Token
 
struct  UnconvertobleError
 Exception when a string cannot be converted properly. More...
 
struct  UnexpectedTermError
 Exception for unexpected Term. More...
 
struct  UnexpectedTokenError
 Exception for unexpected Token. More...
 
struct  WrongNumberOfArgumentError
 Exception for wrong number of function arguments. More...
 

Static Public Member Functions

static QColor readColor (const QString &prog)
 parses the given expression, which should represent a color (incl. color-functions like rgb() )
 
static QGradient readGradient (const QString &prog)
 parses the given expression, which should represent a QGradient
 
static NumberWithUnit readNumberWithUnit (const QString &prog)
 parses the given expression
 

Protected Member Functions

 JKQTPCSSParser (const QString &text)
 class constructor
 
Parser
JKQTPExpected< JKQTPCSSParser::NumberWithUnit, JKQTPCSSParser::GeneralErrorparseNumberWithUnit (bool get)
 parses a number with unit
 
JKQTPExpected< QColor, JKQTPCSSParser::GeneralErrorparseColor (bool get)
 parses a color definition <color>
 
JKQTPExpected< QGradient, JKQTPCSSParser::GeneralErrorparseGradient (bool get)
 parses a color definition <gradient>
 

Static Protected Attributes

Error Handling <br>
static RawErrorTag_t RawErrorTag
 

Tokenizer

Token CurrentToken
 the current token while parsing a string
 
QString text
 this stream is used to read in the program. An object is created and assigned (and destroyed) by the parse()-function
 
int pos
 current reading position in text
 
Token peekNextToken (int *endPos=nullptr)
 Tokenizer: look at the next token from the input, but don't set it as CurrentToken and don't move the read pointer pos.
 
Token getToken ()
 Tokenizer: extract the next token from the input.
 
bool textAtEnd () const
 indicates whether pos points to the end of text
 
bool getCh (QChar &ch)
 
bool peekCh (QChar &ch)
 
void putBackCh ()
 

Detailed Description

A simple parser for certain CSS subsets.

EBNF definition of the parsed expressions

<lingradient>         -> linear-gradient( <angle>? , <gradientstops> )
<angle>               -> <numberwithunit>
                       | to (left|right|bottom|top) (left|right|bottom|top)?
<numberwithunit>      -> <number> [A-Za-z%]*
<gradientstops>       -> <gradientstop> | <gradientstop> , <gradientstops>
<gradientstop>        -> <color> (<number>%)?
<color>               -> NAME
                       | #<hexnumber>
                       | (rgb | rgba | hsl | hsv | gray | grey | red | green | blue) ( (<numberwithunit> [,/]? ){1-4} )

<number>              -> floating-point-number, i.e.  "[+-]?\d+\.?\d*"
<hexnumber>           -> RGB | RRGGBB | RGBA | RRGGBBAA

Class Documentation

◆ JKQTPCSSParser::RawErrorTag_t

struct JKQTPCSSParser::RawErrorTag_t

Constructor & Destructor Documentation

◆ JKQTPCSSParser()

JKQTPCSSParser::JKQTPCSSParser ( const QString &  text)
protected

class constructor

\note This also registers all standatd functions and constants by calling     addStandardFunctions() and addStandardVariables()

Member Function Documentation

◆ getCh()

bool JKQTPCSSParser::getCh ( QChar &  ch)
inlineprotected

◆ getToken()

Token JKQTPCSSParser::getToken ( )
protected

Tokenizer: extract the next token from the input.

◆ parseColor()

JKQTPExpected< QColor, JKQTPCSSParser::GeneralError > JKQTPCSSParser::parseColor ( bool  get)
protected

parses a color definition <color>

◆ parseGradient()

JKQTPExpected< QGradient, JKQTPCSSParser::GeneralError > JKQTPCSSParser::parseGradient ( bool  get)
protected

parses a color definition <gradient>

◆ parseNumberWithUnit()

JKQTPExpected< JKQTPCSSParser::NumberWithUnit, JKQTPCSSParser::GeneralError > JKQTPCSSParser::parseNumberWithUnit ( bool  get)
protected

parses a number with unit

◆ peekCh()

bool JKQTPCSSParser::peekCh ( QChar &  ch)
inlineprotected

◆ peekNextToken()

Token JKQTPCSSParser::peekNextToken ( int *  endPos = nullptr)
protected

Tokenizer: look at the next token from the input, but don't set it as CurrentToken and don't move the read pointer pos.

◆ putBackCh()

void JKQTPCSSParser::putBackCh ( )
inlineprotected

◆ readColor()

static QColor JKQTPCSSParser::readColor ( const QString &  prog)
static

parses the given expression, which should represent a color (incl. color-functions like rgb() )

◆ readGradient()

static QGradient JKQTPCSSParser::readGradient ( const QString &  prog)
static

parses the given expression, which should represent a QGradient

◆ readNumberWithUnit()

static NumberWithUnit JKQTPCSSParser::readNumberWithUnit ( const QString &  prog)
static

parses the given expression

◆ textAtEnd()

bool JKQTPCSSParser::textAtEnd ( ) const
inlineprotected

indicates whether pos points to the end of text

Member Data Documentation

◆ CurrentToken

Token JKQTPCSSParser::CurrentToken
protected

the current token while parsing a string

◆ pos

int JKQTPCSSParser::pos
protected

current reading position in text

◆ RawErrorTag

RawErrorTag_t JKQTPCSSParser::RawErrorTag
staticprotected

◆ text

QString JKQTPCSSParser::text
protected

this stream is used to read in the program. An object is created and assigned (and destroyed) by the parse()-function


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