Streaming C++ API
sb::FieldValue Class Reference

A value a Field may take on. More...

#include <FieldValue.hpp>

Public Member Functions

 ~FieldValue ()
 Destructor. More...
 
 FieldValue (bool value)
 DataType::BOOL constructor. More...
 
 FieldValue (int value)
 DataType::INT constructor. More...
 
 FieldValue (double value)
 DataType::DOUBLE constructor. More...
 
 FieldValue (long long value)
 DataType::LONG constructor. More...
 
 FieldValue (const Timestamp &value)
 DataType::TIMESTAMP constructor. More...
 
 FieldValue (const char *value)
 DataType::STRING constructor. More...
 
 FieldValue (const std::string &value)
 DataType::STRING constructor. More...
 
 FieldValue (const DataType &type, const std::string &value)
 DataType::STRING, DataType::BLOB, and DataType::CAPTURE constructor. More...
 
 FieldValue (const Tuple &value)
 DataType::TUPLE constructor. More...
 
 FieldValue (const Function &value)
 DataType::FUNCTION constructor. More...
 
 FieldValue (const std::vector< FieldValue > &value)
 DataType::LIST constructor. More...
 
 FieldValue (const DataType &type, const CompleteDataType &elemType)
 Create an empty list of the specified element type. More...
 
 FieldValue (const FieldValue &fv)
 Copy constructor. More...
 
const FieldValueoperator= (const FieldValue &fv)
 Assignment operator. More...
 
bool operator== (const FieldValue &t) const
 
bool operator!= (const FieldValue &t) const
 
bool operator< (const FieldValue &t) const
 
bool operator> (const FieldValue &t) const
 
bool operator<= (const FieldValue &t) const
 
bool operator>= (const FieldValue &t) const
 
int compare (const FieldValue &fv) const
 Compare the current FieldValue against the provided FieldValue. More...
 
const CompleteDataTypegetCompleteType () const
 Get the CompleteDataType of this FieldValue. More...
 
const DataTypegetType () const
 Get the primitive DataType of this FieldValue. More...
 
bool sameType (const FieldValue &fv) const
 Returns true if this FieldValue and the provided FieldValue are of the same type. More...
 
std::string as_string () const
 Return a string representation of this FieldValue. More...
 
bool isNull () const
 Return true if this FieldValue represents a null value. More...
 
bool getBool () const
 Return the value of a boolean FieldValue. More...
 
int getInt () const
 Return the value of an integer FieldValue. More...
 
double getDouble () const
 Return the value of a double FieldValue. More...
 
long long getLong () const
 Return the value of a long FieldValue. More...
 
Timestamp getTimestamp () const
 Return the value of a Timestamp FieldValue as a Timestamp. More...
 
const std::string & getString () const
 Return the value of a string FieldValue. More...
 
const std::string & getBlob () const
 Return the value of a blob FieldValue as a string. More...
 
const TuplegetTuple () const
 Return the value of a Tuple FieldValue. More...
 
const std::string & getCapture () const
 Return the value of a Capture FieldValue, as a string Will throw an exception if this FieldValue is not of type DataType::CAPTURE. More...
 
const Function & getFunction () const
 Return the value of a Function FieldValue Will throw an exception if this FieldValue is not of type DataType::FUNCTION. More...
 
TuplegetTuple ()
 Return the value of a Tuple FieldValue as a mutable Tuple. More...
 
const std::vector< FieldValue > & getList () const
 Return the value of a List FieldValue. More...
 

Detailed Description

A value a Field may take on.

Also possibly a list element.
Has a type and some information of said type.

FieldValues are immutable. Calling an inappropriate getter will cause an error.

FieldValue fv(5); // this creates a FieldValue of DataType::INT
cout << fv.getInt() << "\n";
cout << fv.getBool() << "\n";

The first cout line will succeed; the second will throw an exception.

Constructor & Destructor Documentation

◆ ~FieldValue()

sb::FieldValue::~FieldValue ( )

Destructor.

◆ FieldValue() [1/13]

sb::FieldValue::FieldValue ( bool  value)

DataType::BOOL constructor.

◆ FieldValue() [2/13]

sb::FieldValue::FieldValue ( int  value)

DataType::INT constructor.

◆ FieldValue() [3/13]

sb::FieldValue::FieldValue ( double  value)

DataType::DOUBLE constructor.

◆ FieldValue() [4/13]

sb::FieldValue::FieldValue ( long long  value)

DataType::LONG constructor.

◆ FieldValue() [5/13]

sb::FieldValue::FieldValue ( const Timestamp value)

DataType::TIMESTAMP constructor.

◆ FieldValue() [6/13]

sb::FieldValue::FieldValue ( const char *  value)

DataType::STRING constructor.

◆ FieldValue() [7/13]

