Donner 0.5.1
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::css::Declaration Struct Reference

A declaration is a CSS name/value pair, such as color: red;. More...

#include "donner/css/Declaration.h"

Collaboration diagram for donner::css::Declaration:
[legend]

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.
Declarationoperator= (const Declaration &other)=default
 Copy assignment operator.
Declarationoperator= (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< ComponentValuevalues
 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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ Declaration()

donner::css::Declaration::Declaration ( RcString name,
std::vector< ComponentValue > values = {},
const FileOffset & sourceOffset = FileOffset::Offset(0),
bool important = false )
inline

Construct a new Declaration object.

Parameters
nameName of the declaration.
valuesList of component values for the declaration.
sourceOffsetOffset of the declaration name in the source string.
importantWhether the declaration ends with !important.

Member Function Documentation

◆ toCssText()

std::string donner::css::Declaration::toCssText ( ) const

Serialize this declaration back to its CSS text representation, e.g.

fill: red.

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const Declaration & declaration )
friend

Output a human-readable representation of the declaration to a stream.

Parameters
osOutput stream.
declarationDeclaration to output.

Member Data Documentation

◆ sourceRange

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.


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