Atlas  0.7.0
Networking protocol for the Worldforge system.
Atlas::Message::Element Class Reference

#include <Element.h>

Collaboration diagram for Atlas::Message::Element:

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. More...
 
 Element (const Element &obj)
 Copy an existing object. More...
 
 Element (Element &&obj) noexcept
 
 Element (int v)
 Set type to int, and value to v. More...
 
 Element (long v)
 
 Element (bool v)
 Set type to int, and value to v. More...
 
 Element (long long v)
 Set type to int, and value to v. More...
 
 Element (float v)
 Set type to double, and value to v. More...
 
 Element (FloatType v)
 Set type to double, and value to v. More...
 
 Element (PtrType v)
 Set type to PtrType, and value to v. More...
 
 Element (const char *v)
 Set type to std::string, and value to v. More...
 
 Element (const StringType &v)
 Set type to std::string, and value to v. More...
 
 Element (StringType &&v)
 Set type to std::string, and move v. More...
 
 Element (const MapType &v)
 Set type to MapType, and value to v. More...
 
 Element (MapType &&v)
 Set type to MapType, and move v. More...
 
 Element (const ListType &v)
 Set type to ListType, and value to v. More...
 
 Element (ListType &&v)
 Set type to ListType, and move v. More...
 
Elementoperator= (const Element &obj)
 overload assignment operator ! More...
 
Elementoperator= (Element &&obj) noexcept
 
Elementoperator= (int v)
 
Elementoperator= (long v)
 
Elementoperator= (bool v)
 
