MeVisLab Toolbox Reference
ml::StringConversion Class Reference

The class StringConversion provides static methods to convert ML objects to and from strings. More...

#include <mlStringConversion.h>

Static Public Member Functions

String construction and destruction:
static char * newString (const std::string &str)
static void deleteString (char *str)
 Disposes a string created by newString(); NULL values as str are legal and will be ignored.
writeToStdString-Versions:
static std::string writeToStdString (unsigned char val)
 Converts an unsigned char to a std::string.
static std::string writeToStdString (char val)
 Converts a char to a std::string.
static std::string writeToStdString (unsigned short val)
 Converts an unsigned short to a std::string.
static std::string writeToStdString (short val)
 Converts a short to a std::string.
static std::string writeToStdString (MLuint32 val)
 Converts an uint32 to a std::string.
static std::string writeToStdString (MLint32 val)
 Converts an int32 to a std::string.
static std::string writeToStdString (unsigned long val)
 Converts an unsigned long to std::string.
static std::string writeToStdString (long val)
 Converts a long to a std::string.
static std::string writeToStdString (MLuint64 val)
 Converts an uint64 to a std::string.
static std::string writeToStdString (MLint64 val)
 Converts an int64 to a std::string.
static std::string writeToStdString (MLfloat val)
 Converts a float to a std::string.
static std::string writeToStdString (MLdouble val)
 Converts a double to a std::string.
static std::string writeToStdString (MLldouble val)
 Converts a long double to a std::string.
static std::string writeToStdString (const Vector2 &val)
 Converts a Vector2 to a std::string that can be parsed by readFromString().
static std::string writeToStdString (const Vector3 &val)
 Converts a Vector3 to a std::string that can be parsed by readFromString().
static std::string writeToStdString (const Vector4 &val)
 Converts a Vector4 to a std::string that can be parsed by readFromString().
static std::string writeToStdString (const Vector5 &val)
 Converts a Vector5 to a std::string that can be parsed by readFromString().
static std::string writeToStdString (const Vector6 &val)
 Converts a Vector6 to a std::string that can be parsed by readFromString().
static std::string writeToStdString (const Vector7 &val)
 Converts a Vector7 to a std::string that can be parsed by readFromString().
static std::string writeToStdString (const Vector8 &val)
 Converts a Vector8 to a std::string that can be parsed by readFromString().
static std::string writeToStdString (const Vector9 &val)
 Converts a Vector9 to a std::string that can be parsed by readFromString().
static std::string writeToStdString (const Vector10 &val)
 Converts a Vector10 to a std::string that can be parsed by readFromString().
static std::string writeToStdString (const Vector16 &val)
 Converts a Vector16 to a std::string that can be parsed by readFromString().
static std::string writeToStdString (const Vector32 &val)
 Converts a Vector32 to a std::string that can be parsed by readFromString().
static std::string writeToStdString (const Vector64 &val)
 Converts a Vector64 to a std::string that can be parsed by readFromString().
static std::string writeToStdString (const ImageVector &val)
 Converts a ImageVector to a std::string that can be parsed by readFromString().
static std::string writeToStdString (SubImageBox const &box)
 Converts a SubImageBox to a std::string that can be parsed by readFromString(SubImageBox&).
static std::string writeToStdString (SubImageBoxd const &box)
 Converts a SubImageBoxd to a std::string that can be parsed by readFromString(SubImageBoxd&).
static std::string writeToStdString (Matrix2 const &mat)
 Converts a Matrix2 to a std::string that can be parsed by readFromString().
static std::string writeToStdString (Matrix3 const &mat)
 Converts a Matrix3 to a std::string that can be parsed by readFromString().
static std::string writeToStdString (Matrix4 const &mat)
 Converts a Matrix4 to a std::string that can be parsed by readFromString().
static std::string writeToStdString (Matrix5 const &mat)
 Converts a Matrix5 to a std::string that can be parsed by readFromString().
static std::string writeToStdString (Matrix6 const &mat)
 Converts a Matrix6 to a std::string that can be parsed by readFromString().
static std::string writeToStdString (const Base *const obj)
 Writes a Base object to std::string.
static std::string writeToStdString (const Base &obj)
 Writes a Base object to std::string.
