86 static string NextWord(
string Line,
int &start,
char sep =
' ',
char alt_sep =
'\0');
97 static string PreviousWord(
string Line,
int &start,
char sep =
' ',
char alt_sep =
'\0');
104 static int GetStartWord(
string Line,
int CurrentPosition,
char sep =
' ');
111 static int GetEndWord(
string Line,
int CurrentPosition,
char sep =
' ');
118 static string ReplaceAll(
string InLine,
string ToReplace,
string By);
124 static void ltrim(std::string &s);
129 static void rtrim(std::string &s);
134 static void trim(std::string &s);
149 static int Find(
const char *search,
string Line);
157 static int rFind(
const char *search,
string Line);
164 static void ToLower(
string &Line);
165 static void ToUpper(
string &Line);
177 template <
class out_T,
class in_T >
static out_T
convert(
const in_T &t);
195 template <
class T >
static bool ToNumber(T &t,
const std::string &s, std::ios_base & (*f)(std::ios_base & ))
197 if(s.size() == 0)
return true;
198 std::istringstream iss(s);
199 return ! (iss >> f >> t).fail();
201 static bool IsDouble(
const std::string &s);
210 if(start >=
int(Line.size()))
216 string ToReplace = string(1, alt_sep);
217 string By = string(1, sep);
222 int wordlength =
GetEndWord(Line, start, sep) - start;
224 Word = Line.substr(start, wordlength);
237 if(start >=
int(Line.size()))
238 start = Line.size() - 1;
241 string ToReplace = string(1, alt_sep);
242 string By = string(1, sep);
245 while(Line[start] == sep)
247 int pos = Line.rfind(sep, start);
248 int wordlength = start - Line.rfind(sep, pos);
252 Word = Line.substr(0, start + 1);
256 Word = Line.substr(pos + 1, wordlength);
258 start -= wordlength + 1;
265 s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](
int ch)
267 return ! std::iswspace(ch);
274 s.erase(std::find_if(s.rbegin(), s.rend(), [](
int ch)
276 return ! std::iswspace(ch);
290 transform (Line.begin(), Line.end(),
292 (
int(*)(
int))tolower);
298 transform (Line.begin(), Line.end(),
300 (
int(*)(
int))toupper);
306 int pos = Line.find(sep, CurrentPosition);
307 if(pos ==
int(string::npos))
return CurrentPosition;
308 while(CurrentPosition <
int(Line.size()) && Line[CurrentPosition] == sep)
310 return CurrentPosition;
316 int pos = Line.find(sep, CurrentPosition);
318 if(pos ==
int(string::npos))
326 size_t Pos = Line.find(search);
327 if(Pos != string::npos )
return Pos;
334 size_t Pos = Line.rfind(search);
335 if(Pos != string::npos)
return Pos;
340template <
class out_T,
class in_T >
353 if(ToReplace == By)
return InLine;
355 int pos = InLine.find(ToReplace, start);
356 while(pos !=
int(string::npos))
358 InLine.replace(pos, ToReplace.size(), By);
360 pos = InLine.find(ToReplace, start);
367 std::istringstream i(s);
369 return ( (i >> temp) ?
true : false );
Class extracting fields from a string / line.
Definition StringLine.hxx:70
static string NextWord(string Line, int &start, char sep=' ', char alt_sep='\0')
Find the next word in a line.
Definition StringLine.hxx:207
static string ReplaceAll(string InLine, string ToReplace, string By)
Replace a sub-string by an other in a string.
Definition StringLine.hxx:351
static out_T convert(const in_T &t)
convert a input type (in_T) to another (out_T).
Definition StringLine.hxx:341
static void trim(std::string &s)
Remove spaces (trim) of the begining and the end of a string.
Definition StringLine.hxx:281
static bool ToNumber(T &t, const std::string &s, std::ios_base &(*f)(std::ios_base &))
try to convert a string to a number.
Definition StringLine.hxx:195
static void rtrim(std::string &s)
Remove ending spaces (trim) of a string.
Definition StringLine.hxx:272
static int Find(const char *search, string Line)
Find search in Line from the begining.
Definition StringLine.hxx:324
static void ToLower(string &Line)
convert a string to Lower case
Definition StringLine.hxx:288
static void ltrim(std::string &s)
Remove starting spaces (trim) a string.
Definition StringLine.hxx:263
static string PreviousWord(string Line, int &start, char sep=' ', char alt_sep='\0')
Find the previous word in a line.
Definition StringLine.hxx:230
static bool IsDouble(const std::string &s)
Definition StringLine.hxx:365
static void ToUpper(string &Line)
convert a string to Upper case
Definition StringLine.hxx:296
static int GetStartWord(string Line, int CurrentPosition, char sep=' ')
Find the start of a word in a line.
Definition StringLine.hxx:304
static int GetEndWord(string Line, int CurrentPosition, char sep=' ')
Find the end of a word in a line.
Definition StringLine.hxx:314
static int rFind(const char *search, string Line)
Find search in Line from the end.
Definition StringLine.hxx:332
the namespace of the Standard C++