OpenGUI::Value Class Reference
[Types]

#include <OpenGUI_Value.h>

List of all members.


Detailed Description

An encapsulation class used for passing values back and forth in the Accessor system.

Each Value has a stored value of ValueType as well as the option to carry a string based Name.


Public Types

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 ()
 default constructor
 Value (const Value &copy)
 Copy Constructor.
 ~Value ()
 Destructor.
const StringgetName () const
 gets the name of this Value
void setName (const 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).
Valueoperator= (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 String &value, const String &Name="")
 Constructor, initializes object with copy of given value, the Name is optional.
 Value (const char *value, const String &Name="")
 Constructor, initializes object with copy of given value, the Name is optional.
 Value (bool boolean, const String &Name="")
 Constructor, initializes object with copy of given value, the Name is optional.
 Value (float value, const String &Name="")
 Constructor, initializes object with copy of given value, the Name is optional.
 Value (const FVector2 &value, const String &Name="")
 Constructor, initializes object with copy of given value, the Name is optional.
 Value (const FRect &value, const String &Name="")
 Constructor, initializes object with copy of given value, the Name is optional.
 Value (int value, const String &Name="")
 Constructor, initializes object with copy of given value, the Name is optional.
 Value (const IVector2 &value, const String &Name="")
 Constructor, initializes object with copy of given value, the Name is optional.
 Value (const IRect &value, const String &Name="")
 Constructor, initializes object with copy of given value, the Name is optional.
 Value (const Color &value, const String &Name="")
 Constructor, initializes object with copy of given value, the Name is optional.
 Value (const Font &value, const String &Name="")
 Constructor, initializes object with copy of given value, the Name is optional.
 Value (const TextAlignment &value, const String &Name="")
 Constructor, initializes object with copy of given value, the Name is optional.
 Value (const ImageryPtr &value, const String &Name="")
 Constructor, initializes object with copy of given value, the Name is optional.
 Value (const FacePtr &value, const String &Name="")
 Constructor, initializes object with copy of given value, the Name is optional.
 Value (const CursorPtr &value, const String &Name="")
 Constructor, initializes object with copy of given value, the Name is optional.
Auto detect type based on parameter type
void setValue (const String &str)
 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
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 String &intStr)
 Sets the value from a string, parsed into an int.
void setValueAsFloat (const String &floatStr)
 Sets the value from a string, parsed into a float.
void setValueAsFVector2 (const String &fv2Str)
 Sets the value from a string, parsed into an FVector2.
void setValueAsFRect (const String &frectStr)
 Sets the value from a string, parsed into an FRect.
void setValueAsIVector2 (const String &iv2Str)
 Sets the value from a string, parsed into an IVector2.
void setValueAsIRect (const String &irectStr)
 Sets the value from a string, parsed into an IRect.
void setValueAsColor (const String &colorStr)
 Sets the value from a string, parsed into a Color.
void setValueAsString (const String &stringStr)
 Sets the value from a string, parsed into a string.
void setValueAsBool (const String &boolStr)
 Sets the value from a string, parsed into a boolean.
void setValueAsFont (const String &fontStr)
 Sets the value from a string, parsed into a Font.
void setValueAsTextAlignment (const String &textAlignmentStr)
 Sets the value from a string, parsed into a TextAlignment.
void setValueAsImageryPtr (const String &imageryName)
 Sets the value from a string, used to look up the Imagery (can be either short name or FQN).
void setValueAsFacePtr (const String &faceName)
 Sets the value from a string, used to look up the Face.
void setValueAsCursorPtr (const String &cursorName)
 Sets the value from a string, used to look up the Cursor via CursorManager::CreateDefinedCursor().
Purely string based functions
String toStr () const
 Returns a string representation of the stored value.


Member Enumeration Documentation

enum OpenGUI::Value::ValueType
 

signifies the stored value type

Enumerator:
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.


Constructor & Destructor Documentation

OpenGUI::Value::Value  ) 
 

default constructor

OpenGUI::Value::Value const Value copy  ) 
 

Copy Constructor.

OpenGUI::Value::~Value  ) 
 

Destructor.

OpenGUI::Value::Value const String value,
const String Name = ""
 

Constructor, initializes object with copy of given value, the Name is optional.

OpenGUI::Value::Value const char *  value,
const String Name = ""
 

Constructor, initializes object with copy of given value, the Name is optional.

OpenGUI::Value::Value bool  boolean,
const String Name = ""
 

Constructor, initializes object with copy of given value, the Name is optional.

OpenGUI::Value::Value float  value,
const String Name = ""
 

Constructor, initializes object with copy of given value, the Name is optional.

OpenGUI::Value::Value const FVector2 value,
const String Name = ""
 

Constructor, initializes object with copy of given value, the Name is optional.

