A CSS component value, which is either a token, or a parsed function or block.
More...
#include "donner/css/ComponentValue.h"
|
| | ComponentValue (Type &&value) |
| | Construct a new ComponentValue object, taking ownership of a Token.
|
|
| ~ComponentValue () |
| | Destructor.
|
|
| ComponentValue (const ComponentValue &)=default |
| | Copy constructor.
|
|
ComponentValue & | operator= (const ComponentValue &)=default |
| | Move constructor.
|
|
| ComponentValue (ComponentValue &&) noexcept=default |
| | Move assignment operator.
|
|
ComponentValue & | operator= (ComponentValue &&) noexcept=default |
| | Copy assignment operator.
|
|
bool | operator== (const ComponentValue &other) const |
| | Equality operator.
|
| template<typename T> |
| bool | is () const |
| | Check if the component value is of a given type.
|
| template<typename T> |
| bool | isToken () const |
| | Shorthand for checking if this component value holds a specific token.
|
| template<typename T> |
| const T * | tryGetToken () const |
| | Get the inner token value as a pointer, if the component value is a token and matches the requested type, or nullptr.
|
| template<typename T> |
| T & | get () & |
| | Get the component value as a reference.
|
| template<typename T> |
| const T & | get () const & |
| | Get the component value as a const-reference.
|
| template<typename T> |
| T && | get () && |
| | Get the component value as an rvalue-reference for move semantics.
|
| FileOffset | sourceOffset () const |
| | Get the offset of this component value in the original source.
|
|
|
Type | value |
| | The actual value of the component value.
|
|
| std::ostream & | operator<< (std::ostream &os, const ComponentValue &component) |
| | Output a human-readable representation of the component value to a stream.
|
A CSS component value, which is either a token, or a parsed function or block.
This is the second level of parsing, after Token. A Token is a single lexical unit, and ComponentValue groups those into logical function and block groups, as well as wrapping standalone Token.
ComponentValue is the base component traversed when parsing CSS into logical blocks, such as Selector and donner::svg::Property.
◆ ComponentValue()
◆ get() [1/3]
template<typename T>
| T & donner::css::ComponentValue::get |
( |
| ) |
& |
|
inline |
Get the component value as a reference.
Example usage:
block.
values.push_back(componentValue);
A CSS simple block, such as a rule block or a parenthesized expression.
Definition ComponentValue.h:62
std::vector< ComponentValue > values
List of component values inside the simple block.
Definition ComponentValue.h:70
- Template Parameters
-
- Precondition
- The component must be of the given type, i.e. is<T>() must be true.
◆ get() [2/3]
template<typename T>
| T && donner::css::ComponentValue::get |
( |
| ) |
&& |
|
inline |
Get the component value as an rvalue-reference for move semantics.
Example usage:
- Template Parameters
-
- Precondition
- The component must be of the given type, i.e. is<T>() must be true.
◆ get() [3/3]
template<typename T>
| const T & donner::css::ComponentValue::get |
( |
| ) |
const & |
|
inline |
Get the component value as a const-reference.
Example usage:
- Template Parameters
-
- Precondition
- The component must be of the given type, i.e. is<T>() must be true.
◆ is()
template<typename T>
| bool donner::css::ComponentValue::is |
( |
| ) |
const |
|
inline |
Check if the component value is of a given type.
For example:
- Template Parameters
-
- Returns
- True if the component value is of type T.
◆ isToken()
template<typename T>
| bool donner::css::ComponentValue::isToken |
( |
| ) |
const |
|
inline |
Shorthand for checking if this component value holds a specific token.
For example:
<percentage-token>, which represents a percentage such as '50'.
Definition Token.h:420
Which is equivalent to component.is<Token>() &&
component.get<Token>().is<Token::Percentage>().
- Template Parameters
-
◆ sourceOffset()
| FileOffset donner::css::ComponentValue::sourceOffset |
( |
| ) |
const |
|
inline |
Get the offset of this component value in the original source.
For Function and SimpleBlock, returns the offset of the group opening token.
◆ tryGetToken()
template<typename T>
| const T * donner::css::ComponentValue::tryGetToken |
( |
| ) |
const |
|
inline |
Get the inner token value as a pointer, if the component value is a token and matches the requested type, or nullptr.
See also Token::tryGet().
Example:
- Template Parameters
-
◆ operator<<
| std::ostream & operator<< |
( |
std::ostream & | os, |
|
|
const ComponentValue & | component ) |
|
friend |
Output a human-readable representation of the component value to a stream.
- Parameters
-
| os | Output stream. |
| component | Component value to output. |
The documentation for this struct was generated from the following files: