AaronCameron.net
I can't believe how tired I am.
Not a Member? - Login or Create an Account...MC Offline
Thursday the 29th of June 2017 @ 05:07am
Front Page Projects Your Profile About
[]

LibN2L-4 Library Code Reference

Classes
Compounds
Files
Members
Method Index
Full Reference

n2l::cDynVar Class Reference

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

#include <cDynVar.h>

Collaboration diagram for n2l::cDynVar:

Collaboration graph
[legend]
List of all members.

Public Types

Public Member Functions

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

  • union tValue

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

typedef tDynVarArray::const_iterator n2l::cDynVar::tConstIterator
 

Definition at line 116 of file cDynVar.h.

typedef std::map<tString,cDynVar> n2l::cDynVar::tDynVarArray
 

Definition at line 115 of file cDynVar.h.

typedef tUint32 n2l::cDynVar::tSize
 

Type sizes and positions are returned.

Definition at line 114 of file cDynVar.h.


Member Enumeration Documentation

enum n2l::cDynVar::tVarType
 

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  ) 
 

Construct with the type/value Sint32(0).

Definition at line 49 of file cDynVar.cpp.

Referenced by find(), keyExists(), keyExistsAsArray(), keyValueOr(), and operator[]().

n2l::cDynVar::cDynVar const tVarType  iType  ) 
 

Construct with the type provided as "", 0, 0.0f or false.

Parameters:
iType The type to initalize as.

Definition at line 56 of file cDynVar.cpp.

References VarType_Array, and VarType_String.

n2l::cDynVar::cDynVar const cDynVar iDynVar  ) 
 

Create a new copy of the provided dynamic variable.

Parameters:
iDynVar The value to copy.

Definition at line 70 of file cDynVar.cpp.

References assign(), and VarType_Sint32.

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  ) 
 

Construct as a 'string' initalized with iValue.

Parameters:
iValue The STL string value to initalize with.

Definition at line 90 of file cDynVar.cpp.

References n2l::cString::c_str(), and n2l::cString::size().

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  ) 
 

Definition at line 105 of file cDynVar.cpp.

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.

n2l::cDynVar::cDynVar const tDynVarArray iValue  ) 
 

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  ) 
 

Deconstruct and free any associated memory.

Definition at line 135 of file cDynVar.cpp.

References VarType_Array, and VarType_String.


Member Function Documentation

const tString & n2l::cDynVar::anyTypeStr const tVarType  iType  )  [static]
 

Return a string representing type type passed.

This is method is provided for other methods which share use of the tVarType typedef. Usually this applies to validators and parsers.

Note:
the typeStr() method calls this method.
Parameters:
iType The type to return the string representation of.
Returns:
A string representing the type passed.

Definition at line 359 of file cDynVar.cpp.

References n2l::asString(), VarType_Array, VarType_Bool, VarType_Float, VarType_Null, VarType_Sint32, and VarType_String.

Referenced by n2l::cConfValidatorIsType::describe(), and typeStr().

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  ) 
 

Release any stored values and copy the provided dynamic variable.

Parameters:
iDynVar The value to copy.

Definition at line 149 of file cDynVar.cpp.

References mType, mValue, size(), VarType_Array, and VarType_String.

Referenced by cDynVar(), eval(), operator=(), unserialize(), unserialize_raw_100(), and unset().

const cDynVar::tConstIterator n2l::cDynVar::begin  )  const
 

Get the beginning const iterator in an array dynVar.

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 671 of file cDynVar.cpp.

References VarType_Array.

Referenced by deepMerge(), n2l::cConfValidatorIsOneOf::describe(), and n2l::cConfValidatorIsOneOf::valueOk().

cDynVar & n2l::cDynVar::cast const tVarType  iType  ) 
 

Convert the internally stored value to the provided type.

The conversion which takes place when a type is changed is identical to the conversion that would take place in a casted() call, except the value is stored internally, rather than returned.

See also:
casted()
Returns:
Reference to self.

Definition at line 452 of file cDynVar.cpp.

References Array, Null, VarType_Array, VarType_Bool, VarType_Float, VarType_Null, VarType_Sint32, and VarType_String.

const cDynVar n2l::cDynVar::casted const tVarType  iType  )  const
 

Return a temporary cDynVar of the type requested.

