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
14#include <mlTypeDefs.h>
15#include <FMEThirdPartyWarningsDisable.h>
16#include <string>
17#include <vector>
18#include <FMEThirdPartyWarningsRestore.h>
19
20ML_START_NAMESPACE
21
22class PagedImage;
23
24//----------------------------------------------------------------------------------
26//----------------------------------------------------------------------------------
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
267ML_END_NAMESPACE
Project global and OS specific declarations.
#define MLRELEASE_TOOLS_EXPORT
DLL export macro definition.
MLuint64 MLuint
Definition mlTypeDefs.h:505
double MLdouble
Definition mlTypeDefs.h:216
MLint64 MLint
Definition mlTypeDefs.h:489
Collection of some string tools.
MLRELEASE_TOOLS_EXPORT std::string toSize_tStr(size_t val, signed char fieldWidth=-1, bool padWithZeros=false)
MLRELEASE_TOOLS_EXPORT StringVector splitAtLineBreaks(const std::string &value)
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)
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)
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)
MLRELEASE_TOOLS_EXPORT StringVector split(const std::string &value, const std::string &sep)
MLRELEASE_TOOLS_EXPORT std::vector< size_t > createIndexList(size_t numIndexes, std::string idxExp, std::string &resultInfo)
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)
MLRELEASE_TOOLS_EXPORT std::string toDblStr(MLdouble val, signed char fieldWidth=-1, signed char numDecimalPlaces=-1, bool padWithZeros=false, bool considerValAsFloat=false)
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)
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::string replaceAllStr1ByStr2(const std::string &inStr, const std::string &str1, const std::string &str2)
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=' ')
MLRELEASE_TOOLS_EXPORT const std::string DefaultLineSeparator
MLRELEASE_TOOLS_EXPORT std::string terminateWithSingleEndString(const std::string &inStr, const std::string &endStr)
Returns inStr+endStr if endStr is still not at the end of inStr, otherwise it returns inStr.
MLRELEASE_TOOLS_EXPORT std::string toMLIntStr(MLint val, signed char fieldWidth=-1, bool padWithZeros=false)
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.