Object

class Object : public emcore::TypedContainer

Generic object to wrap underlying values.

An object could contains any type inside.

Public Functions

Object()

Default empty constructor for an Object.

After an Object instance is created through this constructor, its Type will be the nullType and it will not contain any data.

Object(const Type &type, void *memory = nullptr)

Object constructor where the memory and type are provided. In this case the Object will not be the “owner” of the memory and should not free it when it is destroyed.

Object(const Object &other)

Standard copy constructor.

The newly created object will have the same data Type than the other object. The underlying data will be a copy of the other’s data.

Object(Object &&other)

Move constructor. TODO: DOCUMENT!!!

template<class T>
Object(const T &valueIn)

Object class destructor. Copy construct from an existing Object.

The new object will take the Type inferred from the type of the argument and the data will contain a copy of it.

template<class T>
Object &operator=(const T &valueIn)

Assign operator to store an given value. The object will change its type (and do memory allocation) if necessary to accommodate the new value.

Return

Return a references to ‘this’ object.

Template Parameters
  • T: template type of the input value.

Parameters
  • valueIn: Value that will define the internal content of the object.

template<class T>
void set(const T &valueIn)

Set the internal value of the object. The internal type will be preserved and the input value will be converted if necessary.

Template Parameters
  • T:

Parameters
  • valueIn:

Object &operator=(Object &&other)

Move assign.

Object getView()

Return a View of this object.

void toStream(std::ostream &ostream) const

Push the value of the Object to the output stream

void fromStream(std::istream &istream)

Parse the value of the Object from the input stream

std::string toString() const

Get a string representation of the Object value

void fromString(const std::string &str)

Parse the value of the Object from string

void setType(const Type &newType)

Set a new type to this object. Release current memory if needed and allocate new one if needed as well.