template<typename T>
static std::string writeToStdString (const std::vector< T > &vec, const std::string &separatorString)
static std::string writeToStdString (const std::string &str)
readFromString-Versions:
static bool readFromString (const std::string &arg, unsigned char &val)
static bool readFromString (const std::string &arg, char &val)
static bool readFromString (const std::string &arg, unsigned short &val)
static bool readFromString (const std::string &arg, short &val)
static bool readFromString (const std::string &arg, MLuint32 &val)
static bool readFromString (const std::string &arg, MLint32 &val)
static bool readFromString (const std::string &arg, MLuint64 &val)
static bool readFromString (const std::string &arg, MLint64 &val)
static bool readFromString (std::string const &arg, unsigned long &val)
static bool readFromString (std::string const &arg, long &val)
static bool readFromString (std::string const &arg, float &val)
static bool readFromString (std::string const &arg, double &val)
static bool readFromString (std::string const &arg, long double &val)
static bool readFromString (const std::string &vecstr, Vector2 &v)
static bool readFromString (const std::string &vecstr, Vector3 &v)
static bool readFromString (const std::string &vecstr, Vector4 &v)
static bool readFromString (const std::string &vecstr, Vector5 &v)
static bool readFromString (const std::string &vecstr, Vector6 &v)
static bool readFromString (const std::string &vecstr, Vector7 &v)
static bool readFromString (const std::string &vecstr, Vector8 &v)
static bool readFromString (const std::string &vecstr, Vector9 &v)
static bool readFromString (const std::string &vecstr, Vector10 &v)
static bool readFromString (const std::string &vecstr, Vector16 &v)
static bool readFromString (const std::string &vecstr, Vector32 &v)
static bool readFromString (const std::string &vecstr, Vector64 &v)
static bool readFromString (const std::string &vecstr, ImageVector &v)
static bool readFromString (const std::string &str, Matrix2 &val)
static bool readFromString (const std::string &str, Matrix3 &val)
static bool readFromString (const std::string &str, Matrix4 &val)
static bool readFromString (const std::string &str, Matrix5 &val)
static bool readFromString (const std::string &str, Matrix6 &val)
static bool readFromString (const std::string &arg, SubImageBox &val)
static bool readFromString (const std::string &arg, SubImageBoxd &val)
static bool readFromString (const std::string &source, Base &obj)
template<typename T>
static bool readFromString (const std::string &vecstr, std::vector< T > &vec, const std::string &separatorString)
static bool readFromString (const std::string &source, std::string &target)
Miscellaneous:
static MLint getFirstNonSpacePos (const std::string &str, MLint pos=0)
 Helper method returning the first non-space position starting from pos.

Detailed Description

The class StringConversion provides static methods to convert ML objects to and from strings.

Definition at line 29 of file mlStringConversion.h.

Member Function Documentation

◆ deleteString()

void ml::StringConversion::deleteString ( char * str)
static

Disposes a string created by newString(); NULL values as str are legal and will be ignored.

◆ getFirstNonSpacePos()

MLint ml::StringConversion::getFirstNonSpacePos ( const std::string & str,
MLint pos = 0 )
static

Helper method returning the first non-space position starting from pos.

◆ newString()

char * ml::StringConversion::newString ( const std::string & str)
staticnodiscard

Convenience method to create a copy of the string str allocated on the heap. On allocation failures and exceptions, it posts a fatal error and returns NULL if error handling allows continuing.

◆ readFromString() [1/36]

bool ml::StringConversion::readFromString ( const std::string & arg,
char & val )
static

Reads a value from string arg into val; it returns true if one value has been converted successfully; otherwise, it returns false.

◆ readFromString() [2/36]

bool ml::StringConversion::readFromString ( const std::string & arg,
MLint32 & val )
static

Reads a value from string arg into val; it returns true if one value has been converted successfully; otherwise, it returns false.

◆ readFromString() [3/36]

bool ml::StringConversion::readFromString ( const std::string & arg,
MLint64 & val )
static

Reads a value from string arg into val; it returns true if one value has been converted successfully; otherwise, it returns false.

◆ readFromString() [4/36]

bool ml::StringConversion::readFromString ( const std::string & arg,
MLuint32 & val )
static

Reads a value from string arg into val; it returns true if one value has been converted successfully; otherwise, it returns false.

◆ readFromString() [5/36]

bool ml::StringConversion::readFromString ( const std::string & arg,
MLuint64 & val )
static

Reads a value from string arg into val; it returns true if one value has been converted successfully; otherwise, it returns false.

◆ readFromString() [6/36]

bool ml::StringConversion::readFromString ( const std::string & arg,
short & val )
static

Reads a value from string arg into val; it returns true if one value has been converted successfully; otherwise, it returns false.

◆ readFromString() [7/36]

