ValueHolder.h

Classes

ValueHolder -- A holder for a value of any basic AIPS++ data type. (full description)

class ValueHolder

Interface

Public Members
ValueHolder() : itsRep(0)
explicit ValueHolder (Bool value)
explicit ValueHolder (uChar value)
explicit ValueHolder (Short value)
explicit ValueHolder (uShort value)
explicit ValueHolder (Int value)
explicit ValueHolder (uInt value)
explicit ValueHolder (Float value)
explicit ValueHolder (Double value)
explicit ValueHolder (const Complex& value)
explicit ValueHolder (const DComplex& value)
explicit ValueHolder (const Char* value)
explicit ValueHolder (const String& value)
explicit ValueHolder (const Array<Bool>& value)
explicit ValueHolder (const Array<uChar>& value)
explicit ValueHolder (const Array<Short>& value)
explicit ValueHolder (const Array<uShort>& value)
explicit ValueHolder (const Array<Int>& value)
explicit ValueHolder (const Array<uInt>& value)
explicit ValueHolder (const Array<Float>& value)
explicit ValueHolder (const Array<Double>& value)
explicit ValueHolder (const Array<Complex>& value)
explicit ValueHolder (const Array<DComplex>& value)
explicit ValueHolder (const Array<Array>& value)
explicit ValueHolder (const Record& value)
explicit ValueHolder (ValueHolderRep* rep) : itsRep (rep)
ValueHolder (const ValueHolder&)
~ValueHolder()
ValueHolder& operator= (const ValueHolder&)
Bool isNull() const
DataType dataType() const
Bool asBool () const
uChar asuChar () const
Short asShort () const
uShort asuShort () const
Int asInt () const
uInt asuInt () const
Float asFloat () const
Double asDouble () const
Complex asComplex () const
DComplex asDComplex() const
const String& asString () const
const Array<Bool> asArrayBool () const
const Array<uChar> asArrayuChar () const
const Array<Short> asArrayShort () const
const Array<uShort> asArrayuShort () const
const Array<Int> asArrayInt () const
const Array<uInt> asArrayuInt () const
const Array<Float> asArrayFloat () const
const Array<Double> asArrayDouble () const
const Array<Complex> asArrayComplex () const
const Array<DComplex> asArrayDComplex() const
const Array<String> asArrayString () const
const Record& asRecord () const
void toRecord (Record&, const RecordFieldId&) const
static ValueHolder fromRecord (const Record&, const RecordFieldId&)

Description

Review Status

Programs:
Tests:

Synopsis

Class ValueHolder is meant to be used for holding a single AIPS++ value. The value can be scalar or an array of any basic type (including complex and string). Also a Record value is possible. In this way varying typed data (e.g. the result of getCell in the table DO) can be packed in a strongly typed variable.
All unsigned integer type values are kept as signed 32-bit integers because scripting languages usually only support those types.

ValueHolder is an envelope class that holds a counted-referenced letter object ValueHolderRep.

Motivation

This class comes handy in passing arbitrary values from a DO to its environment.

Member Description

ValueHolder() : itsRep(0)

Construct a null object.

explicit ValueHolder (Bool value)
explicit ValueHolder (uChar value)
explicit ValueHolder (Short value)
explicit ValueHolder (uShort value)
explicit ValueHolder (Int value)
explicit ValueHolder (uInt value)
explicit ValueHolder (Float value)
explicit ValueHolder (Double value)
explicit ValueHolder (const Complex& value)
explicit ValueHolder (const DComplex& value)
explicit ValueHolder (const Char* value)
explicit ValueHolder (const String& value)
explicit ValueHolder (const Array<Bool>& value)
explicit ValueHolder (const Array<uChar>& value)
explicit ValueHolder (const Array<Short>& value)
explicit ValueHolder (const Array<uShort>& value)
explicit ValueHolder (const Array<Int>& value)
explicit ValueHolder (const Array<uInt>& value)
explicit ValueHolder (const Array<Float>& value)
explicit ValueHolder (const Array<Double>& value)
explicit ValueHolder (const Array<Complex>& value)
explicit ValueHolder (const Array<DComplex>& value)
explicit ValueHolder (const Array<Array>& value)
explicit ValueHolder (const Record& value)

Create the object for the given value.

explicit ValueHolder (ValueHolderRep* rep) : itsRep (rep)

Create a ValueHolder from a ValueHolderRep. It takes over the pointer and deletes it in the destructor.

ValueHolder (const ValueHolder&)

Copy constructor (reference semantics).

~ValueHolder()

Destructor.

ValueHolder& operator= (const ValueHolder&)

Assignment (reference semantics).

Bool isNull() const

Is this a null object?

DataType dataType() const

Get the data type (as defined in DataType.h).

Bool asBool () const
uChar asuChar () const
Short asShort () const
uShort asuShort () const
Int asInt () const
uInt asuInt () const
Float asFloat () const
Double asDouble () const
Complex asComplex () const
DComplex asDComplex() const
const String& asString () const
const Array<Bool> asArrayBool () const
const Array<uChar> asArrayuChar () const
const Array<Short> asArrayShort () const
const Array<uShort> asArrayuShort () const
const Array<Int> asArrayInt () const
const Array<uInt> asArrayuInt () const
const Array<Float> asArrayFloat () const
const Array<Double> asArrayDouble () const
const Array<Complex> asArrayComplex () const
const Array<DComplex> asArrayDComplex() const
const Array<String> asArrayString () const
const Record& asRecord () const

Get the value. It throws an exception if the data type is incorrect.

void toRecord (Record&, const RecordFieldId&) const

Put the value as a field in a record.

static ValueHolder fromRecord (const Record&, const RecordFieldId&)

Construct the object from the value in a record.