CSS attribute value is a list of variant components. More...
#include <Valuable/StyleValue.hpp>
Classes | |
| class | Component |
| One part of StyleValue list, variant / tagged union type with some convertions. More... | |
Public Types | |
| typedef QList< Component > | ComponentList |
| enum | Separator { SEPARATOR_WHITE_SPACE, SEPARATOR_COMMA, SEPARATOR_SLASH } |
| A separator between components. More... | |
| enum | ValueType { TYPE_NONE, TYPE_FLOAT, TYPE_INT, TYPE_COLOR, TYPE_STRING, TYPE_KEYWORD } |
| Component variant type. More... | |
Public Member Functions | |
| void | append (const StyleValue &v) |
| Concatenates another StyleValue to this object. More... | |
| void | append (const StyleValue &v, Separator separator) |
| Concatenates another StyleValue to this object with given separator. More... | |
| void | append (const Component &c) |
| Appends one component to end of this StyleValue. More... | |
| void | append (const Component &c, Separator separator) |
| Appends one component to end of this StyleValue with given separator. More... | |
| Radiant::Color | asColor (int idx=0) const |
| float | asFloat (int idx=0) const |
| int | asInt (int idx=0) const |
| QByteArray | asKeyword (int idx=0) const |
| QMap< QString, QString > | asMap () const |
| CSS value "aaa bbb, ccc ddd eee, fff" will be converted to map: "aaa" => "bbb", "ccc" => "ddd eee", "fff" => "". More... | |
| QString | asString (int idx=0) const |
| const ComponentList & | components () const |
| bool | isEmpty () const |
| bool | isNumber (int idx=0) const |
| bool | isUniform () const |
| In uniform StyleValue all components have same separators and types that can be converted to each other. More... | |
| bool | operator!= (const StyleValue &v) const |
| Checks if StyleValue objects are different. More... | |
| bool | operator== (const StyleValue &v) const |
| Checks if StyleValue objects are identical. More... | |
| const Component & | operator[] (int idx) const |
| Access one component in the StyleValue. More... | |
| int | size () const |
| QList< StyleValue > | split (Separator sep) const |
| Splits StyleValue to parts with a separator. More... | |
| QString | stringify () const |
| StyleValue () | |
| Creates an empty StyleValue. | |
| StyleValue (float v, Attribute::ValueUnit unit=Attribute::VU_UNKNOWN) | |
| Creates a new StyleValue with one float component. More... | |
| StyleValue (int v) | |
| Creates a new StyleValue with one int component. More... | |
| StyleValue (const Radiant::Color &color) | |
| Creates a new StyleValue with one color component. More... | |
| StyleValue (const QString &string) | |
| Creates a new StyleValue with one string component. More... | |
| StyleValue (const QByteArray &keyword) | |
| Creates a new StyleValue with one keyword component. More... | |
| StyleValue (const Component &component) | |
| Creates a new StyleValue with one component. More... | |
| StyleValue (const QMap< QString, QString > &map) | |
| Shorthand constructor for creating a StyleValue from a map. More... | |
| ValueType | type (int idx=0) const |
| Attribute::ValueUnit | unit (int idx=0) const |
| ~StyleValue () | |
| Deletes StyleValue and its components. | |
CSS attribute value is a list of variant components.
StyleValue is the part between ':' and ';' in CSS, example: background: "image.png" top left; This value is a list of three components, one string and two keywords. CSS parser will generate a StyleValue instance from a value in CSS declaration.
Component variant type.
| Valuable::StyleValue::StyleValue | ( | float | v, |
| Attribute::ValueUnit | unit = Attribute::VU_UNKNOWN |
||
| ) |
Creates a new StyleValue with one float component.
| v | float value |
| unit | unit of v |
| Valuable::StyleValue::StyleValue | ( | int | v | ) |
Creates a new StyleValue with one int component.
| v | int value |
| Valuable::StyleValue::StyleValue | ( | const Radiant::Color & | color | ) |
Creates a new StyleValue with one color component.
| color | color value |
| Valuable::StyleValue::StyleValue | ( | const QString & | string | ) |
Creates a new StyleValue with one string component.
| string | string value |
| Valuable::StyleValue::StyleValue | ( | const QByteArray & | keyword | ) |
Creates a new StyleValue with one keyword component.
| keyword | keyword value |
| Valuable::StyleValue::StyleValue | ( | const Component & | component | ) |
Creates a new StyleValue with one component.
| component | component to add to the new StyleValue |
| Valuable::StyleValue::StyleValue | ( | const QMap< QString, QString > & | map | ) |
Shorthand constructor for creating a StyleValue from a map.
| map | map that is converted to StyleValue, see asMap() for exact format |
| void Valuable::StyleValue::append | ( | const StyleValue & | v | ) |
Concatenates another StyleValue to this object.
| v | StyleValue to append |
| void Valuable::StyleValue::append | ( | const StyleValue & | v, |
| Separator | separator | ||
| ) |
Concatenates another StyleValue to this object with given separator.
| v | StyleValue to append |
| separator | separator to use between this and v |
| void Valuable::StyleValue::append | ( | const Component & | c | ) |
Appends one component to end of this StyleValue.
| c | component to append |
Appends one component to end of this StyleValue with given separator.
| c | component to append |
| separator | separator to use between this and c |
| int Valuable::StyleValue::asInt | ( | int | idx = 0 | ) | const |
| QMap<QString, QString> Valuable::StyleValue::asMap | ( | ) | const |
CSS value "aaa bbb, ccc ddd eee, fff" will be converted to map: "aaa" => "bbb", "ccc" => "ddd eee", "fff" => "".
|
inline |
| bool Valuable::StyleValue::isEmpty | ( | ) | const |
| bool Valuable::StyleValue::isNumber | ( | int | idx = 0 | ) | const |
| idx | index of the value in the list |
| bool Valuable::StyleValue::isUniform | ( | ) | const |
In uniform StyleValue all components have same separators and types that can be converted to each other.
Empty StyleValue is also uniform type.
|
inline |
Checks if StyleValue objects are different.
| v | other StyleValue object |
| bool Valuable::StyleValue::operator== | ( | const StyleValue & | v | ) | const |
Checks if StyleValue objects are identical.
| v | other StyleValue object |
| const Component& Valuable::StyleValue::operator[] | ( | int | idx | ) | const |
Access one component in the StyleValue.
| idx | 0 <= idx < size() |
| int Valuable::StyleValue::size | ( | ) | const |
| QList<StyleValue> Valuable::StyleValue::split | ( | Separator | sep | ) | const |
Splits StyleValue to parts with a separator.
| sep | separator that marks the points where to split |
| QString Valuable::StyleValue::stringify | ( | ) | const |