This method behaves exactly as the repective C++ type cast.

Returns:
A temporary cDynVar of the requested type representing the internally stored value.

Definition at line 419 of file cDynVar.cpp.

References Array, Null, VarType_Array, VarType_Bool, VarType_Float, VarType_Null, VarType_Sint32, and VarType_String.

void n2l::cDynVar::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.

Definition at line 1640 of file cDynVar.cpp.

References Array, begin(), end(), eval(), find(), insert(), isArray(), isInt(), and VarType_Array.

const tString n2l::cDynVar::dump const tString iIndent = ""  )  const
 

Return a textual representation of the internal type and value for debugging purposes.

Outputs the current contents of this variable in a syntax similar to 'var_dump()' in PHP.

Warning:
The format of this value is not strictly defined, it should not be used for any purpose but debugging output.
See also:
http://www.php.net/manual/en/function.var-dump.php

Definition at line 1077 of file cDynVar.cpp.

References n2l::asString(), typeStr(), VarType_Array, VarType_Null, and VarType_String.

const cDynVar::tConstIterator n2l::cDynVar::end  )  const
 

Get the end const iterator in an array dynVar.

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 682 of file cDynVar.cpp.

References VarType_Array.

Referenced by deepMerge(), n2l::cConfValidatorIsOneOf::describe(), n2l::cGuiSButtonSelectBox::load(), n2l::cGuiCanvas::load(), n2l::cGuiButtonSelectBox::load(), n2l::cGuiACList::load(), and n2l::cConfValidatorIsOneOf::valueOk().

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().

const cDynVar::tConstIterator n2l::cDynVar::find const cDynVar iKey  )  const
 

Definition at line 692 of file cDynVar.cpp.

References VarType_Array.

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().

cDynVar & n2l::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.

Definition at line 585 of file cDynVar.cpp.

References isArray(), and NoKey.

cDynVar & n2l::cDynVar::insert const cDynVar iValue  ) 
 

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]
 

Return if the internal type is Null.

Note:
This method is effectively a macro of type()==VarType_Null
Returns:
True if the internal type is a null, false otherwise.

Definition at line 401 of file cDynVar.h.

References VarType_Null.

Referenced by keyExists(), keyExistsAsArray(), keyValueOr(), operator==(), and operator[]().

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]
 

Return if the internal type is string.

Note:
This method is effectively a macro of type()==VarType_String
Returns:
True if the internal type is an String, false otherwise.

Definition at line 389 of file cDynVar.h.

References VarType_String.

Referenced by n2l::n2lgui_loadOrBuild().

const tBool n2l::cDynVar::keyExists const cDynVar iKey  )  const
 

Definition at line 607 of file cDynVar.cpp.

References isArray(), and isNull().

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
 

Definition at line 617 of file cDynVar.cpp.

References isArray(), and isNull().

template<class TKey>
const tBool n2l::cDynVar::keyExistsAsArray const TKey &  iKey  )  const [inline]
 

Return if a key exists and is an array.

Definition at line 428 of file cDynVar.h.

References cDynVar().

Referenced by n2l::cGuiTextInput::load(), n2l::cGuiSEModelOrbit::load(), n2l::cGuiFill::load(), n2l::cGuiFactory::load(), n2l::cGuiACPlaySound::load(), and n2l::cGuiACList::load().

const cDynVar & n2l::cDynVar::keyValueOr const cDynVar iKey,
const cDynVar iDefault
const
 

Definition at line 660 of file cDynVar.cpp.

References isNull(), NoKey, and VarType_Array.

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  ) 
 

Convert the internally stored value into the most suitable numerical format.

This will convert strings and tBools to the best representation possible of either type Sint32 or tFloat. This method behaves exactly as the asNumeric() method except that the new value is stored internally rather than returned.

See also:
asNumeric()

Definition at line 494 of file cDynVar.cpp.

References asNumeric().

Referenced by operator *=(), operator++(), operator+=(), operator--(), operator-=(), and operator/=().

const cDynVar n2l::cDynVar::operator * const cDynVar iRValue  )  const
 

Mathmatical Muliplication.

Parameters:
iRValue Value to operate on.
Returns:
This value as a numeric multiplied by iRValue

Definition at line 731 of file cDynVar.cpp.