bool ml::StringConversion::readFromString ( const std::string & arg,
SubImageBox & val )
static

Reads a SubImageBox value val from string arg whose values are space separated; and returns true if all components have been converted; otherwise, it returns false. Syntax: v1 v2 where v1, v2 are of type ImageVector

◆ readFromString() [8/36]

bool ml::StringConversion::readFromString ( const std::string & arg,
SubImageBoxd & val )
static

Reads a SubImageBox value val from string arg whose values are space separated; and returns true if all components have been converted; otherwise, it returns false. Syntax: v1 v2 where v1, v2 are of type Vector6.

◆ readFromString() [9/36]

bool ml::StringConversion::readFromString ( const std::string & arg,
unsigned char & val )
static

Reads a value from string arg into val; it returns true if one value has been converted successfully; otherwise, it returns false.

Referenced by readFromString().

◆ readFromString() [10/36]

bool ml::StringConversion::readFromString ( const std::string & arg,
unsigned short & val )
static

Reads a value from string arg into val; it returns true if one value has been converted successfully; otherwise, it returns false.

◆ readFromString() [11/36]

bool ml::StringConversion::readFromString ( const std::string & source,
Base & obj )
static

Reads a Base object from string source to obj by calling obj.setPersistentState(source.c_str()). Method provided for convenience, better use setPersistentState() directly.

◆ readFromString() [12/36]

bool ml::StringConversion::readFromString ( const std::string & source,
std::string & target )
static

Reads a std::string object to std::string. This will of course just copy the provided string, but it is required to support using readFromString in templates that may have strings as argument type (e.g., to use readFromString for a std::vector< std::string >) .

◆ readFromString() [13/36]

bool ml::StringConversion::readFromString ( const std::string & str,
Matrix2 & val )
static

Reads a Matrix2 value val from string str whose values are space separated; and returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [14/36]

bool ml::StringConversion::readFromString ( const std::string & str,
Matrix3 & val )
static

Reads a Matrix3 value val from string str whose values are space separated; and returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [15/36]

bool ml::StringConversion::readFromString ( const std::string & str,
Matrix4 & val )
static

Reads a Matrix4 value val from string str whose values are space separated; and returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [16/36]

bool ml::StringConversion::readFromString ( const std::string & str,
Matrix5 & val )
static

Reads a Matrix5 value val from string str whose values are space separated; and returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [17/36]

bool ml::StringConversion::readFromString ( const std::string & str,
Matrix6 & val )
static

Reads a Matrix6 value val from string str whose values are space separated; and returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [18/36]

bool ml::StringConversion::readFromString ( const std::string & vecstr,
ImageVector & v )
static

Reads a ImageVector value v from string vecstr whose values are space separated; it returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [19/36]

template<typename T>
bool ml::StringConversion::readFromString ( const std::string & vecstr,
std::vector< T > & vec,
const std::string & separatorString )
inlinestatic

Reads a std::vector<T> from a string of the form that is generated by stdVectorToString(vec, separatorString) and returns true on success and false otherwise. The type T must be supported by one of the readFromString methods implemented in this class. separatorString must be non-NULL and correctly NULL-terminated.

Definition at line 323 of file mlStringConversion.h.

References readFromString(), and T.

◆ readFromString() [20/36]

bool ml::StringConversion::readFromString ( const std::string & vecstr,
Vector10 & v )
static

Reads a 10D double vector value v from string vecstr whose values are space separated; it returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [21/36]

bool ml::StringConversion::readFromString ( const std::string & vecstr,
Vector16 & v )
static

Reads a 16D double vector value v from string vecstr whose values are space separated; it returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [22/36]

bool ml::StringConversion::readFromString ( const std::string & vecstr,
Vector2 & v )
static

Reads a 2D double vector value v from string vecstr whose values are space separated; it returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [23/36]

bool ml::StringConversion::readFromString ( const std::string & vecstr,
Vector3 & v )
static

Reads a 3D double vector value v from string vecstr whose values are space separated; it returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [24/36]

bool ml::StringConversion::readFromString ( const std::string & vecstr,
Vector32 & v )
static

Reads a 32D double vector value v from string vecstr whose values are space separated; it returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [25/36]

bool ml::StringConversion::readFromString ( const std::string & vecstr,
Vector4 & v )
static

Reads a 4D double vector value v from string vecstr whose values are space separated; it returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [26/36]

bool ml::StringConversion::readFromString ( const std::string & vecstr,
Vector5 & v )
static

