VRS
A file format for sensor data.
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
vrs::DataPieceString Class Reference

DataPiece for variable length string. More...

#include <DataPieceString.h>

Inheritance diagram for vrs::DataPieceString:
vrs::DataPiece

Public Member Functions

 DataPieceString (const string &label)
 
 DataPieceString (const MakerBundle &bundle)
 
const string & getElementTypeName () const override
 
size_t getVariableSize () const override
 
size_t collectVariableData (int8_t *data, size_t bufferSize) override
 
void stage (const string &string)
 
void stage (string &&string)
 
const string & stagedValue () const
 
string & stagedValue ()
 
string get () const
 
bool get (string &outString) const
 
bool hasDefault () const
 Tell if a the DataPiece has a default value.
 
const string & getDefault () const
 Get the default string, if one was was set.
 
void setDefault (const string &defaultString)
 Set the default string, in case the DataLayout is mapped, but this DataPiece was not mapped.
 
void setDefault (string &&defaultString)
 Set the default string, in case the DataLayout is mapped, but this DataPiece was not mapped.
 
bool isAvailable () const override
 Tell if a value is available, in this DataLayout or the mapped DataLayout.
 
void print (ostream &out, const string &indent) const override
 
void printCompact (ostream &out, const string &indent) const override
 
bool isSame (const DataPiece *rhs) const override
 
void serialize (JsonWrapper &jsonWrapper, const JsonFormatProfileSpec &profile) override
 
bool stageCurrentValue () override
 
unique_ptr< DataPiececlone () const override
 
- Public Member Functions inherited from vrs::DataPiece
const DataLayoutgetDataLayout () const
 
const string & getLabel () const
 
DataPieceType getPieceType () const
 
string getTypeName () const
 
size_t getOffset () const
 
bool hasFixedSize () const
 
size_t getFixedSize () const
 
bool getTag (const string &tagName, string &outTag) const
 
void setTag (const string &tagName, const string &tag)
 
bool getUnit (string &outUnit) const
 
void setUnit (const string &unit)
 
bool getDescription (string &outDescription) const
 
void setDescription (const string &description)
 
void setRequired (bool required=true)
 
bool isRequired () const
 

Protected Member Functions

bool stageFrom (const DataPiece *original) override
 Stage value from another piece known to be of the same type.
 
- Protected Member Functions inherited from vrs::DataPiece
 DataPiece (const string &label, DataPieceType type, size_t size)
 
bool isMatch (const DataPiece &rhs) const
 Match signature only.
 
void setOffset (size_t offset)
 

Additional Inherited Members

- Protected Attributes inherited from vrs::DataPiece
const string label_
 
const DataPieceType pieceType_
 
const size_t fixedSize_
 
size_t offset_
 
DataLayoutlayout_
 
map< string, string > tags_
 
bool required_
 
- Static Protected Attributes inherited from vrs::DataPiece
static const string kUnit = "unit"
 Special tag name to specify a unit of the DataPiece.
 
static const string kDescription = "description"
 Special tag name to specify a human readable description the DataPiece.
 
static const string kMinValue = "min"
 Special property name for the minimum value of the DataPiece.
 
static const string kMaxValue = "max"
 Special property name for the maximum value of the DataPiece.
 
static const string kMinIncrement = "min_increment"
 Special property name for the minimum increment of the DataPiece.
 
static const string kMaxIncrement = "max_increment"
 Special property name for the maximum increment of the DataPiece.
 

Detailed Description

DataPiece for variable length string.

Written values are stored in the string member of this class (VRS record creation) Read values are extracted from the DataLayout's buffer, (VRS records reading/decoding)

Constructor & Destructor Documentation

◆ DataPieceString() [1/2]

vrs::DataPieceString::DataPieceString ( const string &  label)
inlineexplicit
Parameters
labelName for the DataPiece.

◆ DataPieceString() [2/2]

vrs::DataPieceString::DataPieceString ( const MakerBundle bundle)
explicit
Parameters
bundleBundle to reconstruct a DataPieceString from disk.

Member Function Documentation

◆ clone()

unique_ptr< DataPiece > vrs::DataPieceString::clone ( ) const
inlineoverridevirtual

Clone data piece.

