Atlas-C++
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Atlas::Message::Element Class Reference

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.
 
Elementoperator= (const Element &obj)
 overload assignment operator !
 
Elementoperator= (Element &&obj) noexcept
 The object being moved from will have its type set to "None". More...
 
Elementoperator= (int v)
 
Elementoperator= (bool v)
 
Elementoperator= (IntType v)
 
Elementoperator= (float v)
 
Elementoperator= (FloatType v)
 
Elementoperator= (PtrType v)
 
Elementoperator= (const char *v)
 
Elementoperator= (const StringType &v)
 
Elementoperator= (StringType &&v)
 
Elementoperator= (const MapType &v)
 
Elementoperator= (MapType &&v)
 
Elementoperator= (const ListType &v)
 
Elementoperator= (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
 
}; 
 

Detailed Description

Multi-type container.

FIXME: Document this

Author
Stefanus Du Toit sdt@g.nosp@m.mx.n.nosp@m.et

Changes:

2003/04/02 Al Riddcoh alrid.nosp@m.doch.nosp@m.@zepl.nosp@m.er.o.nosp@m.rg Add in some assignment operators for efficiency 2002/11/07 Al Riddcoh alrid.nosp@m.doch.nosp@m.@zepl.nosp@m.er.o.nosp@m.rg Changed the name to Element as Object is a stupid name for a class. 2000/08/05 Karsten-O. Laux klaux.nosp@m.@rhr.nosp@m.k.uni.nosp@m.-kl..nosp@m.de 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

Constructor & Destructor Documentation

Atlas::Message::Element::Element ( Element &&  obj)
noexcept

Move an existing object.

The existing Element will have its type set to "None".

Member Function Documentation

ListType Atlas::Message::Element::moveList ( )
inline

Moves the list out of the Element.

This will leave an empty list in the Element.

Returns
MapType Atlas::Message::Element::moveMap ( )
inline

Moves the map out of the Element.

This will leave an empty map in the Element.

Returns
StringType Atlas::Message::Element::moveString ( )
inline

Moves the string out of the Element.

This will leave an empty string in the Element.

Returns
Element& Atlas::Message::Element::operator= ( Element &&  obj)
noexcept

The object being moved from will have its type set to "None".

Parameters
obj
Returns

The documentation for this class was generated from the following file:

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.