Reads a 5D double vector value v from string vecstr whose values are space separated; it returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [27/36]

bool ml::StringConversion::readFromString ( const std::string & vecstr,
Vector6 & v )
static

Reads a 6D double vector value v from string vecstr whose values are space separated; it returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [28/36]

bool ml::StringConversion::readFromString ( const std::string & vecstr,
Vector64 & v )
static

Reads a 64D double vector value v from string vecstr whose values are space separated; it returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [29/36]

bool ml::StringConversion::readFromString ( const std::string & vecstr,
Vector7 & v )
static

Reads a 7D double vector value v from string vecstr whose values are space separated; it returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [30/36]

bool ml::StringConversion::readFromString ( const std::string & vecstr,
Vector8 & v )
static

Reads a 8D double vector value v from string vecstr whose values are space separated; it returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [31/36]

bool ml::StringConversion::readFromString ( const std::string & vecstr,
Vector9 & v )
static

Reads a 9D double vector value v from string vecstr whose values are space separated; it returns true if all components have been converted; otherwise, it returns false.

◆ readFromString() [32/36]

bool ml::StringConversion::readFromString ( std::string const & arg,
double & val )
static

Reads a value from string arg into val; it returns true if one value has been converted successfully; otherwise, it returns false.

◆ readFromString() [33/36]

bool ml::StringConversion::readFromString ( std::string const & arg,
float & val )
static

Reads a value from string arg into val; it returns true if one value has been converted successfully; otherwise, it returns false.

◆ readFromString() [34/36]

bool ml::StringConversion::readFromString ( std::string const & arg,
long & val )
static

Reads a value from string arg into val; it returns true if one value has been converted successfully; otherwise, it returns false.

◆ readFromString() [35/36]

bool ml::StringConversion::readFromString ( std::string const & arg,
long double & val )
static

Reads a value from string arg into val; it returns true if one value has been converted successfully; otherwise, it returns false.

◆ readFromString() [36/36]

bool ml::StringConversion::readFromString ( std::string const & arg,
unsigned long & val )
static

Reads a value from string arg into val; it returns true if one value has been converted successfully; otherwise, it returns false.

◆ writeToStdString() [1/37]

std::string ml::StringConversion::writeToStdString ( char val)
static

Converts a char to a std::string.

◆ writeToStdString() [2/37]

std::string ml::StringConversion::writeToStdString ( const Base & obj)
static

Writes a Base object to std::string.

◆ writeToStdString() [3/37]

std::string ml::StringConversion::writeToStdString ( const Base *const obj)
static

Writes a Base object to std::string.

◆ writeToStdString() [4/37]

std::string ml::StringConversion::writeToStdString ( const ImageVector & val)
static

Converts a ImageVector to a std::string that can be parsed by readFromString().

◆ writeToStdString() [5/37]

std::string ml::StringConversion::writeToStdString ( const std::string & str)
static

Writes std::string object to std::string. This will of course just return the provided string, but it is required to support using writeToStdString in templates that may have strings as argument type (e.g., to use writeToStdString for a std::vector< std::string >)

◆ writeToStdString() [6/37]

template<typename T>
std::string ml::StringConversion::writeToStdString ( const std::vector< T > & vec,
const std::string & separatorString )
inlinestatic

Converts a std::vector value vec to a string where vector components will be separated by the string separatorString. The type T must be supported by one of the writeToString methods implemented in class StringConversion; the return value needs to be removed with StringConversion::deleteString().

Definition at line 157 of file mlStringConversion.h.

References writeToStdString().

◆ writeToStdString() [7/37]

std::string ml::StringConversion::writeToStdString ( const Vector10 & val)
static

Converts a Vector10 to a std::string that can be parsed by readFromString().

◆ writeToStdString() [8/37]

std::string ml::StringConversion::writeToStdString ( const Vector16 & val)
static

Converts a Vector16 to a std::string that can be parsed by readFromString().

◆ writeToStdString() [9/37]

std::string ml::StringConversion::writeToStdString ( const Vector2 & val)
static

Converts a Vector2 to a std::string that can be parsed by readFromString().

◆ writeToStdString() [10/37]

std::string ml::StringConversion::writeToStdString ( const Vector3 & val)
static

Converts a Vector3 to a std::string that can be parsed by readFromString().

◆ writeToStdString() [11/37]

std::string ml::StringConversion::writeToStdString ( const Vector32 & val)
static

Converts a Vector32 to a std::string that can be parsed by readFromString().

◆ writeToStdString() [12/37]

