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 (long long v)
 
 Element (bool v)
 Set type to int, 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= (long long v)
 
Elementoperator= (bool 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
 
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

◆ Element() [1/14]

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

Construct an empty object.

Definition at line 58 of file Element.h.

◆ Element() [2/14]

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

Copy an existing object.

Definition at line 34 of file Element.cpp.

◆ Element() [3/14]

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.

◆ Element() [4/14]

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

Set type to int, and value to v.

Definition at line 77 of file Element.h.

◆ Element() [5/14]

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

Set type to int, and value to v.

Definition at line 93 of file Element.h.

◆ Element() [6/14]

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

Set type to double, and value to v.

Definition at line 99 of file Element.h.

◆ Element() [7/14]

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

Set type to PtrType, and value to v.

Definition at line 105 of file Element.h.

◆ Element() [8/14]

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

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

Definition at line 111 of file Element.h.

◆ Element() [9/14]

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

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

Definition at line 122 of file Element.h.

◆ Element() [10/14]

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

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

Definition at line 128 of file Element.h.

◆ Element() [11/14]

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

Set type to MapType, and value to v.

Definition at line 135 of file Element.h.

◆ Element() [12/14]

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

Set type to MapType, and move v.

Definition at line 141 of file Element.h.

◆ Element() [13/14]

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

Set type to ListType, and value to v.

Definition at line 148 of file Element.h.

◆ Element() [14/14]

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

Set type to ListType, and move v.

Definition at line 154 of file Element.h.

Member Function Documentation

◆ asFloat()

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

◆ asInt()

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

Retrieve the current value as a int.

Definition at line 404 of file Element.h.

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

◆ asList() [1/2]

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

Retrieve the current value as a const ListType reference.

Definition at line 507 of file Element.h.

◆ asList() [2/2]

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

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

Definition at line 513 of file Element.h.

◆ asMap() [1/2]

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

Retrieve the current value as a const MapType reference.

Definition at line 474 of file Element.h.

◆ asMap() [2/2]

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

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

Definition at line 480 of file Element.h.

◆ asNum()

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

Retrieve the current value as a number.

Definition at line 434 of file Element.h.

◆ asPtr()

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

Retrieve the current value as a pointer.

Definition at line 424 of file Element.h.

◆ asString() [1/2]

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

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

Definition at line 441 of file Element.h.

◆ asString() [2/2]

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

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

Definition at line 447 of file Element.h.

◆ getType()

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

Get the current type.

Definition at line 385 of file Element.h.

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

◆ isFloat()

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

Check whether the current type is double.

Definition at line 391 of file Element.h.

◆ isInt()

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

Check whether the current type is int.

Definition at line 389 of file Element.h.

◆ isList()

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

Check whether the current type is ListType.

Definition at line 401 of file Element.h.

◆ isMap()

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

Check whether the current type is MapType.

Definition at line 399 of file Element.h.

◆ isNone()

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

Check whether the current type is nothing.

Definition at line 387 of file Element.h.

◆ isNum()

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

Check whether the current type is numeric.

Definition at line 395 of file Element.h.

◆ isPtr()

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

Check whether the current type is pointer.

Definition at line 393 of file Element.h.

◆ isString()

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

Check whether the current type is std::string.

Definition at line 397 of file Element.h.

◆ moveList()

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 533 of file Element.h.

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

◆ moveMap()

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 500 of file Element.h.

◆ moveString()

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

◆ operator!=()

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

Check for inequality with anything we can check equality with.

Definition at line 319 of file Element.h.

◆ operator=() [1/2]

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

overload assignment operator !

Definition at line 96 of file Element.cpp.

◆ operator=() [2/2]

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.

◆ operator==() [1/9]

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

Check for equality with another Element.

Definition at line 176 of file Element.cpp.

◆ operator==() [2/9]

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

Check for equality with a int.

Definition at line 325 of file Element.h.

◆ operator==() [3/9]

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

Check for equality with a int.

Definition at line 331 of file Element.h.

◆ operator==() [4/9]

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

Check for equality with a double.

Definition at line 341 of file Element.h.

◆ operator==() [5/9]

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

Check for equality with a pointer.

Definition at line 347 of file Element.h.

◆ operator==() [6/9]

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

Check for equality with a const char *.

Definition at line 353 of file Element.h.

◆ operator==() [7/9]

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

Check for equality with a std::string.

Definition at line 361 of file Element.h.

◆ operator==() [8/9]

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

Check for equality with a MapType.

Definition at line 369 of file Element.h.

◆ operator==() [9/9]

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

Check for equality with a ListType.

Definition at line 377 of file Element.h.


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