jaula API Reference version 1.4.0
JAULA::Value_Object Class Reference

Class for handling object values. More...

#include <jaula_value_object.h>

Inheritance diagram for JAULA::Value_Object:
JAULA::Value_Complex JAULA::Value

Public Types

typedef std::map< std::string, Value * > dataType
 Data type for value contents.
 
- Public Types inherited from JAULA::Value
enum  ValueType {
  TYPE_NULL , TYPE_BOOLEAN , TYPE_STRING , TYPE_NUMBER ,
  TYPE_NUMBER_INT , TYPE_ARRAY , TYPE_OBJECT
}
 Enumeration of available value types. More...
 

Public Member Functions

virtual void clear (void)
 Empties the contents of an instance.
 
virtual bool empty (void) const
 True if the instance is empty.
 
dataType const & getData (void) const
 Retrieves the map of values contained by the instance.
 
void insertItem (std::string const &name, Value const &item) throw (Name_Duplicated)
 Inserts one item to the object.
 
virtual void repr (std::ostream &ostr) const
 Represents the instance in a stream.
 
void set (dataType const &data)
 Establishes the contents of the instance.
 
virtual void set (Value const &origin) throw (Bad_Data_Type)
 Copies the contents of one instance into another.
 
virtual size_t size (void) const
 Number of elements contained.
 
 Value_Object (dataType const &data)
 Data Constructor.
 
 Value_Object (void)
 Default Constructor.
 
virtual ~Value_Object ()
 Destructor.
 
- Public Member Functions inherited from JAULA::Value_Complex
virtual ~Value_Complex ()
 Destructor.
 
- Public Member Functions inherited from JAULA::Value
ValueType getType (void) const
 Retrieves the value type for the instance.
 
Valueoperator= (Value const &orig) throw (Bad_Data_Type)
 Assignment operator.
 
virtual ~Value ()
 Destructor.
 

Private Attributes

dataType data_
 Container to hold the value itself.
 

Additional Inherited Members

- Static Public Member Functions inherited from JAULA::Value
static Valueduplicate (Value const &orig)
 Creates a duplicate of a value.
 
- Protected Member Functions inherited from JAULA::Value_Complex
 Value_Complex (ValueType Type)
 Constructor.
 
- Protected Member Functions inherited from JAULA::Value
 Value (ValueType Type)
 Constructor.
 

Detailed Description

Class for handling object values.

This class is a container for JSON objects
Author
Kombo Morongo moron.nosp@m.go66.nosp@m.6@gma.nosp@m.il.c.nosp@m.om

Member Typedef Documentation

◆ dataType

typedef std::map<std::string, Value *> JAULA::Value_Object::dataType

Data type for value contents.

Description
Definition for the data container internal structure.
This data type defines a map of pointers to any kind of values (including objects) indexed by a property name that is always a string.

Constructor & Destructor Documentation

◆ Value_Object() [1/2]

JAULA::Value_Object::Value_Object ( void  )

Default Constructor.

Description
The default constructor initializes an empty object.

◆ Value_Object() [2/2]

JAULA::Value_Object::Value_Object ( Value_Object::dataType const &  data)

Data Constructor.

Parameters
dataReference to the data to be copied
Description
This constructor generates a new instance by making a deep copy of the original data.

References data_, and JAULA::Value::duplicate().

◆ ~Value_Object()

JAULA::Value_Object::~Value_Object ( )
virtual

Destructor.

Note
The destruction process releases all the memory associated to the data structure so any reference to the object or any element in it will be void.

References clear().

Member Function Documentation

◆ clear()

void JAULA::Value_Object::clear ( void  )
virtual

Empties the contents of an instance.

Description
Erases the contained array.
Note
As the array is destroyed by the process, any references to it or to any of its elements will be void.

Implements JAULA::Value_Complex.

References data_.

Referenced by set(), and ~Value_Object().

◆ empty()

bool JAULA::Value_Object::empty ( void  ) const
virtual

True if the instance is empty.

Returns
true if there are no single elements contained in the object and false otherwise.

Implements JAULA::Value_Complex.

References data_.

◆ getData()

Value_Object::dataType const & JAULA::Value_Object::getData ( void  ) const

Retrieves the map of values contained by the instance.

References data_.

Referenced by JAULA::Value::duplicate(), and set().

◆ insertItem()

void JAULA::Value_Object::insertItem ( std::string const &  name,
Value const &  item 
)
throw (Name_Duplicated
)

Inserts one item to the object.

Parameters
nameName for the property to insert
itemItem value to be inserted
Exceptions
Name_DuplicatedThis exception is thrown in case the object already has a property with the same name as the one to insert.
Description
Inserts a deep copy of the item value at the specified name fot the object.

◆ repr()

void JAULA::Value_Object::repr ( std::ostream &  ostr) const
virtual

Represents the instance in a stream.

Parameters
ostrStream where the instance is to be represented.
Description
writes the instance content in JSON notation in a stream.

Implements JAULA::Value.

References data_.

◆ set() [1/2]

void JAULA::Value_Object::set ( dataType const &  data)

Establishes the contents of the instance.

Parameters
datamap of values to assign to the instance
Note
The destination object is destroyed during the asignment process so, any references to it or to its former elements will be void.

References clear(), data_, and JAULA::Value::duplicate().

◆ set() [2/2]

void JAULA::Value_Object::set ( Value const &  origin)
throw (Bad_Data_Type
)
virtual

Copies the contents of one instance into another.

Parameters
originReference to the value to be copied.
Exceptions
Bad_Data_TypeThis exception is launched in case that origin and destination value types are different.
Note
The destination object is destroyed during the asignment process so, any references to it or to its former elements will be void.

Reimplemented from JAULA::Value.

References JAULA::Exception::addOrigin(), getData(), and JAULA::Value::set().

◆ size()

size_t JAULA::Value_Object::size ( void  ) const
virtual

Number of elements contained.

Returns
the number of single elements contained by the object.

Implements JAULA::Value_Complex.

References data_.

Field Documentation

◆ data_

dataType JAULA::Value_Object::data_
private

Container to hold the value itself.

Referenced by clear(), empty(), getData(), repr(), set(), size(), and Value_Object().


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


Back to JAULA Project Documentation Page.

Go to JAULA Project Home Page.


Copyright (c) 2007, 2008, 2009 Kombo Morongo.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".

API Reference Generated for jaula by

doxygen

jaula project hosted by

SourceForge.net