sb::FieldValue::FieldValue ( const std::string &  value)

DataType::STRING constructor.

◆ FieldValue() [8/13]

sb::FieldValue::FieldValue ( const DataType type,
const std::string &  value 
)

DataType::STRING, DataType::BLOB, and DataType::CAPTURE constructor.

◆ FieldValue() [9/13]

sb::FieldValue::FieldValue ( const Tuple value)

DataType::TUPLE constructor.

◆ FieldValue() [10/13]

sb::FieldValue::FieldValue ( const Function &  value)

DataType::FUNCTION constructor.

◆ FieldValue() [11/13]

sb::FieldValue::FieldValue ( const std::vector< FieldValue > &  value)

DataType::LIST constructor.

◆ FieldValue() [12/13]

sb::FieldValue::FieldValue ( const DataType type,
const CompleteDataType elemType 
)

Create an empty list of the specified element type.

◆ FieldValue() [13/13]

sb::FieldValue::FieldValue ( const FieldValue fv)

Copy constructor.

Member Function Documentation

◆ as_string()

std::string sb::FieldValue::as_string ( ) const

Return a string representation of this FieldValue.

◆ compare()

int sb::FieldValue::compare ( const FieldValue fv) const

Compare the current FieldValue against the provided FieldValue.

Null FieldValues are less than non-null FieldValues. Provides a total ordering over the set of possible FieldValues, so does not check types. Ordering of FieldValues of heterogeneous types is not guaranteed but is consistent.

Returns
-1 if the current FieldValue is less than the provided FieldValue, 0 if the current is equal to the provided FieldValue, and 1 if the current is greater than the provided FieldValue.

◆ getBlob()

const std::string & sb::FieldValue::getBlob ( ) const

Return the value of a blob FieldValue as a string.


Will throw an exception if this FieldValue is not of type DataType::BLOB.

◆ getBool()

bool sb::FieldValue::getBool ( ) const

Return the value of a boolean FieldValue.


Will throw an exception if this FieldValue is not of type DataType::BOOL.

◆ getCapture()

const std::string & sb::FieldValue::getCapture ( ) const

Return the value of a Capture FieldValue, as a string Will throw an exception if this FieldValue is not of type DataType::CAPTURE.

◆ getCompleteType()

const CompleteDataType & sb::FieldValue::getCompleteType ( ) const

Get the CompleteDataType of this FieldValue.

◆ getDouble()

double sb::FieldValue::getDouble ( ) const

Return the value of a double FieldValue.


Will throw an exception if this FieldValue is not of type DataType::DOUBLE.

◆ getFunction()

const Function & sb::FieldValue::getFunction ( ) const

Return the value of a Function FieldValue Will throw an exception if this FieldValue is not of type DataType::FUNCTION.

◆ getInt()

int sb::FieldValue::getInt ( ) const

Return the value of an integer FieldValue.


Will throw an exception if this FieldValue is not of type DataType::INT.

◆ getList()

const std::vector< FieldValue > & sb::FieldValue::getList ( ) const

Return the value of a List FieldValue.


Will throw an exception if this FieldValue is not of type DataType::LIST.

◆ getLong()

long long sb::FieldValue::getLong ( ) const

Return the value of a long FieldValue.


Will throw an exception if this FieldValue is not of type DataType::LONG.

◆ getString()

const std::string & sb::FieldValue::getString ( ) const

Return the value of a string FieldValue.


Will throw an exception if this FieldValue is not of type DataType::STRING.

◆ getTimestamp()

Timestamp sb::FieldValue::getTimestamp ( ) const

Return the value of a Timestamp FieldValue as a Timestamp.


Will throw an exception if this FieldValue is not of type DataType::TIMESTAMP.

◆ getTuple() [1/2]

Tuple & sb::FieldValue::getTuple ( )

Return the value of a Tuple FieldValue as a mutable Tuple.


Will throw an exception if this FieldValue is not of type DataType::TUPLE.

The caller takes on itself the responsibility of managing all concurrency.

◆ getTuple() [2/2]

const Tuple & sb::FieldValue::getTuple ( ) const

Return the value of a Tuple FieldValue.


Will throw an exception if this FieldValue is not of type DataType::TUPLE.

◆ getType()

const DataType & sb::FieldValue::getType ( ) const

Get the primitive DataType of this FieldValue.

◆ isNull()

bool sb::FieldValue::isNull ( ) const

Return true if this FieldValue represents a null value.

◆ operator=()

const FieldValue & sb::FieldValue::operator= ( const FieldValue fv)

Assignment operator.

◆ sameType()

bool sb::FieldValue::sameType ( const FieldValue fv) const

Returns true if this FieldValue and the provided FieldValue are of the same type.

"Of the same type" is defined as their CompleteDataType members being equivalent.


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