jaula API Reference version 1.4.0
JAULA::Value Class Reference

Base class for handling values. More...

#include <jaula_value.h>

Inheritance diagram for JAULA::Value:
JAULA::Value_Boolean JAULA::Value_Complex JAULA::Value_Null JAULA::Value_Number JAULA::Value_Number_Int JAULA::Value_String JAULA::Value_Array JAULA::Value_Object

Public Types

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

ValueType getType (void) const
 Retrieves the value type for the instance.
Valueoperator= (Value const &orig) throw (Bad_Data_Type)
 Assignment operator.
virtual void repr (std::ostream &ostr) const =0
 Represents the instance in a stream.
virtual void set (Value const &origin) throw (Bad_Data_Type)
 Copies the contents of one instance into another.
virtual ~Value ()
 Destructor.

Static Public Member Functions

static Valueduplicate (Value const &orig)
 Creates a duplicate of a value.

Protected Member Functions

 Value (ValueType Type)
 Constructor.

Private Attributes

ValueType Type_
 Container for error code.

Detailed Description

Base class for handling values.

This class is the abstract base for all the containers for values according to the JSON specification.
Author:
Kombo Morongo <morongo666@gmail.com>

Member Enumeration Documentation

Enumeration of available value types.

Enumerator:
TYPE_NULL 

JSON Null value JSON Boolean value

TYPE_BOOLEAN 

JSON String value

TYPE_STRING 

JSON Number value

TYPE_NUMBER 

JSON Number value adapted to hold integer quantities

TYPE_NUMBER_INT 

JSON Array of values

TYPE_ARRAY 

JSON Object


Constructor & Destructor Documentation

JAULA::Value::~Value ( ) [virtual]

Destructor.

JAULA::Value::Value ( ValueType  Type) [protected]

Constructor.

Parameters:
TypeType of value to be contained by the instance
Description
This method construct a new instance by specifying its type.
Note:
A ValueType for the instance is immutable during all the life cycle, this is the only method that permits specifying the value type.

Member Function Documentation

Value * JAULA::Value::duplicate ( Value const &  orig) [static]

Creates a duplicate of a value.

Parameters:
origOriginal instance to duplicate.
Returns:
a pointer to memory taken from the heap (by means of the new operator) and containing a deep copy of the original value.
Warning:
As this method returns a pointer to memory allocated from the heap, it is up to the caller to release once it is no longer needed in order to avoid leaks.

References JAULA::Exception::addOrigin(), JAULA::Value_Object::getData(), JAULA::Value_Array::getData(), JAULA::Value_Number::getData(), JAULA::Value_Number_Int::getData(), JAULA::Value_String::getData(), and JAULA::Value_Boolean::getData().

Referenced by JAULA::Value_Array::addItem(), JAULA::Value_Object::set(), JAULA::Value_Array::set(), JAULA::Value_Array::Value_Array(), and JAULA::Value_Object::Value_Object().

Value::ValueType JAULA::Value::getType ( void  ) const

Retrieves the value type for the instance.

Note:
Value types are immutable during instance's life cycle and can only be specified at construction time.

References Type_.

Value & JAULA::Value::operator= ( Value const &  orig) throw (Bad_Data_Type)

Assignment operator.

Parameters:
origOriginal instance to copy
Returns:
a reference to the destination instance
Exceptions:
Bad_Data_TypeThis exception is launched in case that origin and destination value types are different.
Description
Copies the contents of the original instance in the destination.
Note:
This method controls if destination and origin instances are the same so there is no trouble in a = a asignments.

References JAULA::Exception::addOrigin().

virtual void JAULA::Value::repr ( std::ostream &  ostr) const [pure 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.

Implemented in JAULA::Value_Array, JAULA::Value_Boolean, JAULA::Value_Null, JAULA::Value_Number, JAULA::Value_Number_Int, JAULA::Value_Object, and JAULA::Value_String.

Referenced by operator<<().

void JAULA::Value::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.

Reimplemented in JAULA::Value_Array, JAULA::Value_Boolean, JAULA::Value_Null, JAULA::Value_Number, JAULA::Value_Number_Int, JAULA::Value_Object, and JAULA::Value_String.

Referenced by JAULA::Value_String::set(), JAULA::Value_Object::set(), JAULA::Value_Number_Int::set(), JAULA::Value_Number::set(), JAULA::Value_Null::set(), JAULA::Value_Boolean::set(), and JAULA::Value_Array::set().


Field Documentation

Container for error code.

Referenced by getType().


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