PVData C++  8.0.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Member Functions | List of all members
epics::pvData::Convert Class Reference

Conversion and Copy facility for pvData. More...

#include <pv/convert.h>

Public Member Functions

void copy (PVFieldPtr const &from, PVFieldPtr const &to)
 
void getString (std::string *buf, PVFieldPtr const &pvField)
 
void getString (std::string *buf, PVField const *pvField, int indentLevel)
 
std::size_t fromString (PVStructurePtr const &pv, StringArray const &from, std::size_t fromStartIndex=0)
 
void fromString (PVScalarPtr const &pv, std::string const &from)
 
std::size_t fromString (PVScalarArrayPtr const &pv, std::string from)
 
std::size_t fromStringArray (PVScalarArrayPtr const &pv, std::size_t offset, std::size_t length, StringArray const &from, std::size_t fromOffset)
 
std::size_t toStringArray (PVScalarArrayPtr const &pv, std::size_t offset, std::size_t length, StringArray &to, std::size_t toOffset)
 
int8 toByte (PVScalarPtr const &pv)
 
int16 toShort (PVScalarPtr const &pv)
 
int32 toInt (PVScalarPtr const &pv)
 
int64 toLong (PVScalarPtr const &pv)
 
uint8 toUByte (PVScalarPtr const &pv)
 
uint16 toUShort (PVScalarPtr const &pv)
 
uint32 toUInt (PVScalarPtr const &pv)
 
uint64 toULong (PVScalarPtr const &pv)
 
float toFloat (PVScalarPtr const &pv)
 
double toDouble (PVScalarPtr const &pv)
 
std::string toString (PVScalarPtr const &pv)
 
void fromByte (PVScalarPtr const &pv, int8 from)
 
void fromShort (PVScalarPtr const &pv, int16 from)
 
void fromInt (PVScalarPtr const &pv, int32 from)
 
void fromLong (PVScalarPtr const &pv, int64 from)
 
void fromUByte (PVScalarPtr const &pv, uint8 from)
 
void fromUShort (PVScalarPtr const &pv, uint16 from)
 
void fromUInt (PVScalarPtr const &pv, uint32 from)
 
void fromULong (PVScalarPtr const &pv, uint64 from)
 
void fromFloat (PVScalarPtr const &pv, float from)
 
void fromDouble (PVScalarPtr const &pv, double from)
 

Static Public Member Functions

static ConvertPtr getConvert ()
 

Detailed Description

Conversion and Copy facility for pvData.

Convert between numeric types, convert any field to a string, or convert from a string to a scalar field.

Numeric conversions are between scalar numeric types or between arrays of numeric types. It is not possible to convert between a scalar and an array. Numeric conversions are between types: pvByte, pvShort, pvInt, pvLong, pvUByte, pvUShort, pvUInt, pvULong, pvFloat, or pvDouble.

getString converts any supported type to a std::string.

fromString converts a std::string to a scalar. fromStringArray converts an array of std::strings to a pvArray, which must have a scaler element type. A scalar field is a numeric field or pvBoolean or pvString.

All from methods put data into a PVField, e.g. from means where the PVField gets it's data.

Definition at line 47 of file convert.h.

Member Function Documentation

void epics::pvData::Convert::copy ( PVFieldPtr const &  from,
PVFieldPtr const &  to 
)
inline

Copy from a PVField to another PVField. This calls one on copyScalar, copyArray, copyStructure. The two arguments must be compatible.

Parameters
fromThe source.
toThe destination
Exceptions
std::invalid_argumentif the arguments are not compatible.
Deprecated:
use "to->copy[Unchecked](*from)" instead

Definition at line 60 of file convert.h.

void epics::pvData::Convert::fromByte ( PVScalarPtr const &  pv,
int8  from 
)
inline

Convert a PV from a byte

Parameters
pva PV
fromvalue to put into PV
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 224 of file convert.h.

void epics::pvData::Convert::fromDouble ( PVScalarPtr const &  pv,
double  from 
)
inline

Convert a PV from a double

Parameters
pva PV
fromvalue to put into PV
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 287 of file convert.h.

void epics::pvData::Convert::fromFloat ( PVScalarPtr const &  pv,
float  from 
)
inline

Convert a PV from a float

Parameters
pva PV
fromvalue to put into PV
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 280 of file convert.h.

void epics::pvData::Convert::fromInt ( PVScalarPtr const &  pv,
int32  from 
)
inline

Convert a PV from an int

Parameters
pva PV
fromvalue to put into PV
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 238 of file convert.h.

void epics::pvData::Convert::fromLong ( PVScalarPtr const &  pv,
int64  from 
)
inline

Convert a PV from a long

Parameters
pva PV
fromvalue to put into PV
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 245 of file convert.h.

void epics::pvData::Convert::fromShort ( PVScalarPtr const &  pv,
int16  from 
)
inline

Convert a PV from a short

Parameters
pva PV
fromvalue to put into PV
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 231 of file convert.h.

std::size_t epics::pvData::Convert::fromString ( PVStructurePtr const &  pv,
StringArray const &  from,
std::size_t  fromStartIndex = 0 
)

Convert from an array of std::string to a PVStructure

Parameters
pvThe PV.
fromThe array of std::string value to convert and put into a PV.
fromStartIndexThe first element if the array of strings.
Returns
The total number of fields that have been changed.
Exceptions
std::logic_errorif the array of std::string does not have a valid values.
void epics::pvData::Convert::fromString ( PVScalarPtr const &  pv,
std::string const &  from 
)
inline

Convert from a std::string to a PVScalar