References asNumeric(), isNumericType(), mType, and VarType_Float.

cDynVar & n2l::cDynVar::operator *= const cDynVar iRValue  ) 
 

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
 

Return the internal value as a tBool.

Definition at line 320 of file cDynVar.cpp.

References VarType_Array, VarType_Bool, VarType_Float, VarType_Null, VarType_Sint32, and VarType_String.

n2l::cDynVar::operator const tDouble  )  const [inline]
 

Definition at line 253 of file cDynVar.h.

n2l::cDynVar::operator const tFloat  )  const
 

Return the internal value as a tFloat.

Definition at line 292 of file cDynVar.cpp.

References n2l::asFloat(), VarType_Array, VarType_Bool, VarType_Float, VarType_Null, VarType_Sint32, and VarType_String.

n2l::cDynVar::operator const tSint  )  const
 

Return the internal value as an integer.

Definition at line 264 of file cDynVar.cpp.

References n2l::asSint32(), VarType_Array, VarType_Bool, VarType_Float, VarType_Null, VarType_Sint32, and VarType_String.

n2l::cDynVar::operator const tString  )  const
 

Return the internal value as a STL string instance.

Definition at line 235 of file cDynVar.cpp.

References n2l::asString(), VarType_Array, VarType_Bool, VarType_Float, VarType_Null, VarType_Sint32, and VarType_String.

n2l::cDynVar::operator const tUint  )  const [inline]
 

Definition at line 249 of file cDynVar.h.

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
 

Mathmatical Addition.

Parameters:
iRValue Value to operate on.
Returns:
This value as a numeric plus iRValue

Definition at line 716 of file cDynVar.cpp.

References asNumeric(), isNumericType(), mType, and VarType_Float.

const cDynVar n2l::cDynVar::operator++ int   ) 
 

Mathmatical increment by one (postfix).

Convert the internal value to a numerical type if not one and increment self by one.

Warning:
String values not representing a numeral will be converted to Sint32(0) and then incremented to 1.
Returns:
Constant temporary of numeric self previous to increment.

Definition at line 949 of file cDynVar.cpp.

References isNumericType(), mkNumeric(), VarType_Array, VarType_Bool, VarType_Float, VarType_Null, VarType_Sint32, and VarType_String.

const cDynVar & n2l::cDynVar::operator++  ) 
 

Mathmatical increment by one (prefix).

Convert the internal value to a numerical type if not one and increment self by one.

Warning:
String values not representing a numeral will be converted to Sint32(0) and then incremented to 1.
Returns:
Constant reference to incremented self

Definition at line 886 of file cDynVar.cpp.

References isNumericType(), mkNumeric(), VarType_Array, VarType_Bool, VarType_Float, VarType_Null, VarType_Sint32, and VarType_String.

cDynVar & n2l::cDynVar::operator+= const cDynVar iRValue  ) 
 

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
 

Mathmatical Subtraction.

Parameters:
iRValue Value to operate on.
Returns:
This value as a numeric minus iRValue

Definition at line 701 of file cDynVar.cpp.

References asNumeric(), isNumericType(), mType, and VarType_Float.

const cDynVar n2l::cDynVar::operator-- int   ) 
 

Mathmatical decrement by one (postfix).

Convert the internal value to a numerical type if not one and decrement self by one.

Warning:
String values not representing a numeral will be converted to Sint32(0) and then decremented to -1.
Returns:
Constant temporary of numeric self previous to decrement.

Definition at line 981 of file cDynVar.cpp.

References isNumericType(), mkNumeric(), VarType_Array, VarType_Bool, VarType_Float, VarType_Null, VarType_Sint32, and VarType_String.

const cDynVar & n2l::cDynVar::operator--  ) 
 

Mathmatical decrement by one (prefix).

Convert the internal value to a numerical type if not one and decrement self by one.

Warning:
String values not representing a numeral will be converted to Sint32(0) and then decremented to -1.
Returns:
Constant Reference to decremented self

Definition at line 918 of file cDynVar.cpp.

References isNumericType(), mkNumeric(), VarType_Array, VarType_Bool, VarType_Float, VarType_Null, VarType_Sint32, and VarType_String.

cDynVar & n2l::cDynVar::operator-= const cDynVar iRValue  ) 
 

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.

