Class DField



DField contains one or more values that are part of a DProtocol. Each value in the DField has the same base type, for example integers or strings. We can specify the number of expected values with setFieldRange, which lets the DProtocol verify that the number of values in received messages is correct.


DField(const string &name, FieldType type)

Create a new DField with the specified name and type. The name is used by DProtocol to refer to this DField. type specifies the type of variable this DField contains. It's one of the following values from the libdasyne::FieldType enumeration:

Unsigned integers: DA_UINT8_T  DA_UINT16_T  DA_UINT32_T  DA_UINT64_T
Signed integers:   DA_INT8_T   DA_INT16_T   DA_INT32_T   DA_INT64_T
Floating-point:    DA_FLOAT    DA_DOUBLE
Variable-length:   DA_STRING   DA_DBUFFER

Each of the integer types specifies the number of bits in the variable.


DField(const DField &source)

Creates a new DField that's a copy of source.


DField& operator= (const DField &source)

Sets this DField to be a copy of source.


void addDBuffer(DBuffer &newValue)

void addString(const string &newValue)

template <class T>
void addValue(T newValue)

Each of these functions appends newValue to the DField. addDBuffer and addString should be called if the DField type is DA_DBUFFER or DA_STRING, otherwise addValue should be used. If you'd like to add more than one value, call setFieldRange first.


void clear(void)

Removes all values from this DField.


void getDBuffer(unsigned int index, DBuffer &theValue)

void getString(unsigned int index, string &theValue)

template <class T>
void getValue(unsigned int index, T &theValue)

These functions set theValue to the value from the specified index. They throw an exception if index is out of bounds.


string name(void)

Returns this DField's unique name, set in the constructor.


void setFieldRange(uint64_t minEntries, uint64_t maxEntries)

Normally, a DField contains exactly one value. setFieldRange lets us create a field that can hold multiple values (maxEntries > 1) or a field that is optional (minEntries == 0).


uint64_t size(void)

Returns the number of values currently stored in this field.





















Back to class reference