Atlas-C++
|
Multi-type container. More...
#include <Element.h>
Classes | |
class | DataType |
Public Types | |
enum | Type { TYPE_NONE, TYPE_INT, TYPE_FLOAT, TYPE_PTR, TYPE_STRING, TYPE_MAP, TYPE_LIST } |
Public Member Functions | |
Element () | |
Construct an empty object. | |
Element (const Element &obj) | |
Copy an existing object. | |
Element (int v) | |
Set type to int, and value to v. | |
Element (bool v) | |
Set type to int, and value to v. | |
Element (IntType v) | |
Set type to int, and value to v. | |
Element (float v) | |
Set type to double, and value to v. | |
Element (FloatType v) | |
Set type to double, and value to v. | |
Element (PtrType v) | |
Set type to PtrType, and value to v. | |
Element (const char *v) | |
Set type to std::string, and value to v. | |
Element (const StringType &v) | |
Set type to std::string, and value to v. | |
Element (const MapType &v) | |
Set type to MapType, and value to v. | |
Element (const ListType &v) | |
Set type to ListType, and value to v. | |
Element & | operator= (const Element &obj) |
overload assignment operator ! | |
Element & | operator= (int v) |
Element & | operator= (bool v) |
Element & | operator= (IntType v) |
Element & | operator= (float v) |
Element & | operator= (FloatType v) |
Element & | operator= (PtrType v) |
Element & | operator= (const char *v) |
Element & | operator= (const StringType &v) |
Element & | operator= (const MapType &v) |
Element & | operator= (const ListType &v) |
bool | operator== (const Element &o) const |
Check for equality with another Element. | |
template<class C > | |
bool | operator!= (C c) const |
Check for inequality with anything we can check equality with. | |
bool | operator== (IntType v) const |
Check for equality with a int. | |
bool | operator== (FloatType v) const |
Check for equality with a double. | |
bool | operator== (PtrType v) const |
Check for equality with a pointer. | |
bool | operator== (const char *v) const |
Check for equality with a const char *. | |
bool | operator== (const StringType &v) const |
Check for equality with a std::string. | |
bool | operator== (const MapType &v) const |
Check for equality with a MapType. | |
bool | operator== (const ListType &v) const |
Check for equality with a ListType. | |
Type | getType () const |
Get the current type. | |
bool | isNone () const |
Check whether the current type is nothing. | |
bool | isInt () const |
Check whether the current type is int. | |
bool | isFloat () const |
Check whether the current type is double. | |
bool | isPtr () const |
Check whether the current type is pointer. | |
bool | isNum () const |
Check whether the current type is numeric. | |
bool | isString () const |
Check whether the current type is std::string. | |
bool | isMap () const |
Check whether the current type is MapType. | |
bool | isList () const |
Check whether the current type is ListType. | |
IntType | asInt () const |
Retrieve the current value as a int. | |
IntType | Int () const |
FloatType | asFloat () const |
Retrieve the current value as a double. | |
FloatType | Float () const |
PtrType | asPtr () const |
Retrieve the current value as a pointer. | |
PtrType | Ptr () const |
FloatType | asNum () const |
Retrieve the current value as a number. | |
const std::string & | asString () const |
Retrieve the current value as a const std::string reference. | |
std::string & | asString () |
Retrieve the current value as a non-const std::string reference. | |
const StringType & | String () const |
StringType & | String () |
const MapType & | asMap () const |
Retrieve the current value as a const MapType reference. | |
MapType & | asMap () |
Retrieve the current value as a non-const MapType reference. | |
const MapType & | Map () const |
MapType & | Map () |
const ListType & | asList () const |
Retrieve the current value as a const ListType reference. | |
ListType & | asList () |
Retrieve the current value as a non-const ListType reference. | |
const ListType & | List () const |
ListType & | List () |
Static Public Member Functions | |
static const char * | typeName (Type) |
Protected Attributes | |
Type | t |
union { | |
IntType i | |
FloatType f | |
void * p | |
DataType< StringType > * s | |
DataType< MapType > * m | |
DataType< ListType > * l | |
}; | |
Multi-type container.
FIXME: Document this
Changes:
2003/04/02 Al Riddcoh alrid Add in some assignment operators for efficiency 2002/11/07 Al Riddcoh doch @zepl er.o rgalrid Changed the name to doch @zepl er.o rgElement as Object is a stupid name for a class. 2000/08/05 Karsten-O. Laux klaux Changed the members to pointers which only get created when really needed. This is a major speedup for passing Object as parameter or when copying it. Because copying of unused members is omitted. @rhr k.uni -kl. de
All pointers are stored as a union, so we save memory ! Changed IntType to long and added convinience Constructors for float, int and bool
Copyright 2000-2004 the respective authors.
This document can be licensed under the terms of the GNU Free Documentation License or the GNU General Public License and may be freely distributed under the terms given by one of these licenses.