MeVisLab Toolbox Reference
ml::TextStringParserTools Namespace Reference

A collection of string tools useful for DICOM/ML IO projects. More...

Functions

ML_MLToDicomTools_EXPORT std::string toPagedImgStr (const PagedImage &imgProps, const std::string &lineEndStr)
 Converts a PagedImage property description to a std::string and returns it.
 
ML_MLToDicomTools_EXPORT std::string extractLine (const std::string &source, MLErrorCode &err, size_t &readPos)
 Extraction from std::string.
 
ML_MLToDicomTools_EXPORT MLErrorCode extractLine (const std::string &srcStr, const std::string &parseFormatStr, std::string &targetVal, size_t &readPos)
 Extracts one line starting at readPos, reads parseFormatStr and reads targetVal; readPos is incremented to position after read for subsequent calls.
 
ML_MLToDicomTools_EXPORT MLErrorCode extractLine (const std::string &srcStr, const std::string &parseFormatStr, int &targetVal, size_t &readPos)
 Same as extractLine for int target values, only for one parameter.
 
ML_MLToDicomTools_EXPORT MLErrorCode extractLine (const std::string &srcStr, const std::string &parseFormatStr, MLint &targetVal, size_t &readPos)
 Same as extractLine for MLint target values, only for one parameter.
 
ML_MLToDicomTools_EXPORT MLErrorCode extractLine (const std::string &srcStr, const std::string &parseFormatStr, MLuint64 &targetVal, size_t &readPos)
 Same as extractLine for int target values, only for one parameter.
 
ML_MLToDicomTools_EXPORT MLErrorCode extractLine (const std::string &srcStr, const std::string &parseFormatStr, MLdouble &val, size_t &readPos)
 Extracts one line starting at readPos, reads parseFormatStr and writes it into val;! readPos is incremented to position after read for subsequent calls.
 
ML_MLToDicomTools_EXPORT MLErrorCode extractLine (const std::string &srcStr, const std::string &parseFormatStr, MLdouble &val0, MLdouble &val1, MLdouble &val2, MLdouble &val3, size_t &readPos)
 Extracts one line starting at readPos, reads parseFormatStr and writes it into val[0-3]; readPos is incremented to position after read for subsequent calls.
 
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 >
MLErrorCode extractLine6T (const std::string &srcStr, const std::string &parseFormatStr, T1 &val0, T2 &val1, T3 &val2, T4 &val3, T5 &val4, T6 &val5, int NUM_ELEMS, size_t &readPos)
 Extracts one line starting at readPos, reads parseFormatStr and writes it into val[0-5]; readPos is incremented to position after read for subsequent calls.
 
ML_MLToDicomTools_EXPORT MLErrorCode extractStringChunk (const std::string &srcStr, const std::string &introStr, size_t chunkSize, std::string &readStr, size_t &readPos)
 Expects introString at position readPos in srcStr, then a string of size chunkSize and a terminating cacheLineSep string.
 
ML_MLToDicomTools_EXPORT MLErrorCode extractPagedImgPropsFromString (const std::string &srcStr, PagedImage &imgProps, size_t &readPos)
 Reads one line starting at readPos, sets imgProps from read data and increments readPos to position after read data chunk.
 

Variables

ML_MLToDicomTools_EXPORT const char *const CacheLineSep
 Separator between cache file lines. Has a terminator at the line end for simple line end detection.
 

Detailed Description

A collection of string tools useful for DICOM/ML IO projects.

Function Documentation

◆ extractLine() [1/7]

ML_MLToDicomTools_EXPORT std::string ml::TextStringParserTools::extractLine ( const std::string & source,
MLErrorCode & err,
size_t & readPos )

Extraction from std::string.

Reads (starting from readPos) and returns the first string line terminated with CacheLineSep from source; readPos is incremented to position after read for subsequent calls. On failures (e.g. too long lines > 16383 chars) err returns a code != ML_RESULT_OK, on success ML_RESULT_OK.

References extractLine().

Referenced by extractLine(), extractLine(), extractLine(), extractLine(), extractLine(), extractLine(), extractLine(), and extractLine6T().

◆ extractLine() [2/7]

ML_MLToDicomTools_EXPORT MLErrorCode ml::TextStringParserTools::extractLine ( const std::string & srcStr,
const std::string & parseFormatStr,
int & targetVal,
size_t & readPos )

Same as extractLine for int target values, only for one parameter.

References extractLine().

◆ extractLine() [3/7]

ML_MLToDicomTools_EXPORT MLErrorCode ml::TextStringParserTools::extractLine ( const std::string & srcStr,
const std::string & parseFormatStr,
MLdouble & val,
size_t & readPos )

Extracts one line starting at readPos, reads parseFormatStr and writes it into val;! readPos is incremented to position after read for subsequent calls.