Parameters
pvThe PV.
fromThe std::string value to convert and put into a PV.
Exceptions
std::logic_errorif the std::string does not have a valid value.

Definition at line 98 of file convert.h.

std::size_t epics::pvData::Convert::fromString ( PVScalarArrayPtr const &  pv,
std::string  from 
)

Convert from a std::string to a PVScalarArray. The std::string must be a comma separated set of values optionally enclosed in []

Parameters
pvThe PV.
fromThe std::string value to convert and put into a PV.
Returns
The number of elements converted.
Exceptions
std::invalid_argumentif the element Type is not a scalar.
std::logic_errorif the std::string does not have a valid array values.
std::size_t epics::pvData::Convert::fromStringArray ( PVScalarArrayPtr const &  pv,
std::size_t  offset,
std::size_t  length,
StringArray const &  from,
std::size_t  fromOffset 
)

Convert a PVScalarArray from a std::string array. The array element type must be a scalar.

Parameters
pvThe PV.
offsetStarting element in a PV.
lengthThe number of elements to transfer.
fromThe array of values to put into the PV.
fromOffsetStarting element in the source array.
Returns
The number of elements converted.
Exceptions
std::invalid_argumentif the element Type is not a scalar.
std::logic_errorif the std::string does not have a valid value.
void epics::pvData::Convert::fromUByte ( PVScalarPtr const &  pv,
uint8  from 
)
inline

Convert a PV from a ubyte

Parameters
pva PV
fromvalue to put into PV
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 252 of file convert.h.

void epics::pvData::Convert::fromUInt ( PVScalarPtr const &  pv,
uint32  from 
)
inline

Convert a PV from an uint

Parameters
pva PV
fromvalue to put into PV
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 266 of file convert.h.

void epics::pvData::Convert::fromULong ( PVScalarPtr const &  pv,
uint64  from 
)
inline

Convert a PV from a ulong

Parameters
pva PV
fromvalue to put into PV
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 273 of file convert.h.

void epics::pvData::Convert::fromUShort ( PVScalarPtr const &  pv,
uint16  from 
)
inline

Convert a PV from a ushort

Parameters
pva PV
fromvalue to put into PV
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 259 of file convert.h.

void epics::pvData::Convert::getString ( std::string buf,
PVFieldPtr const &  pvField 
)
inline

Convert a PVField to a string. If a PVField is a structure or array be prepared for a very long string.

Parameters
bufstring that will hold pvField converted to a string,
pvFieldThe PVField to convert to a string.

Definition at line 70 of file convert.h.

void epics::pvData::Convert::getString ( std::string buf,
PVField const *  pvField,
int  indentLevel 
)

Convert a PVField to a string. If a PVField is a structure or array be prepared for a very long string.

Parameters
bufstring that will hold pvField converted to a string,
pvFieldThe PVField to convert to a string.
indentLevelindentation level
int8 epics::pvData::Convert::toByte ( PVScalarPtr const &  pv)
inline

Convert a PV to a byte.

Parameters
pva PV
Returns
converted value

Definition at line 149 of file convert.h.

double epics::pvData::Convert::toDouble ( PVScalarPtr const &  pv)
inline

Convert a PV to a double

Parameters
pva PV
Returns
converted value
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 211 of file convert.h.

float epics::pvData::Convert::toFloat ( PVScalarPtr const &  pv)
inline

Convert a PV to a float

Parameters
pva PV
Returns
converted value
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 204 of file convert.h.

int32 epics::pvData::Convert::toInt ( PVScalarPtr const &  pv)
inline

Convert a PV to a int.

Parameters
pva PV
Returns
converted value
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 163 of file convert.h.

int64 epics::pvData::Convert::toLong ( PVScalarPtr const &  pv)
inline

Convert a PV to an long

Parameters
pva PV
Returns
converted value
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 170 of file convert.h.

int16 epics::pvData::Convert::toShort ( PVScalarPtr const &  pv)
inline

Convert a PV to a short.

Parameters
pva PV
Returns
converted value
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 156 of file convert.h.

std::string epics::pvData::Convert::toString ( PVScalarPtr const &  pv)
inline

Convert a PV to a std::string

Parameters
pva PV
Returns
converted value

Definition at line 217 of file convert.h.

std::size_t epics::pvData::Convert::toStringArray ( PVScalarArrayPtr const &  pv,
std::size_t  offset,
std::size_t  length,
StringArray to,
std::size_t  toOffset 
)

Convert a PVScalarArray to a std::string array.

Parameters
pvThe PV.
offsetStarting element in the PV array.
lengthNumber of elements to convert to the string array.
tostd::string array to receive the converted PV data.
toOffsetStarting element in the string array.
Returns
Number of elements converted.
uint8 epics::pvData::Convert::toUByte ( PVScalarPtr const &  pv)
inline

Convert a PV to a ubyte.

Parameters
pva PV
Returns
converted value

Definition at line 176 of file convert.h.

uint32 epics::pvData::Convert::toUInt ( PVScalarPtr const &  pv)
inline

Convert a PV to a uint.

Parameters
pva PV
Returns
converted value
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 190 of file convert.h.

uint64 epics::pvData::Convert::toULong ( PVScalarPtr const &  pv)
inline

Convert a PV to an ulong

Parameters
pva PV
Returns
converted value
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 197 of file convert.h.

uint16 epics::pvData::Convert::toUShort ( PVScalarPtr const &  pv)
inline

Convert a PV to a ushort.

Parameters
pva PV
Returns
converted value
Exceptions
std::invalid_argumentif the Type is not a numeric scalar

Definition at line 183 of file convert.h.


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