OpenGUI::Value::Value const FRect value,
const String Name = ""
 

Constructor, initializes object with copy of given value, the Name is optional.

OpenGUI::Value::Value int  value,
const String Name = ""
 

Constructor, initializes object with copy of given value, the Name is optional.

OpenGUI::Value::Value const IVector2 value,
const String Name = ""
 

Constructor, initializes object with copy of given value, the Name is optional.

OpenGUI::Value::Value const IRect value,
const String Name = ""
 

Constructor, initializes object with copy of given value, the Name is optional.

OpenGUI::Value::Value const Color value,
const String Name = ""
 

Constructor, initializes object with copy of given value, the Name is optional.

OpenGUI::Value::Value const Font value,
const String Name = ""
 

Constructor, initializes object with copy of given value, the Name is optional.

OpenGUI::Value::Value const TextAlignment value,
const String Name = ""
 

Constructor, initializes object with copy of given value, the Name is optional.

OpenGUI::Value::Value const ImageryPtr value,
const String Name = ""
 

Constructor, initializes object with copy of given value, the Name is optional.

OpenGUI::Value::Value const FacePtr value,
const String Name = ""
 

Constructor, initializes object with copy of given value, the Name is optional.

OpenGUI::Value::Value const CursorPtr value,
const String Name = ""
 

Constructor, initializes object with copy of given value, the Name is optional.


Member Function Documentation

void OpenGUI::Value::clearValue  ) 
 

clears the stored value if one is stored, otherwise does nothing

const 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.

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 store
  • ValueType - defines the type of data held in ValueData. Valid values include:
    • INTEGER
    • FLOAT
    • BOOL
    • FVECTOR2
    • FRECT
    • IVECTOR2
    • IRECT
    • COLOR
    • STRING
    • FONT
    • TEXTALIGNMENT
    • IMAGERY
    • FACE
    • CURSOR

See also:
StringFormats for further information on the text formatting syntax of OpenGUI objects.

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
 

 return !operator==( right ); 
See also:
operator==()

Value & OpenGUI::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.

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.

  • They have the same "set" state (either set or not set)
  • Their stored values are of the same type
  • Their stored values are equal according to the == C++ operator as defined for that type
    Note:
    The Name of the Values is not compared, as it is considered to be metadata
    Exceptions:
    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
 

Saves this Value to the given XMLNode object, overwriting any colliding content.

This works by storing the necessary information in attributes of the given tag. If any of the attributes already exist, their contents are silently overwritten.
The used attributes are:

  • ValueType - identifies the type of data held within ValueData
  • ValueName - the Name of this Value
  • ValueData - the data of this Value in string format

void OpenGUI::Value::setName const 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 String str  ) 
 

Sets the value, stored value is a copy.

void OpenGUI::Value::setValueAsBool const String boolStr  ) 
 

Sets the value from a string, parsed into a boolean.

void OpenGUI::Value::setValueAsColor const String colorStr  ) 
 

Sets the value from a string, parsed into a Color.

void OpenGUI::Value::setValueAsCursorPtr const String cursorName  ) 
 

Sets the value from a string, used to look up the Cursor via CursorManager::CreateDefinedCursor().

void OpenGUI::Value::setValueAsFacePtr const String faceName  ) 
 

Sets the value from a string, used to look up the Face.

void OpenGUI::Value::setValueAsFloat const String floatStr  ) 
 

Sets the value from a string, parsed into a float.

void OpenGUI::Value::setValueAsFont const String fontStr  ) 
 

Sets the value from a string, parsed into a Font.

void OpenGUI::Value::setValueAsFRect const String frectStr  ) 
 

Sets the value from a string, parsed into an FRect.

void OpenGUI::Value::setValueAsFVector2 const String fv2Str  ) 
 

Sets the value from a string, parsed into an FVector2.

void OpenGUI::Value::setValueAsImageryPtr const 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 String intStr  ) 
 

Sets the value from a string, parsed into an int.

void OpenGUI::Value::setValueAsIRect const String irectStr  ) 
 

Sets the value from a string, parsed into an IRect.

void OpenGUI::Value::setValueAsIVector2 const String iv2Str  ) 
 

Sets the value from a string, parsed into an IVector2.

void OpenGUI::Value::setValueAsString const String stringStr  ) 
 

Sets the value from a string, parsed into a string.

Yes, this is redundant.

void OpenGUI::Value::setValueAsTextAlignment const String textAlignmentStr  ) 
 

Sets the value from a string, parsed into a TextAlignment.

String OpenGUI::Value::toStr  )  const
 

Returns a string representation of the stored value.


The documentation for this class was generated from the following files:
Copyright © 2006 OpenGUI | OpenGUI.SF.net
Generated: Sun Sep 9 02:00:22 2007