Yosokumo::Value Class Reference

A base class for value classes which store specific primitive data types, e.g., IntegerValue and RealValue. More...

#include <Value.h>

Inheritance diagram for Yosokumo::Value:
Inheritance graph
[legend]

List of all members.

Public Types

enum  Type {
  EMPTY, NATURAL, INTEGER, REAL,
  SPECIAL
}
 

Indicates the data type stored in the Value, e.g., integer or real.

More...

Public Member Functions

 Value ()
 Default constructor for Value.
Type getType () const
 Return the type of the value.
void * getEmptyValue () const
 Return an empty value.
uint64_t getNaturalValue () const
 Return a natural value.
uint64_t getSpecialValue () const
 Return a special value.
int64_t getIntegerValue () const
 Return an integer value.
double getRealValue () const
 Return a real value.
bool operator== (const Value &rhs) const
 Equality operator - compare two Values for equality.
bool operator!= (const Value &rhs) const
 Inequality operator - compare two Values for inequality.
virtual std::string toString () const
 Return the value as a string.

Protected Member Functions

 Value (Type type, int64_t ival)
 Value (Type type, uint64_t uval)
 Value (Type type, double dval)

Protected Attributes

Type valueType
union {
   int64_t   int_value
   uint64_t   uint_value
   double   double_value
}; 

Detailed Description

A base class for value classes which store specific primitive data types, e.g., IntegerValue and RealValue.

Note that all storage is in the base class itself.

Definition at line 17 of file Value.h.


Member Enumeration Documentation

Indicates the data type stored in the Value, e.g., integer or real.

Enumerator:
EMPTY 

empty value.

NATURAL 

an unsigned integer.

INTEGER 

a signed integer.

REAL 

real, i.e., floating-point.

SPECIAL 

special value (represented as an unsigned integer).

Definition at line 24 of file Value.h.


Constructor & Destructor Documentation

Value::Value ( Type  type,
int64_t  ival 
) [protected]

Definition at line 10 of file Value.cpp.

Value::Value ( Type  type,
uint64_t  uval 
) [protected]

Definition at line 13 of file Value.cpp.

Value::Value ( Type  type,
double  dval 
) [protected]

Definition at line 16 of file Value.cpp.

Value::Value (  ) 

Default constructor for Value.

Definition at line 19 of file Value.cpp.


Member Function Documentation

void * Value::getEmptyValue (  )  const

Return an empty value.

The type of the Value must be EMPTY.

Returns:
an empty value.

Definition at line 27 of file Value.cpp.

References EMPTY, and getType().

Referenced by operator==().

int64_t Value::getIntegerValue (  )  const

Return an integer value.

The type of the Value must be INTEGER.

Returns:
an integer value.

Definition at line 45 of file Value.cpp.

References getType(), int_value, and INTEGER.

Referenced by Yosokumo::YosokumoProtobuf::makeProtobufCellFromCell(), Yosokumo::YosokumoProtobuf::makeProtobufSpecimenFromSpecimen(), and operator==().

uint64_t Value::getNaturalValue (  )  const

Return a natural value.

The type of the Value must be NATURAL.

Returns:
a natural value.

Definition at line 33 of file Value.cpp.

References getType(), NATURAL, and uint_value.

Referenced by Yosokumo::YosokumoProtobuf::makeProtobufCellFromCell(), Yosokumo::YosokumoProtobuf::makeProtobufSpecimenFromSpecimen(), and operator==().

double Value::getRealValue (  )  const

Return a real value.

The type of the Value must be REAL.

Returns:
a real value.

Definition at line 51 of file Value.cpp.

References double_value, getType(), and REAL.

Referenced by Yosokumo::YosokumoProtobuf::makeProtobufCellFromCell(), Yosokumo::YosokumoProtobuf::makeProtobufSpecimenFromSpecimen(), and operator==().

uint64_t Value::getSpecialValue (  )  const

Return a special value.

The type of the Value must be SPECIAL.

Returns:
a special value.

Definition at line 39 of file Value.cpp.

References getType(), SPECIAL, and uint_value.

Referenced by Yosokumo::YosokumoProtobuf::makeProtobufCellFromCell(), and operator==().

Value::Type Value::getType (  )  const
bool Value::operator!= ( const Value rhs  )  const

Inequality operator - compare two Values for inequality.

Parameters:
rhs the righthand side of the inequality.
Returns:
true if and only if this Values and the righthand side Values are not identically equal.

Definition at line 79 of file Value.cpp.

bool Value::operator== ( const Value rhs  )  const

Equality operator - compare two Values for equality.

Parameters:
rhs the righthand side of the equality.
Returns:
true if and only if this Values and the righthand side Values are identically equal.

Definition at line 59 of file Value.cpp.

References EMPTY, getEmptyValue(), getIntegerValue(), getNaturalValue(), getRealValue(), getSpecialValue(), getType(), INTEGER, NATURAL, REAL, and SPECIAL.

std::string Value::toString (  )  const [virtual]

Return the value as a string.

Returns:
the value as a string.

Reimplemented in Yosokumo::EmptyValue, Yosokumo::IntegerValue, Yosokumo::NaturalValue, Yosokumo::RealValue, and Yosokumo::SpecialValue.

Definition at line 84 of file Value.cpp.

Referenced by Yosokumo::Specimen::toString(), and Yosokumo::Cell::toString().


Member Data Documentation

union { ... } [protected]

Definition at line 50 of file Value.h.

Referenced by getType().


The documentation for this class was generated from the following files:
Generated on Mon May 13 09:19:12 2013 for C++ Yosokumo API by  doxygen 1.6.3