PikaScript
|
STLValue is the reference implementation of a PikaScript variable. More...
#include <PikaScript.h>
Typedefs. | |
typedef S | String |
The class to use for all strings (i.e. the super-class). | |
typedef S::value_type | Char |
The character type for all strings (e.g. char or wchar_t). | |
typedef S | String |
The class to use for all strings (i.e. the super-class). | |
typedef S::value_type | Char |
The character type for all strings (e.g. char or wchar_t). | |
Constructors. | |
STLValue () | |
The default constructor initializes the value to the empty string (or "void"). | |
STLValue (double d) | |
Constructs a value representing the double precision floating point d . | |
STLValue (float f) | |
Constructs a value representing the single precision floating point f . | |
STLValue (long i) | |
Constructs a value representing the signed long integer l . | |
STLValue (ulong i) | |
Constructs a value representing the ulong integer l . | |
STLValue (int i) | |
Constructs a value representing the signed integer i . | |
STLValue (uint i) | |
Constructs a value representing the unsigned integer i . | |
STLValue (bool b) | |
Constructs a value representing the boolean b . | |
template<class T > | |
STLValue (const T &s) | |
Pass other types of construction onwards to the super-class S . | |
STLValue () | |
The default constructor initializes the value to the empty string (or "void"). | |
STLValue (double d) | |
Constructs a value representing the double precision floating point d . | |
STLValue (float f) | |
Constructs a value representing the single precision floating point f . | |
STLValue (long i) | |
Constructs a value representing the signed long integer l . | |
STLValue (ulong i) | |
Constructs a value representing the ulong integer l . | |
STLValue (int i) | |
Constructs a value representing the signed integer i . | |
STLValue (uint i) | |
Constructs a value representing the unsigned integer i . | |
STLValue (bool b) | |
Constructs a value representing the boolean b . | |
template<class T > | |
STLValue (const T &s) | |
Pass other types of construction onwards to the super-class S . | |
Conversion to native C++ types. | |
operator bool () const | |
Converts the value to a boolean. More... | |
operator long () const | |
Converts the value to a signed long integer. More... | |
operator double () const | |
Converts the value to a double precision floating point. More... | |
operator float () const | |
Converts the value to a single precision floating point. More... | |
operator ulong () const | |
Converts the value to an ulong integer. More... | |
operator int () const | |
Converts the value to a signed integer. More... | |
operator uint () const | |
Converts the value to an unsigned integer. More... | |
operator bool () const | |
Converts the value to a boolean. More... | |
operator long () const | |
Converts the value to a signed long integer. More... | |
operator double () const | |
Converts the value to a double precision floating point. More... | |
operator float () const | |
Converts the value to a single precision floating point. More... | |
operator ulong () const | |
Converts the value to an ulong integer. More... | |
operator int () const | |
Converts the value to a signed integer. More... | |
operator uint () const | |
Converts the value to an unsigned integer. More... | |
Overloaded operators (comparisons and subscript). | |
bool | operator< (const STLValue &r) const |
Less than comparison operator. More... | |
bool | operator== (const STLValue &r) const |
Equality operator. More... | |
bool | operator!= (const STLValue &r) const |
Non-equality operator. More... | |
bool | operator> (const STLValue &r) const |
Greater than comparison operator. More... | |
bool | operator<= (const STLValue &r) const |
Less than or equal to comparison operator. More... | |
bool | operator>= (const STLValue &r) const |
Greater than or equal to comparison operator. More... | |
const STLValue | operator[] (const STLValue &i) const |
The subscript operator returns the concatenation of the value with the dot (.) separator (if necessary) and the value i . More... | |
bool | operator< (const STLValue &r) const |
Less than comparison operator. More... | |
bool | operator== (const STLValue &r) const |
Equality operator. More... | |
bool | operator!= (const STLValue &r) const |
Non-equality operator. More... | |
bool | operator> (const STLValue &r) const |
Greater than comparison operator. More... | |
bool | operator<= (const STLValue &r) const |
Less than or equal to comparison operator. More... | |
bool | operator>= (const STLValue &r) const |
Greater than or equal to comparison operator. More... | |
const STLValue | operator[] (const STLValue &i) const |
The subscript operator returns the concatenation of the value with the dot (.) separator (if necessary) and the value i . More... | |
Classification methods. | |
bool | isVoid () const |
Returns true if the value represents the empty string. | |
bool | isVoid () const |
Returns true if the value represents the empty string. | |
Helper templates to allow certain operations on any type that is convertible to a STLValue. | |
template<class T > | |
bool | operator< (const T &r) const |
template<class T > | |
bool | operator== (const T &r) const |
template<class T > | |
bool | operator!= (const T &r) const |
template<class T > | |
bool | operator> (const T &r) const |
template<class T > | |
bool | operator<= (const T &r) const |
template<class T > | |
bool | operator>= (const T &r) const |
template<class T > | |
const STLValue | operator[] (const T &i) const |
template<class T > | |
bool | operator< (const T &r) const |
template<class T > | |
bool | operator== (const T &r) const |
template<class T > | |
bool | operator!= (const T &r) const |
template<class T > | |
bool | operator> (const T &r) const |
template<class T > | |
bool | operator<= (const T &r) const |
template<class T > | |
bool | operator>= (const T &r) const |
template<class T > | |
const STLValue | operator[] (const T &i) const |
STLValue is the reference implementation of a PikaScript variable.
Internally, all values are represented by an STL compliant string class S
*. This class actually inherits from S
(with public inheritance) for optimization reasons. This way we avoid a lot of unnecessary temporary objects when we cast to and from strings. (Unfortunately it is not possible to make this inheritance private and add conversion operators to the S
class. Explicit conversion operators in C++ have lower priority than implicit base class conversions.)
Although it may seem inefficient to store all variables in textual representation it makes PikaScript easy to interface with and debug for. With the custom value <-> text conversion routines in PikaScript the performance isn't too bad. It mainly depends on the performance of the string implementation which is the reason why this class is a template. The standard variant of STLValue uses std::string, but you may want to "plug in" a more efficient class.
STLValue supports construction from and casting to the following C++ types:
bool
int
uint
long
ulong
float
double
S
find_first_of
) are never used (instead, the equivalent generic STL algorithms are utilized). Destructive functions such as insert
and erase
are not used either. Furthermore, PikaScript consider all string access through the subscript operator [] to be for reading only (therefore only a const
function for this operator is required). Definition at line 173 of file PikaScript.h.
Pika::STLValue< S >::operator bool | ( | ) | const |
Converts the value to a boolean.
If the value isn't "true" or "false" an exception is thrown.
Pika::STLValue< S >::operator bool | ( | ) | const |
Converts the value to a boolean.
If the value isn't "true" or "false" an exception is thrown.
Definition at line 251 of file PikaScriptImpl.h.
Pika::STLValue< S >::operator double | ( | ) | const |
Converts the value to a double precision floating point.
If the value isn't in valid floating point format an exception is thrown.
Pika::STLValue< S >::operator double | ( | ) | const |
Converts the value to a double precision floating point.
If the value isn't in valid floating point format an exception is thrown.
Definition at line 264 of file PikaScriptImpl.h.
|
inline |
Converts the value to a single precision floating point.
If the value isn't in valid floating point format an exception is thrown.
Definition at line 197 of file PikaScript.h.
|
inline |
Converts the value to a single precision floating point.
If the value isn't in valid floating point format an exception is thrown.
Definition at line 197 of file PikaScript.h.
|
inline |
Converts the value to a signed integer.
If the value isn't in valid integer format an exception is thrown.
Definition at line 199 of file PikaScript.h.
|
inline |
Converts the value to a signed integer.
If the value isn't in valid integer format an exception is thrown.
Definition at line 199 of file PikaScript.h.
Pika::STLValue< S >::operator long | ( | ) | const |
Converts the value to a signed long integer.
If the value isn't in valid integer format an exception is thrown.
Definition at line 257 of file PikaScriptImpl.h.
Pika::STLValue< S >::operator long | ( | ) | const |
Converts the value to a signed long integer.
If the value isn't in valid integer format an exception is thrown.
|
inline |
Converts the value to an unsigned integer.
If the value isn't in valid integer format an exception is thrown.
Definition at line 200 of file PikaScript.h.
|
inline |
Converts the value to an unsigned integer.
If the value isn't in valid integer format an exception is thrown.
Definition at line 200 of file PikaScript.h.
|
inline |
Converts the value to an ulong integer.
If the value isn't in valid integer format an exception is thrown.
Definition at line 198 of file PikaScript.h.
|
inline |
Converts the value to an ulong integer.
If the value isn't in valid integer format an exception is thrown.
Definition at line 198 of file PikaScript.h.
|
inline |
Non-equality operator.
Notice that numbers are compared numerically (e.g. '1.0' and '1' are considered identical) and strings are compared literally (character by character).
Definition at line 206 of file PikaScript.h.
|
inline |
Non-equality operator.
Notice that numbers are compared numerically (e.g. '1.0' and '1' are considered identical) and strings are compared literally (character by character).
Definition at line 206 of file PikaScript.h.
bool Pika::STLValue< S >::operator< | ( | const STLValue< S > & | r | ) | const |
Less than comparison operator.
Notice that numbers are compared numerically and a number is always considered less than any non-number string.
Definition at line 270 of file PikaScriptImpl.h.
bool Pika::STLValue< S >::operator< | ( | const STLValue< S > & | r | ) | const |
Less than comparison operator.
Notice that numbers are compared numerically and a number is always considered less than any non-number string.
|
inline |
Less than or equal to comparison operator.
Notice that numbers are compared numerically and a number is always considered less than any non-number string.
Definition at line 208 of file PikaScript.h.
|
inline |
Less than or equal to comparison operator.
Notice that numbers are compared numerically and a number is always considered less than any non-number string.
Definition at line 208 of file PikaScript.h.
bool Pika::STLValue< S >::operator== | ( | const STLValue< S > & | r | ) | const |
Equality operator.
Notice that numbers are compared numerically (e.g. '1.0' and '1' are considered identical) and strings are compared literally (character by character).
Definition at line 276 of file PikaScriptImpl.h.
bool Pika::STLValue< S >::operator== | ( | const STLValue< S > & | r | ) | const |
Equality operator.
Notice that numbers are compared numerically (e.g. '1.0' and '1' are considered identical) and strings are compared literally (character by character).
|
inline |
Greater than comparison operator.
Notice that numbers are compared numerically and a number is always considered less than any non-number string.
Definition at line 207 of file PikaScript.h.
|
inline |
Greater than comparison operator.
Notice that numbers are compared numerically and a number is always considered less than any non-number string.
Definition at line 207 of file PikaScript.h.
|
inline |
Greater than or equal to comparison operator.
Notice that numbers are compared numerically and a number is always considered less than any non-number string.
Definition at line 209 of file PikaScript.h.
|
inline |
Greater than or equal to comparison operator.
Notice that numbers are compared numerically and a number is always considered less than any non-number string.
Definition at line 209 of file PikaScript.h.
const STLValue Pika::STLValue< S >::operator[] | ( | const STLValue< S > & | i | ) | const |
The subscript operator returns the concatenation of the value with the dot (.) separator (if necessary) and the value i
.
Use it on a reference value to create a reference to a subscript element of that reference.
const STLValue< S > Pika::STLValue< S >::operator[] | ( | const STLValue< S > & | i | ) | const |
The subscript operator returns the concatenation of the value with the dot (.) separator (if necessary) and the value i
.
Use it on a reference value to create a reference to a subscript element of that reference.
Definition at line 282 of file PikaScriptImpl.h.