A base class for value classes which store specific primitive data types, e.g., IntegerValue
and RealValue
.
More...
#include <Value.h>
Public Types | |
enum | Type { EMPTY, NATURAL, INTEGER, REAL, SPECIAL } |
Indicates the data type stored in the | |
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 | |
}; |
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.
void * Value::getEmptyValue | ( | ) | const |
int64_t Value::getIntegerValue | ( | ) | const |
Return an integer value.
The type of the Value must be INTEGER.
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.
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.
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.
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 |
Return the type of the value.
Definition at line 22 of file Value.cpp.
References valueType.
Referenced by getEmptyValue(), getIntegerValue(), getNaturalValue(), getRealValue(), getSpecialValue(), Yosokumo::YosokumoProtobuf::makeProtobufCellFromCell(), Yosokumo::YosokumoProtobuf::makeProtobufSpecimenFromSpecimen(), and operator==().
bool Value::operator!= | ( | const Value & | rhs | ) | const |
bool Value::operator== | ( | const Value & | rhs | ) | const |
Equality operator - compare two Values
for equality.
rhs | the righthand side of the equality. |
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.
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().
union { ... } [protected] |
Definition at line 56 of file Value.h.
Referenced by getRealValue(), Yosokumo::RealValue::getValue(), and Yosokumo::RealValue::toString().
int64_t Yosokumo::Value::int_value |
Definition at line 54 of file Value.h.
Referenced by getIntegerValue(), Yosokumo::IntegerValue::getValue(), and Yosokumo::IntegerValue::toString().
uint64_t Yosokumo::Value::uint_value |
Definition at line 55 of file Value.h.
Referenced by getNaturalValue(), getSpecialValue(), Yosokumo::SpecialValue::getValue(), Yosokumo::NaturalValue::getValue(), Yosokumo::SpecialValue::toString(), and Yosokumo::NaturalValue::toString().
Type Yosokumo::Value::valueType [protected] |