#include <OpenGUI_Value.h>
Each Value has a stored value of ValueType as well as the option to carry a string based Name.
Public Types | |
| T_STRING = 0 | |
| String value type. | |
| T_BOOL = 1 | |
| Boolean value type. | |
| T_FLOAT = 2 | |
| Float value type. | |
| T_FVECTOR2 = 3 | |
| FVector2 value type. | |
| T_FRECT = 4 | |
| FRect value type. | |
| T_INTEGER = 5 | |
| Integer value type. | |
| T_IVECTOR2 = 6 | |
| IVector2 value type. | |
| T_IRECT = 7 | |
| IRect value type. | |
| T_COLOR = 8 | |
| Color value type. | |
| T_FONT = 9 | |
| Font value type. | |
| T_TEXTALIGNMENT = 10 | |
| TextAlignment value type. | |
| T_IMAGERY = 11 | |
| ImageryPtr value type. | |
| T_FACE = 12 | |
| FacePtr value type. | |
| T_CURSOR = 13 | |
| CursorPtr value type. | |
| enum | ValueType { T_STRING = 0, T_BOOL = 1, T_FLOAT = 2, T_FVECTOR2 = 3, T_FRECT = 4, T_INTEGER = 5, T_IVECTOR2 = 6, T_IRECT = 7, T_COLOR = 8, T_FONT = 9, T_TEXTALIGNMENT = 10, T_IMAGERY = 11, T_FACE = 12, T_CURSOR = 13 } |
| signifies the stored value type More... | |
Public Member Functions | |
| Value (const std::string &Name="") | |
Constructor. Name is optional, but will set the name of this Value if given. | |
| Value (const Value ©) | |
| Copy Constructor. | |
| ~Value () | |
| Destructor. | |
| const std::string & | getName () const |
| gets the name of this Value | |
| void | setName (const std::string &Name="") |
| sets the name of this Value | |
| ValueType | getType () const |
| Returns the type of this value. | |
| void | clearValue () |
| clears the stored value if one is stored, otherwise does nothing | |
| bool | isSet () const |
| returns true if a value is stored | |
| bool | operator== (const Value &right) const |
| bool | operator!= (const Value &right) const |
| bool | operator! () const |
| Returns true if this Value is empty (contains no stored value). | |
| operator bool () const | |
| Returns true if this Value is not empty (has a value stored). | |
| Value & | operator= (const Value &right) |
Assignment operation creates a complete copy of the contents (clones), but does not alter the Name of the assign target. | |
| void | SaveToXMLNode (XMLNode &node) const |
| Saves this Value to the given XMLNode object, overwriting any colliding content. | |
| void | LoadFromXMLNode (const XMLNode &node) |
| Loads this value from the given XMLNode object. | |
Assigning constructors that auto detect type based on parameter type | |
| Value (const std::string &value, const std::string &Name="") | |
Constructor, initializes object with copy of given value, the Name is optional. | |
| Value (const char *value, const std::string &Name="") | |
Constructor, initializes object with copy of given value, the Name is optional. | |
| Value (bool boolean, const std::string &Name="") | |
Constructor, initializes object with copy of given value, the Name is optional. | |
| Value (float value, const std::string &Name="") | |
Constructor, initializes object with copy of given value, the Name is optional. | |
| Value (const FVector2 &value, const std::string &Name="") | |
Constructor, initializes object with copy of given value, the Name is optional. | |
| Value (const FRect &value, const std::string &Name="") | |
Constructor, initializes object with copy of given value, the Name is optional. | |
| Value (int value, const std::string &Name="") | |
Constructor, initializes object with copy of given value, the Name is optional. | |
| Value (const IVector2 &value, const std::string &Name="") | |
Constructor, initializes object with copy of given value, the Name is optional. | |
| Value (const IRect &value, const std::string &Name="") | |
Constructor, initializes object with copy of given value, the Name is optional. | |
| Value (const Color &value, const std::string &Name="") | |
Constructor, initializes object with copy of given value, the Name is optional. | |
| Value (const Font &value, const std::string &Name="") | |
Constructor, initializes object with copy of given value, the Name is optional. | |
| Value (const TextAlignment &value, const std::string &Name="") | |
Constructor, initializes object with copy of given value, the Name is optional. | |
| Value (const ImageryPtr &value, const std::string &Name="") | |
Constructor, initializes object with copy of given value, the Name is optional. | |
| Value (const FacePtr &value, const std::string &Name="") | |
Constructor, initializes object with copy of given value, the Name is optional. | |
| Value (const CursorPtr &value, const std::string &Name="") | |
Constructor, initializes object with copy of given value, the Name is optional. | |
Auto detect type based on parameter type | |
| void | setValue (const std::string &std_string) |
| Sets the value, stored value is a copy. | |
| void | setValue (const char *cString) |
| Sets the value, stored value is a copy. | |
| void | setValue (bool boolean) |
| Sets the value, stored value is a copy. | |
| void | setValue (float floatingPoint) |
| Sets the value, stored value is a copy. | |
| void | setValue (const FVector2 &floatVector) |
| Sets the value, stored value is a copy. | |
| void | setValue (const FRect &floatRect) |
| Sets the value, stored value is a copy. | |
| void | setValue (int integer) |
| Sets the value, stored value is a copy. | |
| void | setValue (const IVector2 &intVector) |
| Sets the value, stored value is a copy. | |
| void | setValue (const IRect &intRect) |
| Sets the value, stored value is a copy. | |
| void | setValue (const Color &color) |
| Sets the value, stored value is a copy. | |
| void | setValue (const Font &font) |
| Sets the value, stored value is a copy. | |
| void | setValue (const TextAlignment &textAlignment) |
| Sets the value, stored value is a copy. | |
| void | setValue (const ImageryPtr &imageryPtr) |
| Sets the value, stored value is a copy. | |
| void | setValue (const FacePtr &facePtr) |
| Sets the value, stored value is a copy. | |
| void | setValue (const CursorPtr &cursorPtr) |
| Sets the value, stored value is a copy. | |
Get value as explicit type | |
| std::string | getValueAsString () const |
| Gets the stored value, throws exception if no value is stored. | |
| const char * | getValueAsCString () const |
| Gets the stored value, throws exception if no value is stored. | |
| bool | getValueAsBool () const |
| Gets the stored value, throws exception if no value is stored. | |
| float | getValueAsFloat () const |
| Gets the stored value, throws exception if no value is stored. | |
| FVector2 | getValueAsFVector2 () const |
| Gets the stored value, throws exception if no value is stored. | |
| FRect | getValueAsFRect () const |
| Gets the stored value, throws exception if no value is stored. | |
| int | getValueAsInt () const |
| Gets the stored value, throws exception if no value is stored. | |
| IVector2 | getValueAsIVector2 () const |
| Gets the stored value, throws exception if no value is stored. | |
| IRect | getValueAsIRect () const |
| Gets the stored value, throws exception if no value is stored. | |
| Color | getValueAsColor () const |
| Gets the stored value, throws exception if no value is stored. | |
| Font | getValueAsFont () const |
| Gets the stored value, throws exception if no value is stored. | |
| TextAlignment | getValueAsTextAlignment () const |
| Gets the stored value, throws exception if no value is stored. | |
| ImageryPtr | getValueAsImageryPtr () const |
| Gets the stored value, throws exception if no value is stored. | |
| FacePtr | getValueAsFacePtr () const |
| Gets the stored value, throws exception if no value is stored. | |
| CursorPtr | getValueAsCursorPtr () const |
| Gets the stored value, throws exception if no value is stored. | |
Set from string with explicit type conversion | |
| void | setValueAsInt (const std::string &intStr) |
| Sets the value from a string, parsed into an int. | |
| void | setValueAsFloat (const std::string &floatStr) |
| Sets the value from a string, parsed into a float. | |
| void | setValueAsFVector2 (const std::string &fv2Str) |
| Sets the value from a string, parsed into an FVector2. | |
| void | setValueAsFRect (const std::string &frectStr) |
| Sets the value from a string, parsed into an FRect. | |
| void | setValueAsIVector2 (const std::string &iv2Str) |
| Sets the value from a string, parsed into an IVector2. | |
| void | setValueAsIRect (const std::string &irectStr) |
| Sets the value from a string, parsed into an IRect. | |
| void | setValueAsColor (const std::string &colorStr) |
| Sets the value from a string, parsed into a Color. | |
| void | setValueAsString (const std::string &stringStr) |
| Sets the value from a string, parsed into a string. | |
| void | setValueAsBool (const std::string &boolStr) |
| Sets the value from a string, parsed into a boolean. | |
| void | setValueAsFont (const std::string &fontStr) |
| Sets the value from a string, parsed into a Font. | |
| void | setValueAsTextAlignment (const std::string &textAlignmentStr) |
| Sets the value from a string, parsed into a TextAlignment. | |
| void | setValueAsImageryPtr (const std::string &imageryName) |
| Sets the value from a string, used to look up the Imagery (can be either short name or FQN). | |
| void | setValueAsFacePtr (const std::string &faceName) |
| Sets the value from a string, used to look up the Face. | |
| void | setValueAsCursorPtr (const std::string &cursorName) |
| Sets the value from a string, used to look up the Cursor via CursorManager::CreateDefinedCursor(). | |
Purely string based functions | |
| void | setValueAuto (const std::string &std_string) |
| Sets the value from a string, performing auto detection to try to fit it into the best type. | |
| std::string | toStr () const |
| Returns a string representation of the stored value. | |
signifies the stored value type
| T_STRING | String value type. |
| T_BOOL | Boolean value type. |
| T_FLOAT | Float value type. |
| T_FVECTOR2 | FVector2 value type. |
| T_FRECT | FRect value type. |
| T_INTEGER | Integer value type. |
| T_IVECTOR2 | IVector2 value type. |
| T_IRECT | IRect value type. |
| T_COLOR | Color value type. |
| T_FONT | Font value type. |
| T_TEXTALIGNMENT | TextAlignment value type. |
| T_IMAGERY | ImageryPtr value type. |
| T_FACE | FacePtr value type. |
| T_CURSOR | CursorPtr value type. |
| OpenGUI::Value::Value | ( | const std::string & | Name = "" |
) |
Constructor. Name is optional, but will set the name of this Value if given.
| OpenGUI::Value::Value | ( | const Value & | copy | ) |
Copy Constructor.
| OpenGUI::Value::~Value | ( | ) |
Destructor.
| OpenGUI::Value::Value | ( | const std::string & | value, | |
| const std::string & | Name = "" | |||
| ) |
Constructor, initializes object with copy of given value, the Name is optional.
| OpenGUI::Value::Value | ( | const char * | value, | |
| const std::string & | Name = "" | |||
| ) |
Constructor, initializes object with copy of given value, the Name is optional.
| OpenGUI::Value::Value | ( | bool | boolean, | |
| const std::string & | Name = "" | |||
| ) |
Constructor, initializes object with copy of given value, the Name is optional.
| OpenGUI::Value::Value | ( | float | value, | |
| const std::string & | Name = "" | |||
| ) |
Constructor, initializes object with copy of given value, the Name is optional.
| OpenGUI::Value::Value | ( | const FVector2 & | value, | |
| const std::string & | Name = "" | |||
| ) |
Constructor, initializes object with copy of given value, the Name is optional.
| OpenGUI::Value::Value | ( | const FRect & | value, | |
| const std::string & | Name = "" | |||
| ) |
Constructor, initializes object with copy of given value, the Name is optional.
| OpenGUI::Value::Value | ( | int | value, | |
| const std::string & | Name = "" | |||
| ) |
Constructor, initializes object with copy of given value, the Name is optional.
| OpenGUI::Value::Value | ( | const IVector2 & | value, | |
| const std::string & | Name = "" | |||
| ) |
Constructor, initializes object with copy of given value, the Name is optional.
| OpenGUI::Value::Value | ( | const IRect & | value, | |
| const std::string & | Name = "" | |||
| ) |
Constructor, initializes object with copy of given value, the Name is optional.
| OpenGUI::Value::Value | ( | const Color & | value, | |
| const std::string & | Name = "" | |||
| ) |
Constructor, initializes object with copy of given value, the Name is optional.
| OpenGUI::Value::Value | ( | const Font & | value, | |
| const std::string & | Name = "" | |||
| ) |
Constructor, initializes object with copy of given value, the Name is optional.
| OpenGUI::Value::Value | ( | const TextAlignment & | value, | |
| const std::string & | Name = "" | |||
| ) |
Constructor, initializes object with copy of given value, the Name is optional.
| OpenGUI::Value::Value | ( | const ImageryPtr & | value, | |
| const std::string & | Name = "" | |||
| ) |
Constructor, initializes object with copy of given value, the Name is optional.
| OpenGUI::Value::Value | ( | const FacePtr & | value, | |
| const std::string & | Name = "" | |||
| ) |
Constructor, initializes object with copy of given value, the Name is optional.
| OpenGUI::Value::Value | ( | const CursorPtr & | value, | |
| const std::string & | Name = "" | |||
| ) |
Constructor, initializes object with copy of given value, the Name is optional.
| void OpenGUI::Value::clearValue | ( | ) |
clears the stored value if one is stored, otherwise does nothing
| const std::string& OpenGUI::Value::getName | ( | void | ) | const [inline] |
gets the name of this Value
| Value::ValueType OpenGUI::Value::getType | ( | ) | const |
Returns the type of this value.
Only valid if isSet() == true
| bool OpenGUI::Value::getValueAsBool | ( | ) | const |
Gets the stored value, throws exception if no value is stored.
| Color OpenGUI::Value::getValueAsColor | ( | ) | const |
Gets the stored value, throws exception if no value is stored.
| const char * OpenGUI::Value::getValueAsCString | ( | ) | const |
Gets the stored value, throws exception if no value is stored.
You must copy this if you wish to keep it, the buffer is temporary
| CursorPtr OpenGUI::Value::getValueAsCursorPtr | ( | ) | const |
Gets the stored value, throws exception if no value is stored.
| FacePtr OpenGUI::Value::getValueAsFacePtr | ( | ) | const |
Gets the stored value, throws exception if no value is stored.
| float OpenGUI::Value::getValueAsFloat | ( | ) | const |
Gets the stored value, throws exception if no value is stored.
| Font OpenGUI::Value::getValueAsFont | ( | ) | const |
Gets the stored value, throws exception if no value is stored.
| FRect OpenGUI::Value::getValueAsFRect | ( | ) | const |
Gets the stored value, throws exception if no value is stored.
| FVector2 OpenGUI::Value::getValueAsFVector2 | ( | ) | const |
Gets the stored value, throws exception if no value is stored.
| ImageryPtr OpenGUI::Value::getValueAsImageryPtr | ( | ) | const |
Gets the stored value, throws exception if no value is stored.
| int OpenGUI::Value::getValueAsInt | ( | ) | const |
Gets the stored value, throws exception if no value is stored.
| IRect OpenGUI::Value::getValueAsIRect | ( | ) | const |
Gets the stored value, throws exception if no value is stored.
| IVector2 OpenGUI::Value::getValueAsIVector2 | ( | ) | const |
Gets the stored value, throws exception if no value is stored.
| std::string OpenGUI::Value::getValueAsString | ( | ) | const |
Gets the stored value, throws exception if no value is stored.
| TextAlignment OpenGUI::Value::getValueAsTextAlignment | ( | ) | const |
Gets the stored value, throws exception if no value is stored.
| bool OpenGUI::Value::isSet | ( | ) | const |
returns true if a value is stored
| void OpenGUI::Value::LoadFromXMLNode | ( | const XMLNode & | node | ) |
Loads this value from the given XMLNode object.
This expects the given node to contain all necessary data as XMLNode attributes. Only the ValueName attribute may be missing
ValueName - defines the string based name for the Value (given to setName())ValueData - string representation of the data to storeValueType - defines the type of data held in ValueData. Valid values include:
| OpenGUI::Value::operator bool | ( | ) | const [inline] |
Returns true if this Value is not empty (has a value stored).
| bool OpenGUI::Value::operator! | ( | ) | const [inline] |
Returns true if this Value is empty (contains no stored value).
| bool OpenGUI::Value::operator!= | ( | const Value & | right | ) | const |
Assignment operation creates a complete copy of the contents (clones), but does not alter the Name of the assign target.
If you want to create a complete clone, including the name, use the copy constructor.
| bool OpenGUI::Value::operator== | ( | const Value & | right | ) | const |
Values are only equal under fairly strict conditions.
Name of the Values is not compared, as it is considered to be metadata | Exception::ERR_NOT_IMPLEMENTED | If this is received it is because you tried to compare two values of a type that should have been implemented but wasn't. This would make it a bug, so please report it! |
| void OpenGUI::Value::SaveToXMLNode | ( | XMLNode & | node | ) | const |
| void OpenGUI::Value::setName | ( | const std::string & | Name = "" |
) | [inline] |
sets the name of this Value
| void OpenGUI::Value::setValue | ( | const CursorPtr & | cursorPtr | ) |
Sets the value, stored value is a copy.
| void OpenGUI::Value::setValue | ( | const FacePtr & | facePtr | ) |
Sets the value, stored value is a copy.
| void OpenGUI::Value::setValue | ( | const ImageryPtr & | imageryPtr | ) |
Sets the value, stored value is a copy.
| void OpenGUI::Value::setValue | ( | const TextAlignment & | textAlignment | ) |
Sets the value, stored value is a copy.
| void OpenGUI::Value::setValue | ( | const Font & | font | ) |
Sets the value, stored value is a copy.
| void OpenGUI::Value::setValue | ( | const Color & | color | ) |
Sets the value, stored value is a copy.
| void OpenGUI::Value::setValue | ( | const IRect & | intRect | ) |
Sets the value, stored value is a copy.
| void OpenGUI::Value::setValue | ( | const IVector2 & | intVector | ) |
Sets the value, stored value is a copy.
| void OpenGUI::Value::setValue | ( | int | integer | ) |
Sets the value, stored value is a copy.
| void OpenGUI::Value::setValue | ( | const FRect & | floatRect | ) |
Sets the value, stored value is a copy.
| void OpenGUI::Value::setValue | ( | const FVector2 & | floatVector | ) |
Sets the value, stored value is a copy.
| void OpenGUI::Value::setValue | ( | float | floatingPoint | ) |
Sets the value, stored value is a copy.
| void OpenGUI::Value::setValue | ( | bool | boolean | ) |
Sets the value, stored value is a copy.
| void OpenGUI::Value::setValue | ( | const char * | cString | ) |
Sets the value, stored value is a copy.
| void OpenGUI::Value::setValue | ( | const std::string & | std_string | ) |
Sets the value, stored value is a copy.
| void OpenGUI::Value::setValueAsBool | ( | const std::string & | boolStr | ) |
Sets the value from a string, parsed into a boolean.
| void OpenGUI::Value::setValueAsColor | ( | const std::string & | colorStr | ) |
Sets the value from a string, parsed into a Color.
| void OpenGUI::Value::setValueAsCursorPtr | ( | const std::string & | cursorName | ) |
Sets the value from a string, used to look up the Cursor via CursorManager::CreateDefinedCursor().
| void OpenGUI::Value::setValueAsFacePtr | ( | const std::string & | faceName | ) |
Sets the value from a string, used to look up the Face.
| void OpenGUI::Value::setValueAsFloat | ( | const std::string & | floatStr | ) |
Sets the value from a string, parsed into a float.
| void OpenGUI::Value::setValueAsFont | ( | const std::string & | fontStr | ) |
Sets the value from a string, parsed into a Font.
| void OpenGUI::Value::setValueAsFRect | ( | const std::string & | frectStr | ) |
Sets the value from a string, parsed into an FRect.
| void OpenGUI::Value::setValueAsFVector2 | ( | const std::string & | fv2Str | ) |
Sets the value from a string, parsed into an FVector2.
| void OpenGUI::Value::setValueAsImageryPtr | ( | const std::string & | imageryName | ) |
Sets the value from a string, used to look up the Imagery (can be either short name or FQN).
| void OpenGUI::Value::setValueAsInt | ( | const std::string & | intStr | ) |
Sets the value from a string, parsed into an int.
| void OpenGUI::Value::setValueAsIRect | ( | const std::string & | irectStr | ) |
Sets the value from a string, parsed into an IRect.
| void OpenGUI::Value::setValueAsIVector2 | ( | const std::string & | iv2Str | ) |
Sets the value from a string, parsed into an IVector2.
| void OpenGUI::Value::setValueAsString | ( | const std::string & | stringStr | ) |
Sets the value from a string, parsed into a string.
Yes, this is redundant.
| void OpenGUI::Value::setValueAsTextAlignment | ( | const std::string & | textAlignmentStr | ) |
Sets the value from a string, parsed into a TextAlignment.
| void OpenGUI::Value::setValueAuto | ( | const std::string & | std_string | ) |
Sets the value from a string, performing auto detection to try to fit it into the best type.
This function should be considered fairly dangerous, as it is very easy to lose type information when building directly from a string. For instance, floats and integers can appear identical when the float has no decimal value. It is also pretty slow, considering that it has to perform several tests to try to determine the type of the input.
| std::string OpenGUI::Value::toStr | ( | ) | const |
Returns a string representation of the stored value.