jaula API Reference version 1.4.0
JAULA::Value Class Referenceabstract

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 moron.nosp@m.go66.nosp@m.6@gma.nosp@m.il.c.nosp@m.om

Member Enumeration Documentation

◆ ValueType

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

◆ ~Value()

JAULA::Value::~Value ( )
virtual

Destructor.

◆ Value()

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

◆ duplicate()

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_Array::getData(), JAULA::Value_Boolean::getData(), JAULA::Value_Number::getData(), JAULA::Value_Number_Int::getData(), JAULA::Value_Object::getData(), and JAULA::Value_String::getData().

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

◆ getType()

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_.

◆ operator=()

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().

◆ repr()

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<<().

◆ set()

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_Array::set(), JAULA::Value_Boolean::set(), JAULA::Value_Null::set(), JAULA::Value_Number::set(), JAULA::Value_Number_Int::set(), JAULA::Value_Object::set(), and JAULA::Value_String::set().

Field Documentation

◆ Type_

ValueType JAULA::Value::Type_
private

Container for error code.

Referenced by getType().


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