40 for(
unsigned int i = 0 ;
i < str.length( ) ;
i++ )
42 if ( str[
i ] != character )
53 for(
unsigned int i = 0 ;
i < str.length( ) ;
i++ )
55 char current_char = str[
i ];
57 if( current_char !=
'\n' && current_char !=
'\t' &&
58 current_char !=
'\v' && current_char !=
'\b' &&
59 current_char !=
'\r' && current_char !=
'\f' &&
60 current_char !=
'\a' )
77 int pos = straux.find_first_not_of(
' ' );
78 straux.erase( 0, pos );
81 for(
unsigned int i = 0 ;
i < straux.length( ) ; )
85 if ( straux[
i ] ==
' ' )
87 while( straux[
i ] ==
' ' )
100 if( temp[ temp.size( ) - 1 ] ==
' ' )
102 temp.resize( temp.size() - 1 );
111 String::size_type pos = str.find_last_not_of(
' ');
113 if (pos != String::npos)
116 pos = str.find_first_not_of(
' ');
117 if (pos != String::npos)
130 int ok = sscanf(str,
"%f", &retval);
143 int ok = sscanf(str,
"%d", &retval);
155 long unsigned int retval;
156 int ok = sscanf(str,
"%lu", &retval);
168 long long int retval;
169 int ok = sscanf(str,
"%lld", &retval);
187 if (exp > _width - 3)
190 advised_prec = _width - 2;
193 advised_prec = _width + (exp - 1) - 3;
194 if (advised_prec <= 0)
198 if (advised_prec < 0)
206 #if GCC_VERSION < 30300 208 std::ostrstream outs(aux,
sizeof(aux));
211 std::ostringstream outs;
222 if (_prec == -1 && _width > 7)
224 outs.precision(_width - 7);
225 outs.setf(std::ios::scientific);
228 outs.precision(_prec);
230 #if GCC_VERSION < 30301 232 outs << F << std::ends;
238 #if GCC_VERSION < 30300 243 String retval = outs.str();
244 int i = retval.find(
'\0');
247 retval = retval.substr(0, i);
273 for (
int i = 0;
i < width;
i++)
281 int digit = Iaux % 10;
283 aux[width--] =
'0' + digit;
288 return static_cast< String >(
"-") + aux;
290 return static_cast< String >(aux);
299 int ok = sscanf(str,
"%c", &readval);
313 if (_width < str.length())
314 return str.substr(0, _width);
317 return aux.append(_width - str.length(),
' ');
332 static_cast< String >(
333 "checkAngle: Not recognized angle type: " + str));
339 int first = _str.find_first_not_of(
"\n \t");
340 int last = _str.find_last_not_of(
"\n \t");
341 bool after_blank =
false;
343 for (
int i = first;
i <= last;
i++)
345 if (_str[
i] ==
' ' || _str[
i] ==
'\n' || _str[
i] ==
'\t')
366 if (retval.length() == 0)
369 if (c ==
'\"' || c ==
'\'')
370 retval = retval.substr(1, retval.length() - 1);
371 c = retval[retval.length()-1];
372 if (c ==
'\"' || c ==
'\'')
373 retval = retval.substr(0, retval.length() - 1);
375 *_str = strdup(retval.c_str());
385 size_t delimiterSize = delimiter.size();
386 if (input.size()== 0 || delimiterSize == 0)
389 size_t newPos, iPos = 0;
391 while ((newPos = input.find(delimiter, iPos))!=String::npos)
396 results.push_back(emptyString);
399 results.push_back(input.substr(iPos, newPos-iPos));
400 iPos = newPos+delimiterSize;
402 if (iPos>=input.size())
405 results.push_back(emptyString);
408 results.push_back(input.substr(iPos, String::npos));
409 return results.size();
416 while (_str[i] !=
'\0')
418 if (_str[i] >=
'A' && _str[i] <=
'Z')
427 while (_str[i] !=
'\0')
429 if (_str[i] >=
'A' && _str[i] <=
'Z')
439 if (i >= str.length())
441 int j = str.find_first_not_of(
" \t\n", i);
444 int k = str.find_first_of(
" \t\n", j + 1);
447 retval = str.substr(j, k - j + 1);
476 String::size_type lastPos = str.find_first_not_of(delimiters, 0);
478 String::size_type pos = str.find_first_of(delimiters, lastPos);
480 while (String::npos != pos || String::npos != lastPos)
483 tokens.push_back(str.substr(lastPos, pos - lastPos));
485 lastPos = str.find_first_not_of(delimiters, pos);
487 pos = str.find_first_of(delimiters, lastPos);
495 size_t uFindLen = tFind.length();
501 size_t uReplaceLen = tReplace.length();
503 for( ;(uPos = tOut.find(tFind, uPos)) != String::npos; )
505 tOut=tOut.replace( uPos, uFindLen, tReplace );
525 char *
memtok(
char **src,
char **_end,
const char *sep)
533 start += strspn(start, sep);
543 end = start + strcspn(start, sep);
553 void *
_memmem (
const void *haystack,
size_t haystack_len,
const void *needle,
size_t needle_len)
558 return (
void *) haystack;
562 if (haystack_len < needle_len)
566 const char *pNeedle=(
const char *) needle;
568 const char *
const last_possible = (
const char *) haystack + haystack_len - needle_len;
569 for (
const char *begin = (
const char *) haystack; begin <= last_possible; ++begin)
570 if (begin[0] == pNeedle[0] &&
571 !memcmp (begin+1, pNeedle + 1, needle_len - 1))
572 return (
void *) begin;
574 const char *begin=(
const char *) haystack;
575 const char *current=begin;
576 size_t remaining=haystack_len-needle_len+1;
577 int firstChar=(int)pNeedle[0];
580 const char *found=(
const char *) memchr(current, firstChar, remaining);
585 if (memcmp(found+1, pNeedle + 1, needle_len - 1)==0)
586 return (
void *)found;
589 remaining-=found-current+1;
604 char formatBuffer[1024];
606 va_start(args, format);
607 vsprintf (formatBuffer, format, args);
608 String result(formatBuffer);
619 char formatBuffer[1024];
622 va_start(args, format);
623 vsprintf (formatBuffer, format, args);
633 if (regcomp(&re, pattern.c_str(), REG_EXTENDED|REG_NOSUB) != 0)
637 int status = regexec(&re, inputString.c_str(), (size_t) 0, NULL, 0);
648 if(inputString.size() <= lineLength)
649 return ((
String)
"# " + inputString +
"\n");
650 std::istringstream iss(inputString);
651 std::ostringstream ss;
660 if (line.length() + word.length() > lineLength)
662 ss <<
"# " << line << std::endl;
672 ss <<
"# " << line << std::endl;
686 int len1 = strlen(str1);
687 int len2 = strlen(str2);
688 return (len1 >= len2) && (0 == strcmp(str1 + len1 - len2, str2));
char * firstWord(char *str)
bool endsWith(const char *str1, const char *str2)
String removeSpaces(const String &_str)
#define REPORT_ERROR(nerr, ErrormMsg)
Null pointer passed as parameter.
String WordWrap(const String &inputString, size_t lineLength)
int bestPrecision(float F, int _width)
String integerToString(int I, int _width, char fill_with)
std::vector< String > StringVector
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
char * memtok(char **src, char **_end, const char *sep)
void * _memmem(const void *haystack, size_t haystack_len, const void *needle, size_t needle_len)
void checkAngle(const String &str)
float textToFloat(const char *str)
int splitString(const String &input, const String &delimiter, StringVector &results, bool includeEmpties)
Incorrect argument received.
String simplify(const String &str)
String findAndReplace(const String &tInput, const String &tFind, const String &tReplace)
void removeQuotes(char **_str)
String removeChar(const String &str, char character)
void tokenize(const String &str, StringVector &tokens, const String &delimiters)
long long textToLongLong(const char *str)
void log10(Image< double > &op)
String stringToString(const String &str, size_t _width)
String escapeForRegularExpressions(const String &str)
bool matchRegExp(const String &inputString, const String &pattern)
String formatString(const char *format,...)
int textToInteger(const char *str)
char * firstToken(const char *str)
int charToInt(const char *str)
String unescape(const String &str)
String floatToString(float F, int _width, int _prec)
String nextToken(const String &str, size_t &i)
Incorrect value received.
size_t textToSizeT(const char *str)
void formatStringFast(String &str, const char *format,...)