std::string ml::StringConversion::writeToStdString ( const Vector4 & val)
static

Converts a Vector4 to a std::string that can be parsed by readFromString().

◆ writeToStdString() [13/37]

std::string ml::StringConversion::writeToStdString ( const Vector5 & val)
static

Converts a Vector5 to a std::string that can be parsed by readFromString().

◆ writeToStdString() [14/37]

std::string ml::StringConversion::writeToStdString ( const Vector6 & val)
static

Converts a Vector6 to a std::string that can be parsed by readFromString().

◆ writeToStdString() [15/37]

std::string ml::StringConversion::writeToStdString ( const Vector64 & val)
static

Converts a Vector64 to a std::string that can be parsed by readFromString().

◆ writeToStdString() [16/37]

std::string ml::StringConversion::writeToStdString ( const Vector7 & val)
static

Converts a Vector7 to a std::string that can be parsed by readFromString().

◆ writeToStdString() [17/37]

std::string ml::StringConversion::writeToStdString ( const Vector8 & val)
static

Converts a Vector8 to a std::string that can be parsed by readFromString().

◆ writeToStdString() [18/37]

std::string ml::StringConversion::writeToStdString ( const Vector9 & val)
static

Converts a Vector9 to a std::string that can be parsed by readFromString().

◆ writeToStdString() [19/37]

std::string ml::StringConversion::writeToStdString ( long val)
static

Converts a long to a std::string.

◆ writeToStdString() [20/37]

std::string ml::StringConversion::writeToStdString ( Matrix2 const & mat)
static

Converts a Matrix2 to a std::string that can be parsed by readFromString().

◆ writeToStdString() [21/37]

std::string ml::StringConversion::writeToStdString ( Matrix3 const & mat)
static

Converts a Matrix3 to a std::string that can be parsed by readFromString().

◆ writeToStdString() [22/37]

std::string ml::StringConversion::writeToStdString ( Matrix4 const & mat)
static

Converts a Matrix4 to a std::string that can be parsed by readFromString().

◆ writeToStdString() [23/37]

std::string ml::StringConversion::writeToStdString ( Matrix5 const & mat)
static

Converts a Matrix5 to a std::string that can be parsed by readFromString().

◆ writeToStdString() [24/37]

std::string ml::StringConversion::writeToStdString ( Matrix6 const & mat)
static

Converts a Matrix6 to a std::string that can be parsed by readFromString().

◆ writeToStdString() [25/37]

std::string ml::StringConversion::writeToStdString ( MLdouble val)
static

Converts a double to a std::string.

◆ writeToStdString() [26/37]

std::string ml::StringConversion::writeToStdString ( MLfloat val)
static

Converts a float to a std::string.

◆ writeToStdString() [27/37]

std::string ml::StringConversion::writeToStdString ( MLint32 val)
static

Converts an int32 to a std::string.

◆ writeToStdString() [28/37]

std::string ml::StringConversion::writeToStdString ( MLint64 val)
static

Converts an int64 to a std::string.

◆ writeToStdString() [29/37]

std::string ml::StringConversion::writeToStdString ( MLldouble val)
static

Converts a long double to a std::string.

◆ writeToStdString() [30/37]

std::string ml::StringConversion::writeToStdString ( MLuint32 val)
static

Converts an uint32 to a std::string.

◆ writeToStdString() [31/37]

std::string ml::StringConversion::writeToStdString ( MLuint64 val)
static

Converts an uint64 to a std::string.

◆ writeToStdString() [32/37]

std::string ml::StringConversion::writeToStdString ( short val)
static

Converts a short to a std::string.

◆ writeToStdString() [33/37]

std::string ml::StringConversion::writeToStdString ( SubImageBox const & box)
static

Converts a SubImageBox to a std::string that can be parsed by readFromString(SubImageBox&).

◆ writeToStdString() [34/37]

std::string ml::StringConversion::writeToStdString ( SubImageBoxd const & box)
static

Converts a SubImageBoxd to a std::string that can be parsed by readFromString(SubImageBoxd&).

◆ writeToStdString() [35/37]

std::string ml::StringConversion::writeToStdString ( unsigned char val)
static

Converts an unsigned char to a std::string.

Referenced by writeToStdString().

◆ writeToStdString() [36/37]

std::string ml::StringConversion::writeToStdString ( unsigned long val)
static

Converts an unsigned long to std::string.

◆ writeToStdString() [37/37]

std::string ml::StringConversion::writeToStdString ( unsigned short val)
static

Converts an unsigned short to a std::string.


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