31 #include "DTrackParse.hpp" 46 char* string_nextline(
char* str,
char* start,
int len)
53 if (*s ==
'\r' || *s ==
'\n')
59 return (*s) ? s : NULL;
75 char* string_get_i(
char* str,
int* i)
78 *i = ( int )strtol( str, &s, 10 );
79 return (s == str) ? NULL : s;
90 char* string_get_ui(
char* str,
unsigned int* ui)
93 *ui = (
unsigned int )strtoul( str, &s, 10 );
94 return (s == str) ? NULL : s;
105 char* string_get_d(
char* str,
double* d)
108 *d = strtod(str, &s);
109 return (s == str) ? NULL : s;
120 char* string_get_f(
char* str,
float* f)
123 *f = (float )strtod(str, &s);
124 return (s == str) ? NULL : s;
138 char* string_get_block(
char* str,
const char* fmt,
int* idat,
float* fdat,
double *ddat)
141 int index_i, index_f;
143 str = strchr( str,
'[' );
148 strend = strchr( str,
']' );
149 if ( strend == NULL )
155 index_i = index_f = 0;
161 str = string_get_i( str, &idat[ index_i++ ] );
169 str = string_get_f( str, &fdat[ index_f++ ] );
177 str = string_get_d( str, &ddat[ index_f++ ] );
202 char* string_get_word(
char* str, std::string& w)
210 strend = strchr( str,
' ' );
211 if ( strend == NULL )
215 while (*strend !=
'\0')
219 return (strend == str) ? NULL : strend;
221 w.assign(str, (
int )(strend - str));
233 char* string_get_quoted_text(
char* str, std::string& qt)
237 str = strchr( str,
'\"' );
244 strend = strchr( str,
'\"' );
245 if ( strend == NULL )
249 qt.assign(str, (
int )(strend - str));
257 size_t string_cmp_parameter(
const std::string& str,
size_t pos,
const std::string& par )
259 bool lastwasdigit =
false;
260 const char* p = par.c_str();
261 const char* s = str.c_str() + pos;
277 if ( ( *p ==
' ' ) || ( *s ==
' ' ) )
285 lastwasdigit =
false;
291 return std::string::npos;
294 lastwasdigit = ( ( *p >=
'0' ) && ( *p <=
'9' ) );
304 return s - str.c_str();