Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::css::AnbValue Struct Reference

An+B microsyntax value, which is parsed by parser::AnbMicrosyntaxParser. More...

#include "donner/css/details/AnbValue.h"

Public Member Functions

int evaluate (int index) const noexcept
 Evaluate whether the given child index matches this An+B value.
 
bool operator== (const AnbValue &other) const noexcept=default
 Equality operator.
 

Public Attributes

int a = 0
 The 'a' value in the An+B microsyntax.
 
int b = 0
 The 'b' value in the An+B microsyntax.
 

Friends

std::ostream & operator<< (std::ostream &os, const AnbValue &value)
 Print to an output stream.
 

Detailed Description

An+B microsyntax value, which is parsed by parser::AnbMicrosyntaxParser.

For example, the arguments of :nth-child(4n+2) are parsed as an AnbValue with a = 4, and b = 2.

See also
https://www.w3.org/TR/css-syntax-3/#anb-microsyntax

Member Function Documentation

◆ evaluate()

int donner::css::AnbValue::evaluate ( int index) const
inlinenoexcept

Evaluate whether the given child index matches this An+B value.

For example, if this AnbValue represents 4n+2, then evaluate(2) would return true, but evaluate(3) would return false.

Parameters
indexA 1-based child index; evaluate(1) is the first child. If index is negative, evaluate returns false.

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