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

Public API for parsing CSS. More...

#include "donner/css/CSS.h"

Static Public Member Functions

static Stylesheet ParseStylesheet (std::string_view str)
 Parse a CSS stylesheet into a list of selectors and their associated declarations, which is wrapped into a Stylesheet object.
 
static std::vector< DeclarationParseStyleAttribute (std::string_view str)
 Parse a style="" attribute into a list of Declaration.
 
static std::optional< SelectorParseSelector (std::string_view str)
 Parse a CSS selector string into a Selector object, which can be used to implement querySelector and similar APIs.
 

Detailed Description

Public API for parsing CSS.

Member Function Documentation

◆ ParseSelector()

std::optional< Selector > donner::css::CSS::ParseSelector ( std::string_view str)
static

Parse a CSS selector string into a Selector object, which can be used to implement querySelector and similar APIs.

Parameters
strInput selector string, e.g. "svg > rect".
Returns
Parsed selector, or std::nullopt if the selector is invalid.

◆ ParseStyleAttribute()

std::vector< Declaration > donner::css::CSS::ParseStyleAttribute ( std::string_view str)
static

Parse a style="" attribute into a list of Declaration.

For example:

style="fill:red; stroke:blue"

Returns two declarations, one for fill and one for stroke.

Parameters
strInput style attribute string.
Returns
Parsed declarations.

◆ ParseStylesheet()

Stylesheet donner::css::CSS::ParseStylesheet ( std::string_view str)
static

Parse a CSS stylesheet into a list of selectors and their associated declarations, which is wrapped into a Stylesheet object.

Parameters
strInput stylesheet string.
Returns
Parsed stylesheet.

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