Elementoperator= (long long 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. More...
 
template<class C >
bool operator!= (C c) const
 Check for inequality with anything we can check equality with. More...
 
bool operator== (int v) const
 Check for equality with a int. More...
 
bool operator== (long v) const
 Check for equality with a int. More...
 
bool operator== (long long v) const
 Check for equality with a int. More...
 
bool operator== (FloatType v) const
 Check for equality with a double. More...
 
bool operator== (PtrType v) const
 Check for equality with a pointer. More...
 
bool operator== (const char *v) const
 Check for equality with a const char *. More...
 
bool operator== (const StringType &v) const
 Check for equality with a std::string. More...
 
bool operator== (const MapType &v) const
 Check for equality with a MapType. More...
 
bool operator== (const ListType &v) const
 Check for equality with a ListType. More...
 
Type getType () const
 Get the current type. More...
 
bool isNone () const
 Check whether the current type is nothing. More...
 
bool isInt () const
 Check whether the current type is int. More...
 
bool isFloat () const
 Check whether the current type is double. More...
 
bool isPtr () const
 Check whether the current type is pointer. More...
 
bool isNum () const
 Check whether the current type is numeric. More...
 
bool isString () const
 Check whether the current type is std::string. More...
 
bool isMap () const
 Check whether the current type is MapType. More...
 
bool isList () const
 Check whether the current type is ListType. More...
 
IntType asInt () const
 Retrieve the current value as a int. More...
 
IntType Int () const
 
FloatType asFloat () const
 Retrieve the current value as a double. More...
 
FloatType Float () const
 
PtrType asPtr () const
 Retrieve the current value as a pointer. More...
 
PtrType Ptr () const
 
FloatType asNum () const
 Retrieve the current value as a number. More...
 
const std::string & asString () const
 Retrieve the current value as a const std::string reference. More...
 
std::string & asString ()
 Retrieve the current value as a non-const std::string reference. More...
 
const StringType & String () const
 
StringType & String ()
 
StringType && moveString ()
 
const MapType & asMap () const
 Retrieve the current value as a const MapType reference. More...
 
MapType & asMap ()
 Retrieve the current value as a non-const MapType reference. More...
 
const MapType & Map () const
 
MapType & Map ()
 
MapType && moveMap ()
 
const ListType & asList () const
 Retrieve the current value as a const ListType reference. More...
 
ListType & asList ()
 Retrieve the current value as a non-const ListType reference. More...
 
const ListType & List () const
 
ListType & List ()
 
ListType && moveList ()
 

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

Definition at line 38 of file Element.h.

Constructor & Destructor Documentation

Atlas::Message::Element::Element ( )
inline

Construct an empty object.

Definition at line 58 of file Element.h.

Atlas::Message::Element::Element ( const Element obj)

Copy an existing object.

Definition at line 34 of file Element.cpp.

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

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

Definition at line 65 of file Element.cpp.

Atlas::Message::Element::Element ( int  v)
inline

Set type to int, and value to v.

Definition at line 77 of file Element.h.

Atlas::Message::Element::Element ( bool  v)
inline

Set type to int, and value to v.

Definition at line 88 of file Element.h.

Atlas::Message::Element::Element ( long long  v)
inline

Set type to int, and value to v.

Definition at line 94 of file Element.h.

Atlas::Message::Element::Element ( float  v)
inline

Set type to double, and value to v.

Definition at line 100 of file Element.h.

Atlas::Message::Element::Element ( FloatType  v)
inline

Set type to double, and value to v.

Definition at line 106 of file Element.h.

Atlas::Message::Element::Element ( PtrType  v)
inline

Set type to PtrType, and value to v.

Definition at line 112 of file Element.h.

Atlas::Message::Element::Element ( const char *  v)
inline

Set type to std::string, and value to v.

Definition at line 118 of file Element.h.

Atlas::Message::Element::Element ( const StringType &  v)
inline

Set type to std::string, and value to v.

Definition at line 129 of file Element.h.

Atlas::Message::Element::Element ( StringType &&  v)
inline

Set type to std::string, and move v.

Definition at line 135 of file Element.h.

Atlas::Message::Element::Element ( const MapType &  v)
inline

Set type to MapType, and value to v.

Definition at line 142 of file Element.h.

Atlas::Message::Element::Element ( MapType &&  v)
inline

Set type to MapType, and move v.

Definition at line 148 of file Element.h.

Atlas::Message::Element::Element ( const ListType &  v)
inline

Set type to ListType, and value to v.

Definition at line 155 of file Element.h.

Atlas::Message::Element::Element ( ListType &&  v)
inline

Set type to ListType, and move v.

Definition at line 161 of file Element.h.

Member Function Documentation

FloatType Atlas::Message::Element::asFloat ( ) const
inline
IntType Atlas::Message::Element::asInt ( ) const
inline

Retrieve the current value as a int.

Definition at line 430 of file Element.h.

Referenced by Atlas::Objects::Operation::RootOperationData::setAttr().

const ListType& Atlas::Message::Element::asList ( ) const
inline

Retrieve the current value as a const ListType reference.

Definition at line 533 of file Element.h.

ListType& Atlas::Message::Element::asList ( )
inline

Retrieve the current value as a non-const ListType reference.

Definition at line 539 of file Element.h.

const MapType& Atlas::Message::Element::asMap ( ) const
inline

Retrieve the current value as a const MapType reference.

Definition at line 500 of file Element.h.

MapType& Atlas::Message::Element::asMap ( )
inline

Retrieve the current value as a non-const MapType reference.

Definition at line 506 of file Element.h.

FloatType Atlas::Message::Element::asNum ( ) const
inline

Retrieve the current value as a number.

Definition at line 460 of file Element.h.

PtrType Atlas::Message::Element::asPtr ( ) const
inline

Retrieve the current value as a pointer.

Definition at line 450 of file Element.h.

const std::string& Atlas::Message::Element::asString ( ) const
inline

Retrieve the current value as a const std::string reference.

Definition at line 467 of file Element.h.

std::string& Atlas::Message::Element::asString ( )
inline

Retrieve the current value as a non-const std::string reference.

Definition at line 473 of file Element.h.

Type Atlas::Message::Element::getType ( ) const
inline

Get the current type.

Definition at line 411 of file Element.h.

Referenced by Atlas::Message::Encoder::listElementItem(), and Atlas::Message::Encoder::mapElementItem().

bool Atlas::Message::Element::isFloat ( ) const
inline

Check whether the current type is double.

Definition at line 417 of file Element.h.

bool Atlas::Message::Element::isInt ( ) const
inline

Check whether the current type is int.

Definition at line 415 of file Element.h.

bool Atlas::Message::Element::isList ( ) const
inline

Check whether the current type is ListType.

Definition at line 427 of file Element.h.

bool Atlas::Message::Element::isMap ( ) const
inline

Check whether the current type is MapType.

Definition at line 425 of file Element.h.

bool Atlas::Message::Element::isNone ( ) const
inline

Check whether the current type is nothing.

Definition at line 413 of file Element.h.

bool Atlas::Message::Element::isNum ( ) const
inline

Check whether the current type is numeric.

Definition at line 421 of file Element.h.

bool Atlas::Message::Element::isPtr ( ) const
inline

Check whether the current type is pointer.

Definition at line 419 of file Element.h.

bool Atlas::Message::Element::isString ( ) const
inline

Check whether the current type is std::string.

Definition at line 423 of file Element.h.

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

Moves the list out of the Element.

This will leave an empty list in the Element.

Returns

Definition at line 559 of file Element.h.

Referenced by Atlas::Objects::Entity::RootEntityData::setAttr(), Atlas::Objects::Operation::RootOperationData::setAttr(), and Atlas::Objects::Entity::AccountData::setAttr().

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

Moves the map out of the Element.

This will leave an empty map in the Element.

Returns

Definition at line 526 of file Element.h.

StringType&& Atlas::Message::Element::moveString ( )
inline
template<class C >
bool Atlas::Message::Element::operator!= ( c) const
inline

Check for inequality with anything we can check equality with.

Definition at line 343 of file Element.h.

Element & Atlas::Message::Element::operator= ( const Element obj)

overload assignment operator !

Definition at line 96 of file Element.cpp.

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

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

Parameters
obj
Returns

Definition at line 136 of file Element.cpp.

bool Atlas::Message::Element::operator== ( const Element o) const

Check for equality with another Element.

Definition at line 176 of file Element.cpp.

bool Atlas::Message::Element::operator== ( int  v) const
inline

Check for equality with a int.

Definition at line 349 of file Element.h.

bool Atlas::Message::Element::operator== ( long  v) const
inline

Check for equality with a int.

Definition at line 355 of file Element.h.

bool Atlas::Message::Element::operator== ( long long  v) const
inline

Check for equality with a int.

Definition at line 361 of file Element.h.

bool Atlas::Message::Element::operator== ( FloatType  v) const
inline

Check for equality with a double.

Definition at line 367 of file Element.h.

bool Atlas::Message::Element::operator== ( PtrType  v) const
inline

Check for equality with a pointer.

Definition at line 373 of file Element.h.

bool Atlas::Message::Element::operator== ( const char *  v) const
inline

Check for equality with a const char *.

Definition at line 379 of file Element.h.

bool Atlas::Message::Element::operator== ( const StringType &  v) const
inline

Check for equality with a std::string.

Definition at line 387 of file Element.h.

bool Atlas::Message::Element::operator== ( const MapType &  v) const
inline

Check for equality with a MapType.

Definition at line 395 of file Element.h.

bool Atlas::Message::Element::operator== ( const ListType &  v) const
inline

Check for equality with a ListType.

Definition at line 403 of file Element.h.


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