MeVisLab Toolbox Reference
mlReleaseToolsString.h
Go to the documentation of this file.
1 // Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2 // **InsertLicense** code
3 //----------------------------------------------------------------------------------
5 
10 //----------------------------------------------------------------------------------
11 #pragma once
12 
13 #include "MLReleaseToolsSystem.h"
14 #include <mlTypeDefs.h>
15 #include <ThirdPartyWarningsDisable.h>
16 #include <string>
17 #include <vector>
18 #include <ThirdPartyWarningsRestore.h>
19 
20 ML_START_NAMESPACE
21 
22 class PagedImage;
23 
24 //----------------------------------------------------------------------------------
26 //----------------------------------------------------------------------------------
27 namespace ReleaseToolsString {
28 
33  extern MLRELEASE_TOOLS_EXPORT const std::string DefaultLineSeparator;
34 
36  typedef std::vector< std::string > StringVector;
37 
39  typedef std::vector< StringVector > StringVectorVector;
40 
42  MLRELEASE_TOOLS_EXPORT std::string replaceAllChars(const std::string &str,
43  char ch1,
44  char ch2);
45 
47  MLRELEASE_TOOLS_EXPORT std::string escapeString(const std::string &str);
48 
50  MLRELEASE_TOOLS_EXPORT std::string unescapeString(const std::string &str);
51 
55  const std::string &str1,
56  const std::string &str2);
57 
60  MLRELEASE_TOOLS_EXPORT std::string replaceAllStr1ByStr2(const std::string &inStr,
61  const std::string &str1,
62  const std::string &str2);
63 
65  MLRELEASE_TOOLS_EXPORT std::string replaceNewLinesByBrs(const std::string &inStr);
66 
68  MLRELEASE_TOOLS_EXPORT std::string replaceBrsByNewLines(const std::string &inStr);
69 
71  MLRELEASE_TOOLS_EXPORT bool endsWith(const std::string &str, const std::string &endStr);
72 
74  MLRELEASE_TOOLS_EXPORT std::string terminateWithSingleEndString(const std::string &inStr,
75  const std::string &endStr);
76 
78  MLRELEASE_TOOLS_EXPORT std::string terminateWithSingleEndString(const std::string &inStr,
79  const std::string &endStr,
80  const std::string &endStr2);
81 
83  MLRELEASE_TOOLS_EXPORT std::string makeSingleNewlineTerminated(const std::string &inStr);
84 
87  MLRELEASE_TOOLS_EXPORT std::string convertLineEndingsToNewLinesOnly(const std::string &inStr);
88 
94  MLRELEASE_TOOLS_EXPORT StringVector split(const std::string &value,
95  const std::string &sep);
96 
103 
106  const std::string &str=std::string());
107 
110 
118  MLRELEASE_TOOLS_EXPORT std::string toIntStr(int val,
119  signed char fieldWidth=-1,
120  bool padWithZeros=false);
121 
129  signed char fieldWidth=-1,
130  bool padWithZeros=false);
131 
140  signed char fieldWidth=-1,
141  bool padWithZeros=false);
142 
150  MLRELEASE_TOOLS_EXPORT std::string toSize_tStr(size_t val,
151  signed char fieldWidth=-1,
152  bool padWithZeros=false);
153 
179  signed char fieldWidth=-1,
180  signed char numDecimalPlaces=-1,
181  bool padWithZeros=false,
182  bool considerValAsFloat=false);
184 
185 
223  MLRELEASE_TOOLS_EXPORT std::vector<size_t> createIndexList(size_t numIndexes,
224  std::string idxExp,
225  std::string &resultInfo);
226 
232  MLRELEASE_TOOLS_EXPORT void removeDuplicates(std::string &strToShrink,
233  char ch = ' ');
234 
258  MLRELEASE_TOOLS_EXPORT std::string replaceValuePlaceholders(const std::string &taggedStr,
259  const PagedImage *inImg=nullptr,
260  const std::vector<std::string> &inputValues = std::vector<std::string>(),
261  const std::string &defaultTagContent="",
262  const std::string &fileType="",
263  size_t idx=0,
264  size_t padSize=5);
265 };
266 
267 ML_END_NAMESPACE
Project global and OS specific declarations.
#define MLRELEASE_TOOLS_EXPORT
DLL export macro definition.
std::vector< std::string > StringVector
Class which represents an image, which manages properties of an image and image data which is located...
Definition: mlPagedImage.h:70
MLuint64 MLuint
An unsigned ML integer type with at least 64 bits used for index calculations on very large images ev...
Definition: mlTypeDefs.h:594
double MLdouble
Definition: mlTypeDefs.h:223
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:578
MLRELEASE_TOOLS_EXPORT std::string terminateWithSingleEndString(const std::string &inStr, const std::string &endStr, const std::string &endStr2)
Returns inStr + endStr if inStr does not end neither with endStr nor with endStr2,...
MLRELEASE_TOOLS_EXPORT std::string toSize_tStr(size_t val, signed char fieldWidth=-1, bool padWithZeros=false)
Tool function to convert a size_t to a string.
MLRELEASE_TOOLS_EXPORT StringVector splitAtLineBreaks(const std::string &value)
Subdivides value at all positions which seem to be a line ending, technically it returns split(conver...
MLRELEASE_TOOLS_EXPORT std::string escapeString(const std::string &str)
Replaces all spaces with '?'s.
MLRELEASE_TOOLS_EXPORT std::string toMLUIntStr(MLuint val, signed char fieldWidth=-1, bool padWithZeros=false)
Tool function to convert an MLuint to a string.
MLRELEASE_TOOLS_EXPORT std::string replaceValuePlaceholders(const std::string &taggedStr, const PagedImage *inImg=nullptr, const std::vector< std::string > &inputValues=std::vector< std::string >(), const std::string &defaultTagContent="", const std::string &fileType="", size_t idx=0, size_t padSize=5)
Replaces a number of tags of one of the following formats , $(0IDX), , $(0IMGEXTX),...
MLRELEASE_TOOLS_EXPORT void removeElements(StringVector &strVec, const std::string &str=std::string())
Removes all entries from strVec which equal to str; default is an empty string to remove all empty en...
MLRELEASE_TOOLS_EXPORT std::string convertLineEndingsToNewLinesOnly(const std::string &inStr)
Returns a converted inStr where 1) all appearances of "\r\n" and then 2) all appearances of "\r" are ...
MLRELEASE_TOOLS_EXPORT StringVector split(const std::string &value, const std::string &sep)
Subdivides value at all positions of sep and returns all values in the vector.
MLRELEASE_TOOLS_EXPORT std::string replaceNewLinesByBrs(const std::string &inStr)
Replaces all ' 's with "<br>"s.
MLRELEASE_TOOLS_EXPORT std::string makeSingleNewlineTerminated(const std::string &inStr)
Returns inStr + "\n" if inStr does not end neither with "\n" nor with "<br>", otherwise it returns in...
MLRELEASE_TOOLS_EXPORT void replaceAllStr1ByStr2InStr(std::string &inStr, const std::string &str1, const std::string &str2)
Replaces all occurrences of str1 in inStr by str2.
MLRELEASE_TOOLS_EXPORT std::string toDblStr(MLdouble val, signed char fieldWidth=-1, signed char numDecimalPlaces=-1, bool padWithZeros=false, bool considerValAsFloat=false)
Tool function to print an MLdouble value to a std::string.
std::vector< std::string > StringVector
Define often used string vector type.
MLRELEASE_TOOLS_EXPORT std::string toIntStr(int val, signed char fieldWidth=-1, bool padWithZeros=false)
Tool function to convert an integer to a string.
std::vector< StringVector > StringVectorVector
Define often used vector of string vector type.
MLRELEASE_TOOLS_EXPORT std::string replaceAllChars(const std::string &str, char ch1, char ch2)
Replaces all ch1 characters in str with ch2.
MLRELEASE_TOOLS_EXPORT std::vector< size_t > createIndexList(size_t numIndexes, std::string idxExp, std::string &resultInfo)
Creates a list of indexes by parsing the string expression idxExp.
MLRELEASE_TOOLS_EXPORT std::string replaceAllStr1ByStr2(const std::string &inStr, const std::string &str1, const std::string &str2)
Same as replaceAllStr1ByStr2InStr with the difference that the changed string is returned and inStr r...
MLRELEASE_TOOLS_EXPORT std::string unescapeString(const std::string &str)
Replaces all '?'s with spaces.
MLRELEASE_TOOLS_EXPORT void removeDuplicates(std::string &strToShrink, char ch=' ')
Multiple occurrences of ch in strToShrink are reduced to single ones in O(n).
MLRELEASE_TOOLS_EXPORT const std::string DefaultLineSeparator
The default line separator used for line endings when converting the internal string vector to a stri...
MLRELEASE_TOOLS_EXPORT std::string toMLIntStr(MLint val, signed char fieldWidth=-1, bool padWithZeros=false)
Tool function to convert an MLint to a string.
MLRELEASE_TOOLS_EXPORT bool endsWith(const std::string &str, const std::string &endStr)
Returns true if str ends with endStr, otherwise false.
MLRELEASE_TOOLS_EXPORT std::string replaceBrsByNewLines(const std::string &inStr)
Replaces all "<br>"s with ' 's.