Returns ML_FILE_OR_DATA_STRUCTURE_CORRUPTED on parse failure, otherwise ML_RESULT_OK.

References extractLine().

◆ extractLine() [4/7]

ML_MLToDicomTools_EXPORT MLErrorCode ml::TextStringParserTools::extractLine ( const std::string & srcStr,
const std::string & parseFormatStr,
MLdouble & val0,
MLdouble & val1,
MLdouble & val2,
MLdouble & val3,
size_t & readPos )

Extracts one line starting at readPos, reads parseFormatStr and writes it into val[0-3]; readPos is incremented to position after read for subsequent calls.

Returns ML_FILE_OR_DATA_STRUCTURE_CORRUPTED on parse failure, otherwise ML_RESULT_OK.

References extractLine().

◆ extractLine() [5/7]

ML_MLToDicomTools_EXPORT MLErrorCode ml::TextStringParserTools::extractLine ( const std::string & srcStr,
const std::string & parseFormatStr,
MLint & targetVal,
size_t & readPos )

Same as extractLine for MLint target values, only for one parameter.

References extractLine().

◆ extractLine() [6/7]

ML_MLToDicomTools_EXPORT MLErrorCode ml::TextStringParserTools::extractLine ( const std::string & srcStr,
const std::string & parseFormatStr,
MLuint64 & targetVal,
size_t & readPos )

Same as extractLine for int target values, only for one parameter.

References extractLine().

◆ extractLine() [7/7]

ML_MLToDicomTools_EXPORT MLErrorCode ml::TextStringParserTools::extractLine ( const std::string & srcStr,
const std::string & parseFormatStr,
std::string & targetVal,
size_t & readPos )

Extracts one line starting at readPos, reads parseFormatStr and reads targetVal; readPos is incremented to position after read for subsequent calls.

Returns with ML_FILE_OR_DATA_STRUCTURE_CORRUPTED on parse failure, otherwise ML_RESULT_OK.

References extractLine().

◆ extractLine6T()

template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 >
MLErrorCode ml::TextStringParserTools::extractLine6T ( const std::string & srcStr,
const std::string & parseFormatStr,
T1 & val0,
T2 & val1,
T3 & val2,
T4 & val3,
T5 & val4,
T6 & val5,
int NUM_ELEMS,
size_t & readPos )

Extracts one line starting at readPos, reads parseFormatStr and writes it into val[0-5]; readPos is incremented to position after read for subsequent calls.

Returns ML_FILE_OR_DATA_STRUCTURE_CORRUPTED on parse failure, otherwise ML_RESULT_OK.

Definition at line 92 of file mlTextStringParserTools.h.

References extractLine(), extractLine6T(), ML_FILE_OR_DATA_STRUCTURE_CORRUPTED, ML_RESULT_OK, and mlrange_cast().

Referenced by extractLine6T().

◆ extractPagedImgPropsFromString()

ML_MLToDicomTools_EXPORT MLErrorCode ml::TextStringParserTools::extractPagedImgPropsFromString ( const std::string & srcStr,
PagedImage & imgProps,
size_t & readPos )

Reads one line starting at readPos, sets imgProps from read data and increments readPos to position after read data chunk.

Returns an error code != ML_RESULT_OK on parse failure, on success ML_RESULT_OK.

References extractPagedImgPropsFromString().

Referenced by extractPagedImgPropsFromString().

◆ extractStringChunk()

ML_MLToDicomTools_EXPORT MLErrorCode ml::TextStringParserTools::extractStringChunk ( const std::string & srcStr,
const std::string & introStr,
size_t chunkSize,
std::string & readStr,
size_t & readPos )

Expects introString at position readPos in srcStr, then a string of size chunkSize and a terminating cacheLineSep string.

If this matches all then the return code will be ML_RESULT_OK, readStr will be set to the chunkSize'ed string after introStr and readPos will be incremented to position after the CacheLineSep terminating the "read line". readStr will not be escaped not changed in any way. On no match the returned error code will differ from ML_RESULT_OK, readPos will be left unchanged, readStr will be set to "".

References extractStringChunk().

Referenced by extractStringChunk().

◆ toPagedImgStr()

ML_MLToDicomTools_EXPORT std::string ml::TextStringParserTools::toPagedImgStr ( const PagedImage & imgProps,
const std::string & lineEndStr )

Converts a PagedImage property description to a std::string and returns it.

Invalid properties are also coded and restored as an outdated PagedImage. The argument lineEndStr is appended as terminator for all lines.

References toPagedImgStr().

Referenced by toPagedImgStr().

Variable Documentation

◆ CacheLineSep

ML_MLToDicomTools_EXPORT const char* const ml::TextStringParserTools::CacheLineSep
extern

Separator between cache file lines. Has a terminator at the line end for simple line end detection.