|
cisst-saw
|
#include <cmnDataFunctions.h>
Public Types | |
| enum | { IS_SPECIALIZED = 0 } |
| typedef _elementType | DataType |
Public Member Functions | |
| void CISST_EXPORT | Copy (mtsGenericObject &data, const mtsGenericObject &source) |
| void CISST_EXPORT | SerializeBinary (const mtsGenericObject &data, std::ostream &outputStream) CISST_THROW(std void CISST_EXPORT cmnData< mtsGenericObject >::DeSerializeBinary(mtsGenericObject &data, std::istream &inputStream, const cmnDataFormat &localFormat, const cmnDataFormat &remoteFormat) CISST_THROW(std void CISST_EXPORT cmnData< mtsGenericObject >::SerializeText(const mtsGenericObject &data, std::ostream &outputStream, const char delimiter) CISST_THROW(std std::string CISST_EXPORT cmnData< mtsGenericObject >::SerializeDescription(const mtsGenericObject &data, const char delimiter, const std::string &userDescription) |
| bool CISST_EXPORT | ScalarNumberIsFixed (const mtsGenericObject &data) |
| size_t CISST_EXPORT | ScalarNumber (const mtsGenericObject &data) |
Static Public Member Functions | |
| static std::string | HumanReadable (const DataType &data) |
| static void | Copy (DataType &data, const DataType &source) |
| static std::string | SerializeDescription (const DataType &data, const char delimiter, const std::string &userDescription="") |
| static size_t | SerializeBinary (const DataType &data, char *buffer, size_t bufferSize) |
| static size_t | DeSerializeBinary (DataType &data, const char *buffer, size_t bufferSize, const cmnDataFormat &CMN_UNUSED(localFormat), const cmnDataFormat &CMN_UNUSED(remoteFormat)) |
| static bool | ScalarNumberIsFixed (const DataType &data) |
Static Public Attributes | |
| static void static SerializeText(const DataType &data, std::ostream &outputStream, const char delimiter=',') CISST_THROW(std void static DeSerializeText(DataType &data, std::istream &inputStream, const char delimiter=',') CISST_THROW(std void static SerializeBinary(const DataType &data, std::ostream &outputStream) CISST_THROW(std void static DeSerializeBinary(DataType &data, std::istream &inputStream, const cmnDataFormat &localFormat, const cmnDataFormat &remoteFormat) CISST_THROW(std size_t | SerializeBinaryByteSize (const DataType &data) |
| static std::string static ScalarDescription(const DataType &data, const size_t index, const std::string &userDescription="") CISST_THROW(std double static Scalar(const DataType &data, const size_t index) CISST_THROW(std size_t | ScalarNumber (const DataType &data) |
cmnDataFunction. Data functions used to handle objects across the cisst libraries. All data function names use the prefix cmnData and the first parameter is the object currently manipulated.
The main principle is to rely on the compiler to find the proper class overload for each object type.
void cmnData<int>::HumanReadable(const int & data);
void cmnData<std::string>::HumanReadable(const std::string & data);
...
This approach allows to manipulate external data types by overloading the required cmnData class.
Error handling is based on standard exceptions using std::runtime_error.
| typedef _elementType cmnData< _elementType >::DataType |
|
static |
Copy the source to the data object. This allows to define mechanisms that might be more efficient than copy constructors and avoid the ambiguities of the assignment operator. For example, to copy a dynamic vector of simple object, it can be more efficient to use a memcpy than to iterate over each element and assign one by one.
| void CISST_EXPORT cmnData< mtsGenericObject >::Copy | ( | mtsGenericObject & | data, |
| const mtsGenericObject & | source ) |
|
static |
|
static |
Returns a human readable string describing a specific instance of an object.
| size_t CISST_EXPORT cmnData< mtsGenericObject >::ScalarNumber | ( | const mtsGenericObject & | data | ) |
|
static |
| bool CISST_EXPORT cmnData< mtsGenericObject >::ScalarNumberIsFixed | ( | const mtsGenericObject & | data | ) |
|
static |
Attempt to serialize the data object using the user provided buffer. The buffer size must be provided by the caller. The function first checks that the buffer is large enough and returns 0 otherwise. The function then serializes (binary format) the data object, modify the parameter bufferSize to reflect how much is left and return the number of bytes used.
| void CISST_EXPORT cmnData< mtsGenericObject >::SerializeBinary | ( | const mtsGenericObject & | data, |
| std::ostream & | outputStream ) const & |
|
static |
Provides a human readble string describing each element of the data object. This description is for all instances of the same "size". For example, if the data object is a dynamic vector of intergers of size 4, the delimiter is a comma and the user description is "V", the returned string would look like "V.size,v[0],v[1],v[2],v[3]".
|
static |
|
static |
Serializes each element of the data object in text format, separated by the user provided delimiter. Using the previous example, this method would stream the size followed by the 4 value: "4,11,22,33,44". I/O stream errors can lead to exceptions.
Set the value of the data object by deserializing each element from the input stream. The function will look for the user provided delimiter between the elements to deserialize. Using the previous example, the overloaded function for a dynamic vector will look for the size (4), attempt to resize the data vector to fit 4 elements, skip one delimiter (comma) and then attempt to deserialize 4 comma separated values from the input stream.
Serializes each element of the data object in binary format.
Returns the numbers of bytes required to stored the content of the data object. This function can be used to allocate a char buffer used to perform the serialization.