All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Valuable::StyleValue::Component Class Reference

One part of StyleValue list, variant / tagged union type with some convertions. More...

#include <Valuable/StyleValue.hpp>

Public Member Functions

Radiant::Color asColor () const
 
float asFloat () const
 
int asInt () const
 
QByteArray asKeyword () const
 
QString asString () const
 
bool canConvert (StyleValue::ValueType t) const
 
 Component ()
 Create a null component.
 
 Component (float f, Attribute::ValueUnit unit=Attribute::VU_UNKNOWN)
 Create a floating point type with optional unit. More...
 
 Component (int i)
 Create a integer component. More...
 
 Component (const Radiant::Color &color)
 Create a color component. More...
 
 Component (const QString &string)
 Create a string component. More...
 
 Component (const QByteArray &keyword)
 Create a keyword component. More...
 
 Component (const Component &component)
 Make a copy of the component. More...
 
 Component (Component &&component)
 Move a component. More...
 
bool isNumber () const
 
Component & operator= (const Component &component)
 Make a copy of the component. More...
 
Component & operator= (Component &&component)
 Move a component. More...
 
bool operator== (const Component &v) const
 Compares two components, does no type conversions, types need to be exactly the same. More...
 
bool operator== (const QByteArray &str) const
 Compares this component string / keyword to the given bytearray. More...
 
Separator separator () const
 
void setSeparator (Separator separator)
 
ValueType type () const
 
const char * typeName () const
 
Attribute::ValueUnit unit () const
 
 ~Component ()
 Delete the component.
 

Detailed Description

One part of StyleValue list, variant / tagged union type with some convertions.

Constructor & Destructor Documentation

Valuable::StyleValue::Component::Component ( float  f,
Attribute::ValueUnit  unit = Attribute::VU_UNKNOWN 
)

Create a floating point type with optional unit.

Parameters
fvalue
unitunit of f
Valuable::StyleValue::Component::Component ( int  i)

Create a integer component.

Parameters
ivalue
Valuable::StyleValue::Component::Component ( const Radiant::Color &  color)

Create a color component.

Parameters
colorvalue
Valuable::StyleValue::Component::Component ( const QString &  string)

Create a string component.

Parameters
stringvalue
Valuable::StyleValue::Component::Component ( const QByteArray &  keyword)

Create a keyword component.

Parameters
keywordvalue
Valuable::StyleValue::Component::Component ( const Component &  component)

Make a copy of the component.

Parameters
componentcomponent to copy
Valuable::StyleValue::Component::Component ( Component &&  component)

Move a component.

Parameters
componentcomponent to move

Member Function Documentation

Radiant::Color Valuable::StyleValue::Component::asColor ( ) const
Returns
the component value as color, if the type is not color, prints an error and returns a default Radiant::Color()
float Valuable::StyleValue::Component::asFloat ( ) const
Returns
the component value as float, works with int and float types, otherwise prints an error and returns zero
int Valuable::StyleValue::Component::asInt ( ) const
Returns
the component value as integer, works with int and float types, otherwise prints an error and returns zero
QByteArray Valuable::StyleValue::Component::asKeyword ( ) const
Returns
the component value as keyword, works with string and keyword types, otherwise prints an error and returns a null bytearray
QString Valuable::StyleValue::Component::asString ( ) const
Returns
the component value as string, works with string and keyword types, otherwise prints an error and returns a null string
bool Valuable::StyleValue::Component::canConvert ( StyleValue::ValueType  t) const
Parameters
ttry to convert this component to this type
Returns
true if this component could be converted to type t
bool Valuable::StyleValue::Component::isNumber ( ) const
Returns
true if component is either int or float
Component& Valuable::StyleValue::Component::operator= ( const Component &  component)

Make a copy of the component.

Parameters
componentcomponent to copy
Returns
reference to this
Component& Valuable::StyleValue::Component::operator= ( Component &&  component)

Move a component.

Parameters
componentcomponent to move
Returns
reference to this
bool Valuable::StyleValue::Component::operator== ( const Component &  v) const

Compares two components, does no type conversions, types need to be exactly the same.

Parameters
vother component to compare to
Returns
true if components are identical
bool Valuable::StyleValue::Component::operator== ( const QByteArray &  str) const

Compares this component string / keyword to the given bytearray.

Parameters
strUTF-8 string
Returns
true if component string or keyword equals to str
Separator Valuable::StyleValue::Component::separator ( ) const
inline
Returns
separator token preceding this component in a StyleValue
void Valuable::StyleValue::Component::setSeparator ( Separator  separator)
inline
Parameters
separatornew separator
ValueType Valuable::StyleValue::Component::type ( ) const
inline
Returns
the type of the component
const char* Valuable::StyleValue::Component::typeName ( ) const
Returns
string representation of the type
Attribute::ValueUnit Valuable::StyleValue::Component::unit ( ) const
inline
Returns
component type, VU_UNKNOWN if the type is not a number