Returns
A clone of the data piece, with the same label and same type. All the other data piece properties (default and staged values) are not cloned.

Implements vrs::DataPiece.

◆ collectVariableData()

size_t vrs::DataPieceString::collectVariableData ( int8_t *  data,
size_t  bufferSize 
)
overridevirtual

Copy the staged string to the location given.

Parameters
dataPointer where to write the staged string's characters.
bufferSizeMax number of bytes to write.
Returns
Number of characters written.

Implements vrs::DataPiece.

◆ get() [1/2]

string vrs::DataPieceString::get ( ) const

Get value read from disk, or default value.

Returns
The string value read from disk, or the default value.

◆ get() [2/2]

bool vrs::DataPieceString::get ( string &  outString) const

Get value read from disk, or default value.

Returns
True, if the value returned was read from the field or a mapped field.

◆ getElementTypeName()

const string & vrs::DataPieceString::getElementTypeName ( ) const
overridevirtual

Get the DataPiece element type name.

Returns
"string".

Implements vrs::DataPiece.

◆ getVariableSize()

size_t vrs::DataPieceString::getVariableSize ( ) const
inlineoverridevirtual

Get the size of the staged string, if any.

Returns
Number of bytes to store the staged string (not including a trailing 0).

Implements vrs::DataPiece.

◆ isAvailable()

bool vrs::DataPieceString::isAvailable ( ) const
overridevirtual

Tell if a value is available, in this DataLayout or the mapped DataLayout.

Implements vrs::DataPiece.

◆ isSame()

bool vrs::DataPieceString::isSame ( const DataPiece rhs) const
overridevirtual

Compare two DataPiece objects for their equivalence. Note: the values are not compared, all the other properties are (type, name, tags, etc).

Parameters
rhsOther DataPiece to compare to.
Returns
True if the DataPiece objects are considered the same.

Reimplemented from vrs::DataPiece.

◆ print()

void vrs::DataPieceString::print ( ostream &  out,
const string &  indent 
) const
overridevirtual

Print the DataPiece to the out stream, with many details, using indent text at the start of each line of output.

Parameters
outOutput stream to print to.
indentText to insert at the beginning of each output line, for indentation purposes.

Implements vrs::DataPiece.

◆ printCompact()

void vrs::DataPieceString::printCompact ( ostream &  out,
const string &  indent 
) const
overridevirtual

Print the DataPiece to the out stream in compact form, using indent text at the start of each line of output.

Parameters
outOutput stream to print to.
indentText to insert at the beginning of each output line, for indentation purposes.

Implements vrs::DataPiece.

◆ serialize()

void vrs::DataPieceString::serialize ( JsonWrapper &  jsonWrapper,
const JsonFormatProfileSpec profile 
)
overridevirtual

Export the DataPiece as json, using a specific profile.

Parameters
jsonWrapperWrapper around a json type (to isolate any 3rd party library dependency).
profileProfile describing what information needs to be exported as json.

Reimplemented from vrs::DataPiece.

◆ stage() [1/2]

void vrs::DataPieceString::stage ( const string &  string)
inline

Stage a string value. Note: does not modify the value returned by get().

Parameters
stringValue to stage.

◆ stage() [2/2]

void vrs::DataPieceString::stage ( string &&  string)
inline

Stage a string value. Note: does not modify the value returned by get().

Parameters
stringValue to stage.

◆ stageCurrentValue()

bool vrs::DataPieceString::stageCurrentValue ( )
inlineoverridevirtual

Take the current value of the field, and stage it for writing during record creation.

Returns
True if the value is available and was staged.

Reimplemented from vrs::DataPiece.

◆ stagedValue() [1/2]

string & vrs::DataPieceString::stagedValue ( )
inline

Get the staged value to write to disk, for read or write purposes. Note: the staged value is not the value read from disk.

Returns
A reference to the staged string value.

◆ stagedValue() [2/2]

const string & vrs::DataPieceString::stagedValue ( ) const
inline

Read-only access to the staged value. Note: the staged value is not the value read from disk.

Returns
A const reference to the staged string value.

◆ stageFrom()

bool vrs::DataPieceString::stageFrom ( const DataPiece original)
inlineoverrideprotectedvirtual

Stage value from another piece known to be of the same type.

Implements vrs::DataPiece.


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