62 static string NextWord(
string Line,
int &start,
char sep=
' ',
char alt_sep=
'\0');
73 static string PreviousWord(
string Line,
int &start,
char sep=
' ',
char alt_sep=
'\0');
74 static void ToLower(
string &Line);
75 static void ToUpper(
string &Line);
84 static int Find(
const char *search,
string Line);
92 static int rFind(
const char *search,
string Line);
103 template <
class out_T,
class in_T>
static out_T convert(
const in_T & t);
121 template <
class T>
static bool ToNumber(T& t,
const std::string& s, std::ios_base& (*f)(std::ios_base&))
123 if(s.size()==0)
return true;
124 std::istringstream iss(s);
125 return !(iss >> f >> t).fail();
134 static int GetStartWord(
string Line,
int CurrentPosition,
char sep=
' ',
char alt_sep=
'\0');
142 static int GetEndWord(
string Line,
int CurrentPosition,
char sep=
' ',
char alt_sep=
'\0');
149 static string ReplaceAll(
string InLine,
string ToReplace,
string By);
150 static bool IsDouble(
const std::string& s);
158 if(start>=
int(Line.size()))
162 start=GetStartWord(Line,start,sep,alt_sep);
163 int wordlength=GetEndWord(Line,start,sep,alt_sep)-start;
165 Word=Line.substr(start,wordlength);
178 int pos=Line.rfind(sep,start);
184 alt_pos=Line.rfind(alt_sep,start);
185 real_pos=max(pos,alt_pos);
189 int wordlength=start-Line.rfind(real_sep,real_pos);
192 Word=Line.substr(0,start+1);
196 Word=Line.substr(real_pos+1,wordlength);
205 transform (Line.begin(), Line.end(),
207 (int(*)(int))tolower);
213 transform (Line.begin(), Line.end(),
215 (int(*)(int))toupper);
221 int pos=Line.find(sep,CurrentPosition);
224 alt_pos=Line.find(alt_sep,CurrentPosition);
229 real_pos=min(pos,alt_pos);
230 if(pos==
int(string::npos))real_pos=alt_pos;
234 if(real_pos==
int(string::npos))
return CurrentPosition;
235 while(CurrentPosition<
int(Line.size()) && Line[CurrentPosition]==real_sep)
237 return CurrentPosition;
243 int pos=Line.find(sep,CurrentPosition);
246 alt_pos=Line.find(alt_sep,CurrentPosition);
250 real_pos=min(pos,alt_pos);
251 if(pos==
int(string::npos))real_pos=alt_pos;
253 if(real_pos==
int(string::npos))
261 size_t Pos=Line.find(search);
262 if(Pos != string::npos )
return Pos;
269 size_t Pos=Line.rfind(search);
270 if(Pos != string::npos)
return Pos;
275 template <
class out_T,
class in_T>
289 int pos=InLine.find(ToReplace,start);
290 while(pos!=
int(string::npos))
292 InLine.replace(pos,ToReplace.size(),By);
294 pos=InLine.find(ToReplace,start);
301 std::istringstream i(s);
303 return ( (i >> temp) ?
true :
false );
static bool IsDouble(const std::string &s)
Definition: StringLine.hxx:299
static int Find(const char *search, string Line)
Find search in Line from the begining.
Definition: StringLine.hxx:259
static string ReplaceAll(string InLine, string ToReplace, string By)
Replace a sub-string by an other in a string.
Definition: StringLine.hxx:286
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:121
static string NextWord(string Line, int &start, char sep=' ', char alt_sep='\0')
Find the next word in a line.
Definition: StringLine.hxx:155
static string PreviousWord(string Line, int &start, char sep=' ', char alt_sep='\0')
Find the previous word in a line.
Definition: StringLine.hxx:171
static int rFind(const char *search, string Line)
Find search in Line from the end.
Definition: StringLine.hxx:267
static int GetStartWord(string Line, int CurrentPosition, char sep=' ', char alt_sep='\0')
Find the start of a word in a line.
Definition: StringLine.hxx:219
Class extracting fields from a string / line.
Definition: StringLine.hxx:49
static out_T convert(const in_T &t)
convert a input type (in_T) to another (out_T).
Definition: StringLine.hxx:276
static void ToUpper(string &Line)
convert a string to Upper case
Definition: StringLine.hxx:211
static int GetEndWord(string Line, int CurrentPosition, char sep=' ', char alt_sep='\0')
Find the end of a word in a line.
Definition: StringLine.hxx:241
static void ToLower(string &Line)
convert a string to Lower case
Definition: StringLine.hxx:203