|
|
Donner 0.5.1
Embeddable browser-grade SVG2 engine
|
A declaration is a CSS name/value pair, such as color: red;. More...
#include "donner/css/Declaration.h"
Public Member Functions | |
| Declaration (RcString name, std::vector< ComponentValue > values={}, const FileOffset &sourceOffset=FileOffset::Offset(0), bool important=false) | |
| Construct a new Declaration object. | |
| ~Declaration ()=default | |
| Destructor. | |
| Declaration (const Declaration &other)=default | |
| Copy constructor. | |
| Declaration (Declaration &&other) noexcept=default | |
| Move constructor. | |
| Declaration & | operator= (const Declaration &other)=default |
| Copy assignment operator. | |
| Declaration & | operator= (Declaration &&other) noexcept=default |
| Move assignment operator. | |
| bool | operator== (const Declaration &other) const =default |
| Equality operator. | |
| std::string | toCssText () const |
| Serialize this declaration back to its CSS text representation, e.g. | |
Public Attributes | |
| RcString | name |
| Name of the declaration. | |
| std::vector< ComponentValue > | values |
| List of component values for the declaration. | |
| FileOffset | sourceOffset |
| Offset of the declaration name in the source string. | |
| SourceRange | sourceRange |
| Source byte range of the declaration in the stylesheet or style="" attribute, from the first byte of the name to the offset of the last consumed value token. | |
| bool | important = false |
| Whether the declaration ends with !important. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Declaration &declaration) |
| Output a human-readable representation of the declaration to a stream. | |
A declaration is a CSS name/value pair, such as color: red;.
The name is a CSS identifier, and the value is a list of component values which can be parsed into higher-level constructs, such as a transform: transform: translate(10px, 20px);.
The important flag is set if the declaration ends with !important, and the tokens for !important are not included in the values list.
|
inline |
Construct a new Declaration object.
| name | Name of the declaration. |
| values | List of component values for the declaration. |
| sourceOffset | Offset of the declaration name in the source string. |
| important | Whether the declaration ends with !important. |
| std::string donner::css::Declaration::toCssText | ( | ) | const |
Serialize this declaration back to its CSS text representation, e.g.
fill: red.
|
friend |
Output a human-readable representation of the declaration to a stream.
| os | Output stream. |
| declaration | Declaration to output. |
| SourceRange donner::css::Declaration::sourceRange |
Source byte range of the declaration in the stylesheet or style="" attribute, from the first byte of the name to the offset of the last consumed value token.
For fill: red, sourceRange.start points at f and sourceRange.end points at r (the start of the last value token, not past its last byte). This is deliberately a best-effort approximation: structured-editing callers that need a byte-perfect end to splice into a style="" value can compute the trailing bound from the source text by scanning forward from sourceRange.end to the ;, closing brace, or end-of-input.
sourceRange.start == sourceRange.end means "no consumed value tokens" — either the parser failed partway, or the caller constructed the Declaration directly without going through DeclarationListParser.