|
|
LibN2L-4 Library Code Reference
Classes
Compounds
Files
Members
Method Index
Full Reference
n2l::cDynVar Class ReferencecDynVar is a dynamically typed variable which may be used to express int, tFloat, tString, tBool or arrays in similar ways to the native C++ types, but with type determined at runtime.
More...
#include <cDynVar.h>
Collaboration diagram for n2l::cDynVar:
[legend]List of all members.Public Types
Public Member Functions
- cDynVar ()
- Construct with the type/value Sint32(0).
- cDynVar (const tVarType iType)
- Construct with the type provided as "", 0, 0.0f or false.
- cDynVar (const cDynVar &iDynVar)
- Create a new copy of the provided dynamic variable.
- cDynVar (const char *const iValue)
- Construct as a 'string' initalized with iValue.
- cDynVar (const tString &iValue)
- Construct as a 'string' initalized with iValue.
- cDynVar (const tSint iValue)
- Construct as an integer with value iValue.
- cDynVar (const tUint iValue)
- cDynVar (const tFloat iValue)
- Construct as a tFloat with value iValue.
- cDynVar (const tBool iValue)
- Construct as a tBool with value iValue.
- cDynVar (const tDynVarArray &iValue)
- Construct as an Array with values iValue.
- ~cDynVar ()
- Deconstruct and free any associated memory.
- void assign (const cDynVar &iDynVar)
- Release any stored values and copy the provided dynamic variable.
- cDynVar & operator= (const cDynVar &iDynVar)
- An alias of assign().
- void eval (const tString &iValStr)
- Take a string containing a value and guess what type it is, taking the value as well.
- operator const tString () const
- Return the internal value as a STL string instance.
- operator const tSint () const
- Return the internal value as an integer.
- operator const tUint () const
- operator const tFloat () const
- Return the internal value as a tFloat.
- operator const tDouble () const
- operator const tBool () const
- Return the internal value as a tBool.
- const tVarType type () const
- Return the currently stored type.
- const tSize size () const
- Return the size in bytes of the currently stored value.
- const tString & typeStr () const
- Return a STL string representing the internal values type.
- const cDynVar casted (const tVarType iType) const
- Return a temporary cDynVar of the type requested.
- cDynVar & cast (const tVarType iType)
- Convert the internally stored value to the provided type.
- const cDynVar asNumeric () const
- Convert the internally stored value into the most suitable numerical type available, either int or tFloat.
- void mkNumeric ()
- Convert the internally stored value into the most suitable numerical format.
- void unset ()
- Unset (as much as possible) the dynamic variable.
- const tBool isNumericValue () const
- Check the internal value to see if it is a numeric representation.
- const tBool isNumericType () const
- Check the internal type to see if it is a numerical.
- const tBool isFloat () const
- Return if the internal type is tFloat.
- const tBool isInt () const
- Return if the internal type is integer.
- const tBool isSint32 () const
- Return if the internal type is Sint32 (int).
- const tBool isBool () const
- Return if the internal type is tBoolean.
- const tBool isString () const
- Return if the internal type is string.
- const tBool isArray () const
- Return if the internal type is an array.
- const tBool isNull () const
- Return if the internal type is Null.
- cDynVar & insert (const cDynVar &iValue)
- Add an element to this array using the next available integer key.
- cDynVar & insert (const cDynVar &iKey, const cDynVar &iValue)
- Add an element to this array using the provided key, or overwrite the existing element if the key already exists.
- template<class TKey> const tBool keyExists (const TKey &iKey) const
- Return if a key exists within the current cDynVar array.
- const tBool keyExists (const cDynVar &iKey) const
- template<class TKey> const tBool keyExistsAsArray (const TKey &iKey) const
- Return if a key exists and is an array.
- const tBool keyExistsAsArray (const cDynVar &iKey) const
- template<class TKey> const cDynVar & operator[] (const TKey &iKey) const
- Get an element from an array.
- const cDynVar & operator[] (const cDynVar &iKey) const
- template<class TKey> cDynVar & operator[] (const TKey &iKey)
- Get a read/write element from an array, or character from a string.
- cDynVar & operator[] (const cDynVar &iKey)
- template<class TKey> const cDynVar & keyValueOr (const TKey &iKey, const cDynVar &iDefault) const
- Get an from an array, if this is indeed an array and the key exists, Otherwise return another value.
- const cDynVar & keyValueOr (const cDynVar &iKey, const cDynVar &iDefault) const
- const tConstIterator begin () const
- Get the beginning const iterator in an array dynVar.
- const tConstIterator end () const
- Get the end const iterator in an array dynVar.
- template<class TKey> const tConstIterator find (const TKey &iKey) const
- Get a const iterator to the requested key, or end if none.
- const tConstIterator find (const cDynVar &iKey) const
- const cDynVar operator- (const cDynVar &iRValue) const
- Mathmatical Subtraction.
- const cDynVar operator+ (const cDynVar &iRValue) const
- Mathmatical Addition.
- const cDynVar operator * (const cDynVar &iRValue) const
- Mathmatical Muliplication.
- const cDynVar operator/ (const cDynVar &iRValue) const
- Mathmatical Division.
- const cDynVar operator% (const cDynVar &iRValue) const
- Mathmatical Remainder.
- const cDynVar operator== (const cDynVar &iRValue) const
- Logical Comparison.
- const cDynVar operator!= (const cDynVar &iRValue) const
- Logical Not-Equal Comparison.
- const cDynVar operator> (const cDynVar &iRValue) const
- Logical Greater-than.
- const cDynVar operator< (const cDynVar &iRValue) const
- Logical Less-than.
- const cDynVar operator>= (const cDynVar &iRValue) const
- Logical Greater-than or Equal-to.
- const cDynVar operator<= (const cDynVar &iRValue) const
- Logical Less than or Equal to.
- const cDynVar operator! () const
- Logical Not (not true) Returns true if the value when casted to a tBool is false.
- const cDynVar & operator++ ()
- Mathmatical increment by one (prefix).
- const cDynVar & operator-- ()
- Mathmatical decrement by one (prefix).
- const cDynVar operator++ (int)
- Mathmatical increment by one (postfix).
- const cDynVar operator-- (int)
- Mathmatical decrement by one (postfix).
- cDynVar & operator+= (const cDynVar &iRValue)
- Mathmatical self assign plus.
- cDynVar & operator-= (const cDynVar &iRValue)
- Mathmatical self assign subtraction.
- cDynVar & operator *= (const cDynVar &iRValue)
- Mathmatical self assign multiplication.
- cDynVar & operator/= (const cDynVar &iRValue)
- Mathmatical self assign division.
- const tString dump (const tString &iIndent="") const
- Return a textual representation of the internal type and value for debugging purposes.
- const tString serialize () const
- Serialize will return a string representing this variable including type information.
- void unserialize (const tString &iVarStr)
- Unserialize will set the current value and type to the data stored within a string created previously by serialize().
- void unserialize (const tString &iVarStr, const tString::size_type &iSPos)
- Unserialize will set the current value and type to the data stored within a string created previously by serialize().
- void unserialize_raw_100 (const tString &iVarStr, const tString::size_type &iSPos=0)
- void deepMerge (const cDynVar &iDef, const tBool iIntegersCollide=false)
- Merge the contents of another definition into this following duplicate array keys recursively, taking the parameter values on conflict.
Static Public Member Functions
Static Public Attributes
- static const tDynVarArray Array
- Provide a member that may be used as an array initializer, since there is no equivilent POD C type to use.
- static const cDynVar NoKey
- This is a weird one.
- static const cDynVar Null
Classes
Detailed Description
cDynVar is a dynamically typed variable which may be used to express int, tFloat, tString, tBool or arrays in similar ways to the native C++ types, but with type determined at runtime.
- Supported Types
- Sint32 (int), a 4 byte signed integer
- Float, a 4 byte tFloating point
- String, a string of any length
- Bool, simple true/false tBoolean value
- Array, any type (except array) -> any type value key pair.
- Null
- Casts
- Any of the types listed above may be casted to any of the other types listed. Specifically, strings must be casted to the Standard Template Library 'string' class.
- General Conversions
- Conversions should be as the developer assumes, the following special rules are worth knowing.
- In math equations, strings become auto-detected numerals of maximum precision (always signed)
- In math equations, tBools become (Sint32) (which may become tFloat if dictated by the equation)
- Operator Behaviour
- All following operators will work in reverse with the supported constants as well. In general the return from these operators will be of type cDynVar. These returns are may be immediately (and silently) cast back to their original types, so the following would be legal:
cDynVar x = 5 + cDynVar(3);
int y = x + 2;
- Supported Operators
- -, +, *, /, %
- =, -=, +=, *=, /=
- ++, -- (pre and postfix)
- !
- ==, !=, >, <, >=, <=
For the comparisons above, true is considered larger than false and strings are alphabetically sorted.
String comparisons are type sensitive.
- Type Juggling
- In most cases types are treated as they would be in PHP 4.x There are however some exceptions to this general rule of thumb.
- ++ & -- (pre and postfix) always 'numeralize' a variable, causing strings representing numbers to become those types. Strings not representing a number will become an Sint32(0).
- String vs String equalities are always done as strings, even when both strings are numerical, eg:\ ("2.00" == "2.0") = false as opposed to:
("2.00" == 2.0) = true
- String vs numeric compares as numeric (in the reverse, as well)
- tFloat vs Sint32 converts to tFloat (reverse, as well)
- tBool vs anything converts to tBool where true>false (see information on casting from anything to tBool)
- Special Comparisons
- x!=y is always evaluated as !(x==y)
- x>=y is always evaluated as !(x<y)
- x<=y is always evaluated as !(x>y)
- !x is always evaluated as !tBool(x)
Definition at line 111 of file cDynVar.h.
Member Typedef Documentation
|
|
Type sizes and positions are returned.
Definition at line 114 of file cDynVar.h. |
Member Enumeration Documentation
|
|
Contained variable types.
- Enumerator:
-
| VarType_String |
|
| VarType_Sint32 |
|
| VarType_Int |
|
| VarType_Float |
|
| VarType_Bool |
|
| VarType_Array |
|
| VarType_Null |
|
Definition at line 119 of file cDynVar.h. |
Constructor & Destructor Documentation
| n2l::cDynVar::cDynVar |
( |
|
) |
|
|
| n2l::cDynVar::cDynVar |
( |
const tVarType |
iType |
) |
|
|
| n2l::cDynVar::cDynVar |
( |
const cDynVar & |
iDynVar |
) |
|
|
| n2l::cDynVar::cDynVar |
( |
const char *const |
iValue |
) |
|
|
|
|
Construct as a 'string' initalized with iValue.
- Parameters:
-
| iValue | The const char * string to copy for initalization |
Definition at line 79 of file cDynVar.cpp. |
| n2l::cDynVar::cDynVar |
( |
const tString & |
iValue |
) |
|
|
| n2l::cDynVar::cDynVar |
( |
const tSint |
iValue |
) |
|
|
|
|
Construct as an integer with value iValue.
- Parameters:
-
| iValue | The integer value to initalize with. |
Definition at line 98 of file cDynVar.cpp. |
| n2l::cDynVar::cDynVar |
( |
const tUint |
iValue |
) |
|
|
| n2l::cDynVar::cDynVar |
( |
const tFloat |
iValue |
) |
|
|
|
|
Construct as a tFloat with value iValue.
- Parameters:
-
| iValue | The tFloat value to initalize with. |
Definition at line 112 of file cDynVar.cpp. |
| n2l::cDynVar::cDynVar |
( |
const tBool |
iValue |
) |
|
|
|
|
Construct as a tBool with value iValue.
- Parameters:
-
| iValue | The tBoolean value to initalize with. |
Definition at line 119 of file cDynVar.cpp. |
|
|
Construct as an Array with values iValue.
- Parameters:
-
| iValue | The map value to initalize with. |
Definition at line 127 of file cDynVar.cpp. |
| n2l::cDynVar::~cDynVar |
( |
|
) |
|
|
Member Function Documentation
| const cDynVar n2l::cDynVar::asNumeric |
( |
|
) |
const |
|
|
|
Convert the internally stored value into the most suitable numerical type available, either int or tFloat.
After the value has been converted it is returned as a temporary. - Returns:
- A temporary cDynVar of a numerical type representing this dynamic variables value.
Definition at line 501 of file cDynVar.cpp.
References n2l::asFloat(), n2l::asSint32(), VarType_Array, VarType_Bool, VarType_Float, VarType_Null, VarType_Sint32, and VarType_String.
Referenced by mkNumeric(), operator *(), operator *=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator<(), operator==(), and operator>(). |
| void n2l::cDynVar::assign |
( |
const cDynVar & |
iDynVar |
) |
|
|
| void n2l::cDynVar::deepMerge |
( |
const cDynVar & |
iDef, |
|
|
const tBool |
iIntegersCollide = false |
|
) |
|
|
| const tString n2l::cDynVar::dump |
( |
const tString & |
iIndent = "" |
) |
const |
|
| void n2l::cDynVar::eval |
( |
const tString & |
iValStr |
) |
|
|
|
|
Take a string containing a value and guess what type it is, taking the value as well.
This is similar to normal assignment, but the type taken on by the cDynVar may not be string if the parameter suggests it would be more appropriate as another type. eg.
x = "256.5" -> string(5) "256.5"
x.eval("256.5") -> tFloat(256.500000)
Practically speaking, this allows two strings to be compared accurately if they both contain numeral data.
eg.
x = "2.1"; y = "2.10";
(x==y) -> tBool(0)
x.eval("2.1"); y.eval("2.10");
(x==y) -> tBool(1)
Incidentally, the example above would evaluate correctly if either the left or right side were typed correctly, but see the example following why this isn't a great idea either.
It is often a good idea to eval from an unknown string to get the most useful value for later use. It is also generally more efficient to have types stored as they really are, rather than dynamically converting them. eg.
x = "10"; -> string(2) "10"
y = x * 10; -> int(100);
OR the must faster process (assuming x is used many times like this after assignment).
x.eval("10"); -> int(10);
y = x * 10; -> int(100);
As a general rule, evaluation is done as follows:
- Characters in the string are checked left to right.
- The presence of any non-numeric characters immediately classifies a variable as a string.
- No input will ever be classified as tBool. To simulate tBool use 0 or 1, which will become int.
- Null input ("") will become an Sint32(0) as a default construction would do.
- Note:
- A string will never evaluate to a bool or array
Definition at line 192 of file cDynVar.cpp.
References n2l::asFloat(), assign(), n2l::asSint32(), n2l::cString::empty(), n2l::cString::find(), n2l::isNumericStr(), n2l::cString::npos, and n2l::cString::rfind().
Referenced by n2l::cConfiguration::decodeBuffer(), deepMerge(), and serialize(). |
|
template<class TKey> |
| const tConstIterator n2l::cDynVar::find |
( |
const TKey & |
iKey |
) |
const [inline] |
|
|
|
Get a const iterator to the requested key, or end if none.
- Note:
- Any operation which erases, inserts or changes the type of this dynVar will invalidate this iterator. There is no protection against this.
Definition at line 495 of file cDynVar.h.
References cDynVar().
Referenced by deepMerge(). |
|
|
Add an element to this array using the provided key, or overwrite the existing element if the key already exists.
Definition at line 585 of file cDynVar.cpp.
References isArray(), and NoKey. |
|
|
Add an element to this array using the next available integer key.
Definition at line 571 of file cDynVar.cpp.
References isArray().
Referenced by n2l::cGuiSButton::addExtraClickedData(), n2l::cGuiInteractive::addExtraClickedData(), n2l::cGuiButton::addExtraClickedData(), n2l::cGuiSButton::addExtraDisabledData(), n2l::cGuiInteractive::addExtraFocusData(), n2l::cGuiInteractive::addExtraKeyData(), n2l::cGuiSButton::addExtraOutData(), n2l::cGuiInteractive::addExtraOutData(), n2l::cGuiButton::addExtraOutData(), n2l::cGuiSButton::addExtraOverData(), n2l::cGuiInteractive::addExtraOverData(), n2l::cGuiButton::addExtraOverData(), n2l::cGuiSButton::addExtraPressedData(), n2l::cGuiInteractive::addExtraPressedData(), n2l::cGuiSButton::addExtraReleasedData(), n2l::cGuiInteractive::addExtraReleasedData(), deepMerge(), n2l::cGuiInteractive::focus(), n2l::cGuiInteractive::keystroke(), n2l::cGuiInteractive::mouseClickAt(), n2l::cGuiInteractive::mouseClickOutside(), n2l::cGuiInteractive::mouseMove(), n2l::cGuiInteractive::mouseMoveOutside(), n2l::cGuiTextStyle::prop(), n2l::cGuiFill::prop(), n2l::cGuiSButtonSelectBox::selected(), n2l::cGuiButtonSelectBox::selected(), n2l::cGuiElement::update(), and n2l::cGuiSlider::value(). |
| const tBool n2l::cDynVar::isArray |
( |
|
) |
const [inline] |
|
|
|
Return if the internal type is an array.
- Note:
- This method is effectively a macro of type()==VarType_Array
- Returns:
- True if the internal type is an Array, false otherwise.
Definition at line 395 of file cDynVar.h.
References VarType_Array.
Referenced by n2l::asMatrix44f(), n2l::cConfValidatorIsOneOf::cConfValidatorIsOneOf(), deepMerge(), insert(), keyExists(), keyExistsAsArray(), n2l::cGuiSEFactory::load(), n2l::cGuiSButton::load(), n2l::cGuiModelView::load(), n2l::cGuiACFactory::load(), n2l::cGuiTextDisplay::prop(), n2l::cGuiSprite::prop(), n2l::cGuiSButton::prop(), n2l::cGuiModelView::prop(), n2l::cGuiLabel::prop(), and n2l::cGuiElement::prop(). |
| const tBool n2l::cDynVar::isBool |
( |
|
) |
const [inline] |
|
|
|
Return if the internal type is tBoolean.
- Note:
- This method is effectively a macro of type()==VarType_Bool
- Returns:
- True if the internal type is a tBool, false otherwise.
Definition at line 383 of file cDynVar.h.
References VarType_Bool. |
| const tBool n2l::cDynVar::isFloat |
( |
|
) |
const [inline] |
|
|
|
Return if the internal type is tFloat.
- Note:
- This method is effectively a macro of type()==VarType_Float
- Returns:
- True if the internal type is tFloat, false otherwise.
Definition at line 363 of file cDynVar.h.
References VarType_Float. |
| const tBool n2l::cDynVar::isInt |
( |
|
) |
const [inline] |
|
|
|
Return if the internal type is integer.
- Note:
- This method is effectively a macro of type()==VarType_Sint32
This is provided as a synonym of isSint32
- See also:
- isSint32()
- Returns:
- True if the internal type is an Sint32, false otherwise.
Definition at line 371 of file cDynVar.h.
References VarType_Sint32.
Referenced by deepMerge(). |
| const tBool n2l::cDynVar::isNull |
( |
|
) |
const [inline] |
|
| const tBool n2l::cDynVar::isNumericType |
( |
|
) |
const |
|
|
|
Check the internal type to see if it is a numerical.
This method will return true if the internal value is numerical. - Warning:
- This method 'trusts' the current internal type when deciding the numeric-ness of the value. A cDynVar string with "2.0" would not be considered numeric by this method. If you wish this kind of detection, use isNumericValue() instead.
- See also:
- isNumericValue
- Returns:
- True if the internal type is Sint32 or tFloat, false otherwise.
Definition at line 534 of file cDynVar.cpp.
References VarType_Float, and VarType_Sint32.
Referenced by operator *(), operator *=(), operator+(), operator++(), operator+=(), operator-(), operator--(), operator-=(), operator/(), operator<(), operator==(), and operator>(). |
| const tBool n2l::cDynVar::isNumericValue |
( |
|
) |
const |
|
|
|
Check the internal value to see if it is a numeric representation.
This method checks the value of this variable and returns true if it is numeric in any way. This means that an integer, tFloat or string containing a number will all return true. - Warning:
- This method has not yet been implemented.
- See also:
- isNumericType()
- Returns:
- True if the value is a representation of a number, false otherwise.
Definition at line 541 of file cDynVar.cpp.
References VarType_Array, VarType_Null, and VarType_String.
Referenced by operator==(). |
| const tBool n2l::cDynVar::isSint32 |
( |
|
) |
const [inline] |
|
|
|
Return if the internal type is Sint32 (int).
- Note:
- This method is effectively a macro of type()==VarType_Sint32
- Returns:
- True if the internal type is an Sint32, false otherwise.
Definition at line 377 of file cDynVar.h.
References VarType_Sint32. |
| const tBool n2l::cDynVar::isString |
( |
|
) |
const [inline] |
|
| const tBool n2l::cDynVar::keyExists |
( |
const cDynVar & |
iKey |
) |
const |
|
|
template<class TKey> |
| const tBool n2l::cDynVar::keyExists |
( |
const TKey & |
iKey |
) |
const [inline] |
|
|
|
Return if a key exists within the current cDynVar array.
Returns false if the variable isn't even an array.
Definition at line 419 of file cDynVar.h.
References cDynVar().
Referenced by n2l::cGuiACSetVar< TType >::execute(), n2l::cPParticleSpec::load(), n2l::cPEmitter::load(), n2l::cMaterial::load(), n2l::cGuiTextStyle::load(), n2l::cGuiTextDisplay::load(), n2l::cGuiSound::load(), n2l::cGuiSlider::load(), n2l::cGuiSEColourTrans::load(), n2l::cGuiSButtonSelectBox::load(), n2l::cGuiModelView::load(), n2l::cGuiLabel::load(), n2l::cGuiFill::load(), n2l::cGuiFactory::load(), n2l::cGuiCanvas::load(), n2l::cGuiButtonSelectBox::load(), n2l::cGuiACSetProp::load(), n2l::cGuiACPlaySound::load(), n2l::cGuiACIfProp::load(), n2l::cGuiACIf::load(), and n2l::cGuiACAddEffect::load(). |
| const tBool n2l::cDynVar::keyExistsAsArray |
( |
const cDynVar & |
iKey |
) |
const |
|
|
template<class TKey> |
| const tBool n2l::cDynVar::keyExistsAsArray |
( |
const TKey & |
iKey |
) |
const [inline] |
|
|
template<class TKey> |
| const cDynVar& n2l::cDynVar::keyValueOr |
( |
const TKey & |
iKey, |
|
|
const cDynVar & |
iDefault |
|
) |
const [inline] |
|
|
|
Get an from an array, if this is indeed an array and the key exists, Otherwise return another value.
- Note:
- This is mostly a macro function intended to reduce the overhead of checking for a key, then using it if exists which is very common in definition loading.
Definition at line 464 of file cDynVar.h.
References cDynVar().
Referenced by n2l::cColour::cColour(), n2l::cRSkyMobile::load(), n2l::cRSkyBox::load(), n2l::cRPerspectiveProjection::load(), n2l::cPParticleSpec::load(), n2l::cGuiSEColourTrans::load(), n2l::cGuiACSetProp::load(), n2l::cGuiACRemoveElement::load(), n2l::cGuiACInt::load(), n2l::cGuiACIfProp::load(), n2l::cGuiACIf::load(), n2l::cGuiACClearEffects::load(), n2l::cGuiACAddEffect::load(), n2l::cColourMod::load(), and n2l::cColour::operator=(). |
| void n2l::cDynVar::mkNumeric |
( |
|
) |
|
|
| const cDynVar n2l::cDynVar::operator * |
( |
const cDynVar & |
iRValue |
) |
const |
|
|
|
Mathmatical self assign multiplication.
Convert the internal value to a numerical type if not one and multiply by iRValue. - Warning:
- String values not representing a numeral will be converted to Sint32(0) and then multiplied by.
If this operator is used with a POD l-value, and cDynVar r-value, the POD will be returned, rather than a cDynVar like all other operators.
- Parameters:
-
| iRValue | The amount to multiply self by. |
- Returns:
- Reference to modifed self.
Definition at line 1049 of file cDynVar.cpp.
References asNumeric(), isNumericType(), mkNumeric(), mType, VarType_Array, and VarType_Float. |
| n2l::cDynVar::operator const tBool |
( |
|
) |
const |
|
| n2l::cDynVar::operator const tDouble |
( |
|
) |
const [inline] |
|
| n2l::cDynVar::operator const tFloat |
( |
|
) |
const |
|
| n2l::cDynVar::operator const tSint |
( |
|
) |
const |
|
| n2l::cDynVar::operator const tString |
( |
|
) |
const |
|
| n2l::cDynVar::operator const tUint |
( |
|
) |
const [inline] |
|
| const cDynVar n2l::cDynVar::operator! |
( |
|
) |
const |
|
|
|
Logical Not (not true) Returns true if the value when casted to a tBool is false.
- Note:
- This value is determined by evaluating !tBool(*this)
- Returns:
- True if the value evaluates to false, false otherwise.
Definition at line 879 of file cDynVar.cpp. |
| const cDynVar n2l::cDynVar::operator!= |
( |
const cDynVar & |
iRValue |
) |
const |
|
|
|
Logical Not-Equal Comparison.
This method will compare this value with the provided r-value. See the conversion guide (in the detailed description of this class) for descripton on how values are converted for comparison. - Note:
- This value is determined by evaluating !(*this==iRValue)
- Parameters:
-
| iRValue | Value to compare with. |
- Returns:
- True if the values differ, false otherwise.
Definition at line 805 of file cDynVar.cpp. |
| const cDynVar n2l::cDynVar::operator% |
( |
const cDynVar & |
iRValue |
) |
const |
|
|
|
Mathmatical Remainder.
- Parameters:
-
| iRValue | Value to operate on. |
- Returns:
- The integer remainder of this value divided by iRValue
Definition at line 765 of file cDynVar.cpp. |
| const cDynVar n2l::cDynVar::operator+ |
( |
const cDynVar & |
iRValue |
) |
const |
|
| const cDynVar n2l::cDynVar::operator++ |
( |
int |
|
) |
|
|
| const cDynVar & n2l::cDynVar::operator++ |
( |
|
) |
|
|
|
|
Mathmatical self assign plus.
Convert the internal value to a numerical type if not one and add iRValue to self. - Warning:
- String values not representing a numeral will be converted to Sint32(0) and then added to.
If this operator is used with a POD l-value, and cDynVar r-value, the POD will be returned, rather than a cDynVar like all other operators.
- Parameters:
-
| iRValue | The amount to add to self. |
- Returns:
- Reference to modifed self.
Definition at line 1013 of file cDynVar.cpp.
References asNumeric(), isNumericType(), mkNumeric(), mType, VarType_Array, and VarType_Float. |
| const cDynVar n2l::cDynVar::operator- |
( |
const cDynVar & |
iRValue |
) |
const |
|
| const cDynVar n2l::cDynVar::operator-- |
( |
int |
|
) |
|
|
| const cDynVar & n2l::cDynVar::operator-- |
( |
|
) |
|
|
|
|
Mathmatical self assign subtraction.
Convert the internal value to a numerical type if not one and subtract iRValue from self. - Warning:
- String values not representing a numeral will be converted to Sint32(0) and then subtracted from.
If this operator is used with a POD l-value, and cDynVar r-value, the POD will be returned, rather than a cDynVar like all other operators.
- Parameters:
-
| iRValue | The amount to subtract to self. |
- Returns:
- Reference to modifed self.
Definition at line 1031 of file cDynVar.cpp.
References asNumeric(), isNumericType(), mkNumeric(), mType, VarType_Array, and VarType_Float. |
| const cDynVar n2l::cDynVar::operator/ |
( |
const cDynVar & |
iRValue |
) |
const |
|
|
|
Mathmatical Division.
- Parameters:
-
| iRValue | Value to operate on. |
- Note:
- This method may return a tFloat, even if both the left and right sides of the equation are integers. If this behaviour is not desired the value may be immediately cast back to Sint32 for an integer divide.
- Returns:
- This value as a numeric divided by iRValue
Definition at line 746 of file cDynVar.cpp.
References asNumeric(), isNumericType(), mType, and VarType_Float. |
|
|
Mathmatical self assign division.
Convert the internal value to a numerical type if not one and divide by iRValue. - Warning:
- String values not representing a numeral will be converted to Sint32(0) and then divided by from.
If this operator is used with a POD l-value, and cDynVar r-value, the POD will be returned, rather than a cDynVar like all other operators.
- Parameters:
-
| iRValue | The amount to divide self by. |
- Returns:
- Reference to modifed self.
Definition at line 1067 of file cDynVar.cpp.
References mkNumeric(), and VarType_Array. |
| const cDynVar n2l::cDynVar::operator< |
( |
const cDynVar & |
iRValue |
) |
const |
|
|
|
Logical Less-than.
This method will compare this value with the provided r-value. See the conversion guide (in the detailed description of this class) for descripton on how values are converted for comparison. - Parameters:
-
| iRValue | Value to compare with. |
- Returns:
- True if this value is less than iRValue, false otherwise
Definition at line 838 of file cDynVar.cpp.
References asNumeric(), isNumericType(), mType, mValue, VarType_Float, VarType_Null, and VarType_String. |
| const cDynVar n2l::cDynVar::operator<= |
( |
const cDynVar & |
iRValue |
) |
const |
|
|
|
Logical Less than or Equal to.
This method will compare this value with the provided r-value. See the conversion guide (in the detailed description of this class) for descripton on how values are converted for comparison. - Note:
- This value is determined by evaluating !(*this>iRValue)
- Parameters:
-
| iRValue | Value to compare with. |
- Returns:
- True if this value is less than or equal to iRValue, false otherwise
Definition at line 873 of file cDynVar.cpp. |
| const cDynVar n2l::cDynVar::operator== |
( |
const cDynVar & |
iRValue |
) |
const |
|
| const cDynVar n2l::cDynVar::operator> |
( |
const cDynVar & |
iRValue |
) |
const |
|
|
|
Logical Greater-than.
This method will compare this value with the provided r-value. See the conversion guide (in the detailed description of this class) for descripton on how values are converted for comparison. - Parameters:
-
| iRValue | Value to compare with. |
- Returns:
- True if this value is greater than iRValue, false otherwise
Definition at line 812 of file cDynVar.cpp.
References asNumeric(), isNumericType(), mType, mValue, VarType_Float, VarType_Null, and VarType_String. |
| const cDynVar n2l::cDynVar::operator>= |
( |
const cDynVar & |
iRValue |
) |
const |
|
|
|
Logical Greater-than or Equal-to.
This method will compare this value with the provided r-value. See the conversion guide (in the detailed description of this class) for descripton on how values are converted for comparison. - Note:
- This value is determined by evaluating !(*this<iRValue)
- Parameters:
-
| iRValue | Value to compare with. |
- Returns:
- True if this value is greater than or equal to iRValue, false otherwise
Definition at line 866 of file cDynVar.cpp. |
|
template<class TKey> |
| cDynVar& n2l::cDynVar::operator[] |
( |
const TKey & |
iKey |
) |
[inline] |
|
|
|
Get a read/write element from an array, or character from a string.
- Note:
- This method will create the requested key if it is not present in the array. This behaviour is similar to std::map, and is not easily undone.
Definition at line 451 of file cDynVar.h.
References cDynVar(). |
| const cDynVar & n2l::cDynVar::operator[] |
( |
const cDynVar & |
iKey |
) |
const |
|
|
template<class TKey> |
| const cDynVar& n2l::cDynVar::operator[] |
( |
const TKey & |
iKey |
) |
const [inline] |
|
| const tString n2l::cDynVar::serialize |
( |
|
) |
const |
|
| const tString & n2l::cDynVar::typeStr |
( |
|
) |
const |
|
|
|
Return a STL string representing the internal values type.
The value returned by this method is not guarenteed, and so it should be used for type comparisons, for that instead look at the type() method. - See also:
- type()
- Returns:
- A string representing the type of the internal value.
Definition at line 383 of file cDynVar.cpp.
References anyTypeStr().
Referenced by dump(). |
| void n2l::cDynVar::unserialize |
( |
const tString & |
iVarStr |
) |
|
|
|
|
Unserialize will set the current value and type to the data stored within a string created previously by serialize().
See the documentation for 'serialize' for more information.
- Note:
- It's worthy to note that unserialize() is partially compatible with the PHP 4+ serialize() method, but will not interpret 'object' elements at all, instead becoming int(0)
Unserialize now recognizes a raw type and will parse it without a serialization step from n2l or from PHP. This raw type has a complex format and must be headed with the a line containing n2l::cDynVar_xxx where 'xxx' is the version of the raw data. This method works without modification from earlier versions of cDynVar and the serializations it supports and is intended to allow data definition without the interm step of PHP processing. Data without the specific header expected will be processed as a regular legacy serialization.
Legacy serializations will be more efficient and load more quickly.
- See also:
- http://www.php.net/manual/en/function.unserialize.php
serialize()
- Parameters:
-
Definition at line 1169 of file cDynVar.cpp.
References n2l::cString::findFirstNotOf(), n2l::cString::substr(), and unserialize_raw_100().
Referenced by n2l::cRVisualTriMesh::load(), n2l::cRSkyMobile2::load(), n2l::cRSkyMobile::load(), n2l::cRSkyBox::load(), n2l::cRPerspectiveProjection::load(), n2l::cRFreeCamera::load(), n2l::cPParticleSpec::load(), n2l::cPEmitter::load(), n2l::cMaterial::load(), n2l::cGuiTextInput::load(), n2l::cGuiSpriteMousePointer::load(), n2l::cGuiSound::load(), n2l::cGuiSEFactory::load(), n2l::cGuiSEColourTrans::load(), n2l::cGuiFill::load(), n2l::cGuiFactory::load(), n2l::cGuiACFactory::load(), n2l::cColourMod::load(), n2l::cGuiElement::validateAndDecode(), and n2l::vfsNodeFileWithHeader(). |
| void n2l::cDynVar::unset |
( |
|
) |
[inline] |
|
|
|
Unset (as much as possible) the dynamic variable.
This method is functionally equivilent to assigning cDynVar::Null.
Definition at line 330 of file cDynVar.h.
References assign(), and Null. |
Member Data Documentation
|
|
Provide a member that may be used as an array initializer, since there is no equivilent POD C type to use.
Definition at line 133 of file cDynVar.h.
Referenced by n2l::cGuiSEColourTrans::actOn(), cast(), casted(), deepMerge(), n2l::cGuiSButton::enabled(), n2l::cGuiInteractive::focus(), n2l::cGuiInteractive::keystroke(), n2l::cGuiInteractive::mouseClickAt(), n2l::cGuiInteractive::mouseClickOutside(), n2l::cGuiInteractive::mouseMove(), n2l::cGuiInteractive::mouseMoveOutside(), n2l::cGuiTextStyle::prop(), n2l::cGuiFill::prop(), n2l::cGuiElement::prop(), n2l::cGuiSButtonSelectBox::selected(), n2l::cGuiButtonSelectBox::selected(), n2l::cGuiElement::update(), and n2l::cGuiSlider::value(). |
|
|
This is a weird one.
We specifically say that array can't be a key in an array elsewhere, so it makes a perfect 'fake' key to use as an incremental insert.
Definition at line 134 of file cDynVar.h.
Referenced by insert(), keyValueOr(), and operator[](). |
|
|
Definition at line 135 of file cDynVar.h.
Referenced by cast(), casted(), n2l::cGuiSButtonSelectBox::getValueByLabel(), n2l::cGuiButtonSelectBox::getValueByLabel(), n2l::cGuiTextStyle::prop(), n2l::cGuiSound::prop(), n2l::cGuiSButton::prop(), n2l::cGuiFill::prop(), n2l::cGuiElement::prop(), n2l::cGuiSButtonSelectBox::selected(), n2l::cGuiButtonSelectBox::selected(), and unset(). |
The documentation for this class was generated from the following files:
|