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

Represents a paint server, which can be a solid color, a reference to another element, or a special value like "none" or "context-fill". More...

#include "donner/svg/properties/PaintServer.h"

Classes

struct  ContextFill
 Represents the "context-fill" value for a paint server. More...
 
struct  ContextStroke
 Represents the "context-stroke" value for a paint server. More...
 
struct  ElementReference
 Represents a reference to another element, which originates from a url() reference. Should point to another paint server. More...
 
struct  None
 Represents the "none" value for a paint server. More...
 
struct  Solid
 Represents a solid color paint server. More...
 

Public Types

using Type = std::variant<None, ContextFill, ContextStroke, Solid, ElementReference>
 Variant which can hold valid paint server types.
 

Public Member Functions

 PaintServer (Type value)
 Construct a paint server with the given value.
 
constexpr PaintServer (None)
 Construct a paint server with no value, None.
 
constexpr PaintServer (Solid solid)
 Construct a paint server for a solid color.
 
bool operator== (const PaintServer &other) const
 Equality operator.
 
template<typename T >
bool is () const
 Returns true if the paint server is of the requested type.
 
template<typename T >
T & get () &
 Returns the value of the paint server, if it is of the requested type.
 
template<typename T >
const T & get () const &
 Returns the value of the paint server, if it is of the requested type.
 
template<typename T >
T && get () &&
 Returns the value of the paint server, if it is of the requested type.
 

Public Attributes

Type value
 Current paint server.
 

Friends

std::ostream & operator<< (std::ostream &os, const PaintServer &paint)
 Ostream output operator.
 

Detailed Description

Represents a paint server, which can be a solid color, a reference to another element, or a special value like "none" or "context-fill".

Constructor & Destructor Documentation

◆ PaintServer()

donner::svg::PaintServer::PaintServer ( Type value)
inline

Construct a paint server with the given value.

Parameters
valueThe value of the paint server, one of the supported subtypes of PaintServer as listed by the Type variant.

Member Function Documentation

◆ get() [1/3]

template<typename T >
T & donner::svg::PaintServer::get ( ) &
inline

Returns the value of the paint server, if it is of the requested type.

Template Parameters
TThe type of the paint server to get.

◆ get() [2/3]

template<typename T >
T && donner::svg::PaintServer::get ( ) &&
inline

Returns the value of the paint server, if it is of the requested type.

Template Parameters
TThe type of the paint server to get.

◆ get() [3/3]

template<typename T >
const T & donner::svg::PaintServer::get ( ) const &
inline

Returns the value of the paint server, if it is of the requested type.

Template Parameters
TThe type of the paint server to get.

◆ is()

template<typename T >
bool donner::svg::PaintServer::is ( ) const
inline

Returns true if the paint server is of the requested type.

Template Parameters
TThe type of the paint server to check.

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