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 (Element &&obj) noexcept | |
Move an existing object. More... | |
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 (StringType &&v) | |
Set type to std::string, and move v. | |
Element (const MapType &v) | |
Set type to MapType, and value to v. | |
Element (MapType &&v) | |
Set type to MapType, and move v. | |
Element (const ListType &v) | |
Set type to ListType, and value to v. | |
Element (ListType &&v) | |
Set type to ListType, and move v. | |
Element & | operator= (const Element &obj) |
overload assignment operator ! | |
Element & | operator= (Element &&obj) noexcept |
The object being moved from will have its type set to "None". More... | |
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= (StringType &&v) |
Element & | operator= (const MapType &v) |
Element & | operator= (MapType &&v) |
Element & | operator= (const ListType &v) |
Element & | operator= (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 () |
StringType | moveString () |
Moves the string out of the Element. More... | |
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 () |
MapType | moveMap () |
Moves the map out of the Element. More... | |
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 () |
ListType | moveList () |
Moves the list out of the Element. More... | |
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. All pointers are stored as a union, so we save memory ! Changed IntType to long and added convenience Constructors for float, int and bool @rhr k.uni -kl. de
|
noexcept |
Move an existing object.
The existing Element will have its type set to "None".
|
inline |
|
inline |
|
inline |
The object being moved from will have its type set to "None".
obj |
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.