cDynVar & n2l::cDynVar::operator/= const cDynVar iRValue  ) 
 

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.

cDynVar & n2l::cDynVar::operator= const cDynVar iDynVar  ) 
 

An alias of assign().

See also:
assign()

Definition at line 184 of file cDynVar.cpp.

References assign().

const cDynVar n2l::cDynVar::operator== const cDynVar iRValue  )  const
 

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

Parameters:
iRValue Value to compare with.
Returns:
True if the values match, false otherwise.

Definition at line 772 of file cDynVar.cpp.

References asNumeric(), isNull(), isNumericType(), isNumericValue(), mType, mValue, VarType_Float, and VarType_String.

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.

cDynVar & n2l::cDynVar::operator[] const cDynVar iKey  ) 
 

Definition at line 647 of file cDynVar.cpp.

References isNull(), NoKey, and VarType_Array.

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
 

Definition at line 629 of file cDynVar.cpp.

References isNull(), and VarType_Array.

template<class TKey>
const cDynVar& n2l::cDynVar::operator[] const TKey &  iKey  )  const [inline]
 

Get an element from an array.

Definition at line 438 of file cDynVar.h.

References cDynVar().

const tString n2l::cDynVar::serialize  )  const
 

Serialize will return a string representing this variable including type information.

The string returned by this method may be passed into another cDynVar later via the unserialize() method to recreate the exact value and type of this cDynVar.

It is often not necessary to use serialize and unserialize where simple tString() and eval() would be sufficent. An exception would be the following:

x = "2.1"; // x: string(3) "2.1"
string s = x; // s: "2.1"
x.eval(s); // x: tFloat(2.100000)

whereas serialize/unserialize would produce

x = "2.1"; // x: string(3) "2.1"
string s = x.serialize(); // s: "s:3:\"2.1\";"
x.unserialize(s); // x: string(3) "2.1"

Note:
It's worthy to note that serialize() produces a string which is readable by the PHP 4+ unserialize() method.
See also:
http://www.php.net/manual/en/function.serialize.php

unserialize()

Returns:
A string representing the type and value of this variable.

Definition at line 1111 of file cDynVar.cpp.

References n2l::asString(), eval(), serialize(), VarType_Array, VarType_Bool, VarType_Float, VarType_Null, VarType_Sint32, and VarType_String.

Referenced by serialize().

const cDynVar::tSize n2l::cDynVar::size  )  const
 

Return the size in bytes of the currently stored value.

In the case of a string it will return the strings length not including any trailing characters such as the null character.

Returns:
Internal value size in bytes.

Definition at line 389 of file cDynVar.cpp.

References VarType_Array, VarType_Bool, VarType_Float, VarType_Null, VarType_Sint32, and VarType_String.

Referenced by assign(), n2l::cGuiFill::load(), and n2l::cGuiElement::prop().

const cDynVar::tVarType n2l::cDynVar::type  )  const
 

Return the currently stored type.

Returns:
The value type currently being stored.

Definition at line 353 of file cDynVar.cpp.

Referenced by n2l::cConfValidatorIsType::valueOk().

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,
const tString::size_type iSPos
 

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)
See also:
http://www.php.net/manual/en/function.unserialize.php

serialize()

Parameters:
iVarStr A string representing a cDynVar generated by the serialize() command.
iSPos The start position from which to process the serialization string

Definition at line 1182 of file cDynVar.cpp.

References assign(), and n2l::cString::size().

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:
iVarStr A string representing a cDynVar generated by the serialize() command.

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::unserialize_raw_100 const tString iVarStr,
const tString::size_type iSPos = 0
 

Definition at line 1194 of file cDynVar.cpp.

References assign(), and n2l::cString::size().

Referenced by unserialize().

void n2l::cDynVar::unserializeStats tUint oDString,
tUint oDInt,
tUint oDFloat,
tUint oDBool,
tUint oDArray,
tUint oDNull
[static]
 

Definition at line 1628 of file cDynVar.cpp.

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

const cDynVar::tDynVarArray n2l::cDynVar::Array [static]
 

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().

const cDynVar n2l::cDynVar::NoKey [static]
 

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[]().

const cDynVar n2l::cDynVar::Null [static]
 

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:
©2017 Aaron Cameron