a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
StringParser.hpp
Go to the documentation of this file.
1/*
2 * StringParser.hpp
3 *
4 * Created on: Jan 6, 2012
5 * Author: Ben O'Leary (benjamin.oleary@gmail.com)
6 *
7 * This file is part of BOLlib, released under the
8 * GNU General Public License. Please see the accompanying
9 * README.BOLlib.txt file for a full list of files, brief documentation
10 * on how to use these classes, and further details on the license.
11 */
12
13#ifndef STRINGPARSING_HPP_
14#define STRINGPARSING_HPP_
15
16#include <cstdio>
17#include <iostream>
18#include <string>
19#include <sstream>
20#include <vector>
21#include <list>
22#include "VectorlikeArray.hpp"
23#include "UsefulStuff.hpp"
24#include "StdVectorFiller.hpp"
25
26namespace BOL
27{
28 /* this is a class mainly of static functions for manipulating std::string
29 * instances. instances of the StringParser class are just for handy storage
30 * of custom arguments for some of these functions, such as doubleToString.
31 */
33 {
34 public:
35 static std::string const whitespaceChars;
36 static std::string const newlineChars;
37 static std::string const whitespaceAndNewlineChars;
38 static std::string const lowercaseAlphabetChars;
39 static std::string const uppercaseAlphabetChars;
40 static std::string const digitChars;
41
42 static int
43 numberOfDigitsInInt( int inputInt );
44 // this returns the number of digits of the int in base 10, ignoring '-'.
45 static std::string
46 intToString( int inputInt,
47 int const minimumNumberOfDigits,
48 std::string const prefixForPositiveNumbers = "+",
49 std::string const prefixForNegativeNumbers = "-",
50 char const paddingChar = '0' );
51 /* this returns a std::string that is the ASCII version of an int in base
52 * 10, prefixed with prefixForPositiveNumbers or prefixForNegativeNumbers
53 * depending on whether it is positive or negative. it makes returnString
54 * have at least minimumNumberOfDigits digit characters, filling it out
55 * with paddingChars after
56 * prefixForPositiveNumbers/prefixForNegativeNumbers
57 * (e.g. intToString( 23, 4, "+", "-" ) returns "+0023").
58 */
59 static std::string
60 intToSpacePaddedString( int inputInt,
61 int const minimumNumberOfChars,
62 std::string const prefixForPositiveNumbers = "+",
63 std::string const prefixForNegativeNumbers = "-" );
64 /* this returns a std::string that is the ASCII version of an int in base
65 * 10, prefixed with prefixForPositiveNumbers or prefixForNegativeNumbers
66 * depending on whether it is positive or negative. it makes returnString
67 * have at least minimumNumberOfChars characters in total, prepending
68 * spaces before prefixForPositiveNumbers/prefixForNegativeNumbers
69 * (e.g. intToString( 23, 5, "+", "-" ) returns " +23").
70 */
71 static std::string
72 doubleToString( double inputDouble,
73 int const numberOfMantissaDigits,
74 int const numberOfExponentDigits,
75 std::string const prefixForPositiveNumbers = "+",
76 std::string const prefixForNegativeNumbers = "-",
77 std::string const positiveExponentPrefix = "+",
78 std::string const negativeExponentPrefix = "-",
79 std::string const exponentCharacter = "E" );
80 /* this returns a std::string that is the ASCII version of a double in base
81 * 10, in the form specified thusly:
82 * 1st character: either "-" for negative numbers, or a "+" for
83 * positive numbers (or a string to replace this character),
84 * 2nd character: the 1st digit,
85 * 3rd character: the decimal point,
86 * then ( numberOfMantissaDigits - 1 ) digits following the
87 * decimal point (so that the mantissa is numberOfMantissaDigits
88 * digits plus a decimal point)
89 * then "E" (or a string to replace this character)
90 * then "+" or "-", depending on the sign of the exponent (or a string to
91 * replace this character),
92 * then the absolute value of the exponent, with preceding 0s to fill to
93 * numberOfExponentDigits digit characters.
94 * NaNs are returned as "NaN".
95 */
96 static bool
97 stringsMatchIgnoringCase( std::string const& firstString,
98 std::string const& secondString );
99 // this returns true if both strings would be identical if all their
100 // uppercase chars were converted to lowercase.
101 static void
102 transformToLowercase( std::string& stringToTransform );
103 static void
104 transformToUppercase( std::string& stringToTransform );
105 static void
106 substituteCharacterWith( std::string& stringToTransform,
107 char const charToBeReplaced,
108 char const charToBePutIn );
109 static std::string const&
110 ensureDirectoryExists( std::string const& fileName );
111 static int
112 stringToInt( std::string const& stringToInterpret );
113 static double
114 stringToDouble( std::string const& stringToInterpret );
115 static bool
116 stringIsDouble( std::string const& stringToInterpret,
117 double& doubleToSet );
118 /* this returns true if stringToInterpret is a floating-point number in
119 * scientific E notation (allowing 'E' or 'e'), and sets doubleToSet
120 * accordingly if so.
121 */
122 static std::vector< int >
123 stringToIntVector( std::string stringToInterpret );
124 /* this interprets a string of int separated by commas or semicolons, with
125 * optional whitespace, or just separated by whitespace, as a vector of
126 * ints.
127 */
128 static bool
129 charIsIn( char const queryChar,
130 std::string const& charSet );
131 static bool
132 isOnlyCharsIn( std::string const& queryString,
133 std::string const& charSet );
134 // this returns true if queryString consists only of chars in charSet.
135 static std::string
136 substringToFirst( std::string const& stringToParse,
137 VectorlikeArray< std::string > const& delimitersOfSubstring,
138 std::string* const remainderString = NULL );
139 /* this returns the substring of stringToParse from its beginning up to the
140 * first instance of any of the strings in delimitersOfSubstring within
141 * stringToParse. if stringToParse does not contain any of those strings as
142 * a substring, the whole of stringToParse is returned, otherwise the
143 * substring up to but not including the first of any found strings from
144 * delimitersOfSubstring is returned. if remainderString is not NULL, the
145 * remainder of stringToParse that is not returned is put into
146 * remainderString.
147 */
148 static std::string
149 substringToFirst( std::string const& stringToParse,
150 std::string const& delimiterOfSubstring,
151 std::string* const remainderString = NULL );
152 // this sets delimiterOfSubstring as the single element of stringVector &
153 // calls the above substringToFirst with stringVector.
154 static std::string
155 trimFromFront( std::string const& stringToTrim,
156 std::string const& charsToTrim );
157 /* this returns the substring of stringToTrim which has had all the chars
158 * removed which are in charsToTrim and appear in stringToTrim before the
159 * first char which is not in charsToTrim.
160 */
161 static std::string
162 trimFromBack( std::string const& stringToTrim,
163 std::string const& charsToTrim );
164 /* this returns the substring of stringToTrim which has had all the chars
165 * removed which are in charsToTrim and appear in stringToTrim after the
166 * last char which is not in charsToTrim.
167 */
168 static std::string
169 trimFromFrontAndBack( std::string const& stringToTrim,
170 std::string const& charsToTrim = whitespaceAndNewlineChars );
171 /* this returns the substring of stringToTrim which has had all the chars
172 * removed which are in charsToTrim and appear in stringToTrim before the
173 * first char which is not in charsToTrim and after the last char which is
174 * not in charsToTrim.
175 */
176 static std::string
177 firstWordOf( std::string const& stringToParse,
178 std::string* const remainderString = NULL,
179 std::string const& separatorChars = whitespaceChars );
180 /* this parses the first substring without any of the characters in
181 * separatorChars & returns it, filling remainderString with the rest if
182 * it is not NULL.
183 */
184 static void
185 parseByChar( std::string const& stringToParse,
186 VectorlikeArray< std::string >& destinationArray,
187 std::string const& divisionCharSet = whitespaceChars );
188 /* this goes through stringToParse & creates new strings with all
189 * characters between groups of 1 or more of any of the chars in
190 * divisionCharSet, & puts them (as new strings) in order at the end of
191 * destinationArray. the resulting strings in destinationArray will not
192 * contain *any* instances of *any* of the characters in divisionCharSet.
193 */
194 static void
195 parseByChar( std::string const& stringToParse,
196 VectorlikeArray< std::string >& destinationArray,
197 char const& divisionChar );
198 // this calls parseByChar with a string that consists just of divisionChar.
199 /*template< class ForwardIteratorOfString >
200 static std::string
201 joinWithSeparator( ForwardIteratorOfString const beginIterator,
202 ForwardIteratorOfString const endIterator,
203 std::string const& separatorString );*/
204 /* this returns a string that is the concatenation of all the strings from
205 * ForwardIterator beginIterator to ForwardIterator beginIterator,
206 * separated by separatorString.
207 */
208 static std::string
210 std::string const& separatorString );
211 // this returns a string that is the concatenation of all the strings in
212 // stringsToJoin separated by separatorString.
213 static std::string
214 joinWithSeparator( std::vector< std::string* > const& stringsToJoin,
215 std::string const& separatorString );
216 // this prepares destinationString so that is the concatenation of all the
217 // strings in stringsToJoin separated by separatorString.
218 static std::string
219 joinWithSeparator( std::list< std::string* > const& stringsToJoin,
220 std::string const& separatorString );
221 // this prepares destinationString so that is the concatenation of all the
222 // strings in stringsToJoin separated by separatorString.
223
225 char const paddingCharForInts = '0',
226 int const numberOfMantissaDigits = 6,
227 int const numberOfExponentDigits = 2,
228 std::string const prefixForPositiveNumbers = "+",
229 std::string const prefixForNegativeNumbers = "-",
230 std::string const positiveExponentPrefix = "+",
231 std::string const negativeExponentPrefix = "-",
232 std::string const exponentCharacter = "E" );
234
237 char const paddingCharForInts = '0',
238 int const numberOfMantissaDigits = 6,
239 int const numberOfExponentDigits = 2,
240 std::string const prefixForPositiveNumbers = "+",
241 std::string const prefixForNegativeNumbers = "-",
242 std::string const positiveExponentPrefix = "+",
243 std::string const negativeExponentPrefix = "-",
244 std::string const exponentCharacter = "E" );
245 // this sets the default values that the StringParser instance uses as the
246 // arguments for the static functions it calls with its own functions.
247 std::string
248 intToString( int inputInt ) const;
249 // this calls the static intToString with the StringParser instance's
250 // arguments.
251 std::string
252 doubleToString( double inputDouble ) const;
253 // this calls the static doubleToString with the StringParser instance's
254 // arguments.
255
256
257 protected:
258 static char const lowercaseMinusUppercase;
259
260 static char
261 charForSingleDigit( int const singleDigitAsInt );
262 static int
263 intForSingleDigit( char const singleDigitAsChar );
264 static void
265 fillNumberOfDigitsAndTenTo( int const positiveInt );
266 // this finds out how many digits, in base 10, positiveInt has, putting the
267 // result in numberOfDigits, getting tenToNumberOfDigits in the process.
268 static std::string
269 positiveIntToString( int positiveInt );
270 // this puts the digits of positiveInt into a std::string in the order of
271 // digit for highest power of 10 1st, & returns it.
272
281 std::string exponentCharacter;
282 };
283
284
285
286 inline int
288 // this returns the number of digits of the int in base 10, ignoring '-'.
289 {
290 if( 0 > inputInt )
291 {
292 inputInt = -inputInt;
293 }
294 int numberOfDigits( 1 );
295 int tenToNumberOfDigits( 10 );
296 while( inputInt >= tenToNumberOfDigits )
297 {
298 tenToNumberOfDigits *= 10;
299 ++numberOfDigits;
300 }
301 return numberOfDigits;
302 }
303
304 inline std::string
306 int const minimumNumberOfChars,
307 std::string const prefixForPositiveNumbers,
308 std::string const prefixForNegativeNumbers )
309 /* this returns a std::string that is the ASCII version of an int in base
310 * 10, prefixed with prefixForPositiveNumbers or prefixForNegativeNumbers
311 * depending on whether it is positive or negative. it makes returnString
312 * have at least minimumNumberOfChars characters in total, prepending
313 * spaces before prefixForPositiveNumbers/prefixForNegativeNumbers
314 * (e.g. intToString( 23, 5, "+", "-" ) returns " +23").
315 */
316 {
317 int
318 numberofSpaces( minimumNumberOfChars - numberOfDigitsInInt( inputInt ) );
319 if( 0 > inputInt )
320 {
321 --numberofSpaces;
322 }
323 std::string returnString( "" );
324 if( 0 < numberofSpaces )
325 {
326 returnString.append( (size_t)numberofSpaces,
327 ' ' );
328 }
329 returnString.append( intToString( inputInt,
330 1,
333 return returnString;
334 }
335
336 inline void
337 StringParser::transformToLowercase( std::string& stringToTransform )
338 {
339 for( int charCounter( stringToTransform.size() - 1 );
340 0 <= charCounter;
341 --charCounter )
342 // go through each character in the string:
343 {
344 if( ( 'A' <= stringToTransform[ charCounter ] )
345 &&
346 ( 'Z' >= stringToTransform[ charCounter ] ) )
347 // if it's an uppercase character, replace it with its lowercase:
348 {
349 stringToTransform[ charCounter ] += lowercaseMinusUppercase;
350 }
351 }
352 }
353
354 inline void
355 StringParser::transformToUppercase( std::string& stringToTransform )
356 {
357 for( int charCounter( stringToTransform.size() - 1 );
358 0 <= charCounter;
359 --charCounter )
360 // go through each character in the string:
361 {
362 if( ( 'a' <= stringToTransform[ charCounter ] )
363 &&
364 ( 'z' >= stringToTransform[ charCounter ] ) )
365 // if it's a lowercase character, replace it with its uppercase:
366 {
367 stringToTransform[ charCounter ] -= lowercaseMinusUppercase;
368 }
369 }
370 }
371
372 inline void
373 StringParser::substituteCharacterWith( std::string& stringToTransform,
374 char const charToBeReplaced,
375 char const charToBePutIn )
376 {
377 for( int charCounter( stringToTransform.size() - 1 );
378 0 <= charCounter;
379 --charCounter )
380 // go through each character in the string:
381 {
382 // if it's charToBeReplaced, replace it with charToBePutIn:
383 if( charToBeReplaced == stringToTransform[ charCounter ] )
384 {
385 stringToTransform[ charCounter ] = charToBePutIn;
386 }
387 }
388 }
389
390 inline std::string const&
391 StringParser::ensureDirectoryExists( std::string const& fileName )
392 {
393 if( std::string::npos != fileName.find_last_of( "/" ) )
394 {
395 std::string mkdirCommand( "mkdir -p " );
396 mkdirCommand.append( fileName,
397 0,
398 fileName.find_last_of( "/" ) );
399 int systemReturn( system( mkdirCommand.c_str() ) );
400 if( -1 == systemReturn )
401 {
402 std::cout
403 << std::endl
404 << "BOL::error! StringParser::ensureDirectoryExists( "
405 << fileName << " ) got a -1 from system(...); however, I have no"
406 << " idea what to do about it.";
407 std::cout << std::endl;
408 }
409 }
410 return fileName;
411 }
412
413 inline int
414 StringParser::stringToInt( std::string const& stringToInterpret )
415 {
416 int returnValue( 0 );
417 std::stringstream( stringToInterpret ) >> returnValue;
418 return returnValue;
419 }
420
421 inline double
422 StringParser::stringToDouble( std::string const& stringToInterpret )
423 {
424 double returnValue( UsefulStuff::notANumber );
425 std::stringstream( stringToInterpret ) >> returnValue;
426 return returnValue;
427 }
428
429 inline bool
430 StringParser::charIsIn( char const queryChar,
431 std::string const& charSet )
432 {
433 return ( std::string::npos != charSet.find( queryChar ) );
434 }
435
436 inline bool
437 StringParser::isOnlyCharsIn( std::string const& queryString,
438 std::string const& charSet )
439 // this returns true if queryString consists only of chars in charSet.
440 {
441 return ( queryString.empty()
442 ||
443 ( std::string::npos != queryString.find_first_not_of( charSet ) ) );
444 }
445
446 inline std::string
447 StringParser::substringToFirst( std::string const& stringToParse,
448 std::string const& delimiterOfSubstring,
449 std::string* const remainderString )
450 // this sets delimiterOfSubstring as the single element of stringVector &
451 // calls the above substringToFirst with stringVector.
452 {
453 VectorlikeArray< std::string > stringVector( 1 );
454 stringVector[ 0 ].assign( delimiterOfSubstring );
455 return substringToFirst( stringToParse,
456 stringVector,
457 remainderString );
458 }
459
460 inline std::string
461 StringParser::trimFromFront( std::string const& stringToTrim,
462 std::string const& charsToTrim )
463 /* this returns the substring of stringToTrim which has had all the chars
464 * removed which are in charsToTrim and appear in stringToTrim before the
465 * first char which is not in charsToTrim.
466 */
467 {
468 size_t
469 startOfReturnString( stringToTrim.find_first_not_of( charsToTrim ) );
470 if( std::string::npos == startOfReturnString )
471 {
472 return std::string( "" );
473 }
474 else
475 {
476 return std::string( ( stringToTrim.begin() + startOfReturnString ),
477 stringToTrim.end() );
478 }
479 }
480
481 inline std::string
482 StringParser::trimFromBack( std::string const& stringToTrim,
483 std::string const& charsToTrim )
484 /* this returns the substring of stringToTrim which has had all the chars
485 * removed which are in charsToTrim and appear in stringToTrim after the
486 * last char which is not in charsToTrim.
487 */
488 {
489 size_t endOfReturnString( stringToTrim.find_last_not_of( charsToTrim ) );
490 if( endOfReturnString == std::string::npos )
491 {
492 return "";
493 }
494 else
495 {
496 return std::string( stringToTrim.begin(),
497 ( stringToTrim.begin() + endOfReturnString + 1 ) );
498 }
499 }
500
501 inline std::string
502 StringParser::trimFromFrontAndBack( std::string const& stringToTrim,
503 std::string const& charsToTrim )
504 /* this returns the substring of stringToTrim which has had all the chars
505 * removed which are in charsToTrim and appear in stringToTrim before the
506 * first char which is not in charsToTrim and after the last char which is
507 * not in charsToTrim.
508 */
509 {
510 size_t
511 startOfReturnString( stringToTrim.find_first_not_of( charsToTrim ) );
512 if( startOfReturnString == std::string::npos )
513 {
514 return "";
515 }
516 else
517 {
518 return std::string( ( stringToTrim.begin() + startOfReturnString ),
519 ( stringToTrim.begin()
520 + stringToTrim.find_last_not_of( charsToTrim )
521 + 1 ) );
522 }
523 }
524
525 inline void
526 StringParser::parseByChar( std::string const& stringToParse,
527 VectorlikeArray< std::string >& destinationArray,
528 std::string const& divisionCharSet )
529 /* this goes through stringToParse & creates new strings with all
530 * characters between groups of 1 or more of any of the chars in
531 * divisionCharSet, & puts them (as new strings) in order at the end of
532 * destinationArray. the resulting strings in destinationArray will not
533 * contain *any* instances of *any* of the characters in divisionCharSet.
534 */
535 {
536 size_t wordStart( stringToParse.find_first_not_of( divisionCharSet ) );
537 size_t wordEnd( 0 );
538 while( std::string::npos != wordStart )
539 // if there are any more chars in stringToParse that are not in
540 // divisionCharSet, we have at least one substring to add.
541 {
542 wordEnd = stringToParse.find_first_of( divisionCharSet,
543 wordStart );
544 destinationArray.newEnd().assign( stringToParse.substr( wordStart,
545 ( wordEnd - wordStart ) ) );
546 if( std::string::npos != wordEnd )
547 {
548 wordStart = stringToParse.find_first_not_of( divisionCharSet,
549 wordEnd );
550 }
551 else
552 {
553 wordStart = std::string::npos;
554 }
555 }
556 }
557
558 inline void
559 StringParser::parseByChar( std::string const& stringToParse,
560 VectorlikeArray< std::string >& destinationArray,
561 char const& divisionChar )
562 // this calls parseByChar with a string that consists just of divisionChar.
563 {
564 parseByChar( stringToParse,
565 destinationArray,
566 std::string( 1,
567 divisionChar ) );
568 }
569
570 inline std::string
572 VectorlikeArray< std::string > const& stringsToJoin,
573 std::string const& separatorString )
574 // this prepares destinationString so that is the concatenation of all the
575 // strings in stringsToJoin separated by separatorString.
576 {
577 if( 0 < stringsToJoin.getSize() )
578 {
579 std::string returnString( stringsToJoin.getFront() );
580 for( int stringIndex( 1 );
581 stringsToJoin.getSize() > stringIndex;
582 ++stringIndex )
583 {
584 returnString.append( separatorString );
585 returnString.append( stringsToJoin[ stringIndex ] );
586 }
587 return returnString;
588 }
589 else
590 {
591 return std::string( "" );
592 }
593 }
594
595 inline std::string
597 std::vector< std::string* > const& stringsToJoin,
598 std::string const& separatorString )
599 // this prepares destinationString so that is the concatenation of all the
600 // strings in stringsToJoin separated by separatorString.
601 {
602 if( !(stringsToJoin.empty()) )
603 {
604 std::string returnString( *(stringsToJoin.front()) );
605 for( std::vector< std::string* >::const_iterator
606 stringIterator( stringsToJoin.begin() + 1 );
607 stringsToJoin.end() > stringIterator;
608 ++stringIterator )
609 {
610 returnString.append( separatorString );
611 returnString.append( *(*stringIterator) );
612 }
613 return returnString;
614 }
615 else
616 {
617 return std::string( "" );
618 }
619 }
620
621 inline std::string
623 std::list< std::string* > const& stringsToJoin,
624 std::string const& separatorString )
625 // this prepares destinationString so that is the concatenation of all the
626 // strings in stringsToJoin separated by separatorString.
627 {
628 if( !(stringsToJoin.empty()) )
629 {
630 std::list< std::string* >::const_iterator
631 stringIterator( stringsToJoin.begin() );
632 std::string returnString( *(*stringIterator) );
633 ++stringIterator;
634 while( stringsToJoin.end() != stringIterator )
635 {
636 returnString.append( separatorString );
637 returnString.append( *(*stringIterator) );
638 ++stringIterator;
639 }
640 return returnString;
641 }
642 else
643 {
644 return std::string( "" );
645 }
646 }
647
648 inline StringParser&
649 StringParser::setDefaults( int const minimumNumberOfDigitsForInts,
650 char const paddingCharForInts,
651 int const numberOfMantissaDigits,
652 int const numberOfExponentDigits,
653 std::string const prefixForPositiveNumbers,
654 std::string const prefixForNegativeNumbers,
655 std::string const positiveExponentPrefix,
656 std::string const negativeExponentPrefix,
657 std::string const exponentCharacter )
658 // this sets the default values that the StringParser instance uses as the
659 // arguments for the static functions it calls with its own functions.
660 {
661 this->minimumNumberOfDigitsForInts = minimumNumberOfDigitsForInts;
662 this->paddingCharForInts = paddingCharForInts;
663 this->numberOfMantissaDigits = numberOfMantissaDigits;
664 this->numberOfExponentDigits = numberOfExponentDigits;
665 this->prefixForPositiveNumbers.assign( prefixForPositiveNumbers );
666 this->prefixForNegativeNumbers.assign( prefixForNegativeNumbers );
667 this->positiveExponentPrefix.assign( positiveExponentPrefix );
668 this->negativeExponentPrefix.assign( negativeExponentPrefix );
669 this->exponentCharacter.assign( exponentCharacter );
670 return *this;
671 }
672
673 inline std::string
674 StringParser::intToString( int inputInt ) const
675 // this calls the static intToString with the StringParser instance's
676 // arguments.
677 {
678 return intToString( inputInt,
679 minimumNumberOfDigitsForInts,
680 prefixForPositiveNumbers,
681 prefixForNegativeNumbers,
682 paddingCharForInts );
683 }
684
685 inline std::string
686 StringParser::doubleToString( double inputDouble ) const
687 // this calls the static doubleToString with the StringParser instance's
688 // arguments.
689 {
690 return doubleToString( inputDouble,
691 numberOfMantissaDigits,
692 numberOfExponentDigits,
693 prefixForPositiveNumbers,
694 prefixForNegativeNumbers,
695 positiveExponentPrefix,
696 negativeExponentPrefix,
697 exponentCharacter );
698 }
699
700}
701
702#endif /* STRINGPARSING_HPP_ */
std::string prefixForPositiveNumbers
StringParser(int const minimumNumberOfDigitsForInts=6, char const paddingCharForInts='0', int const numberOfMantissaDigits=6, int const numberOfExponentDigits=2, std::string const prefixForPositiveNumbers="+", std::string const prefixForNegativeNumbers="-", std::string const positiveExponentPrefix="+", std::string const negativeExponentPrefix="-", std::string const exponentCharacter="E")
static void transformToLowercase(std::string &stringToTransform)
StringParser & setDefaults(int const minimumNumberOfDigitsForInts=6, char const paddingCharForInts='0', int const numberOfMantissaDigits=6, int const numberOfExponentDigits=2, std::string const prefixForPositiveNumbers="+", std::string const prefixForNegativeNumbers="-", std::string const positiveExponentPrefix="+", std::string const negativeExponentPrefix="-", std::string const exponentCharacter="E")
static std::string firstWordOf(std::string const &stringToParse, std::string *const remainderString=NULL, std::string const &separatorChars=whitespaceChars)
static std::string const uppercaseAlphabetChars
static std::string const lowercaseAlphabetChars
std::string positiveExponentPrefix
static std::string const whitespaceAndNewlineChars
static bool stringsMatchIgnoringCase(std::string const &firstString, std::string const &secondString)
static std::vector< int > stringToIntVector(std::string stringToInterpret)
static std::string const digitChars
static bool isOnlyCharsIn(std::string const &queryString, std::string const &charSet)
static int intForSingleDigit(char const singleDigitAsChar)
std::string negativeExponentPrefix
static std::string const whitespaceChars
static std::string trimFromBack(std::string const &stringToTrim, std::string const &charsToTrim)
static bool stringIsDouble(std::string const &stringToInterpret, double &doubleToSet)
static std::string const newlineChars
static std::string trimFromFrontAndBack(std::string const &stringToTrim, std::string const &charsToTrim=whitespaceAndNewlineChars)
static double stringToDouble(std::string const &stringToInterpret)
static std::string intToString(int inputInt, int const minimumNumberOfDigits, std::string const prefixForPositiveNumbers="+", std::string const prefixForNegativeNumbers="-", char const paddingChar='0')
static void transformToUppercase(std::string &stringToTransform)
static char const lowercaseMinusUppercase
static char charForSingleDigit(int const singleDigitAsInt)
std::string prefixForNegativeNumbers
static int numberOfDigitsInInt(int inputInt)
static bool charIsIn(char const queryChar, std::string const &charSet)
static std::string positiveIntToString(int positiveInt)
std::string exponentCharacter
static std::string doubleToString(double inputDouble, int const numberOfMantissaDigits, int const numberOfExponentDigits, std::string const prefixForPositiveNumbers="+", std::string const prefixForNegativeNumbers="-", std::string const positiveExponentPrefix="+", std::string const negativeExponentPrefix="-", std::string const exponentCharacter="E")
static std::string joinWithSeparator(VectorlikeArray< std::string > const &stringsToJoin, std::string const &separatorString)
static void substituteCharacterWith(std::string &stringToTransform, char const charToBeReplaced, char const charToBePutIn)
static std::string trimFromFront(std::string const &stringToTrim, std::string const &charsToTrim)
static std::string const & ensureDirectoryExists(std::string const &fileName)
static void fillNumberOfDigitsAndTenTo(int const positiveInt)
static std::string intToSpacePaddedString(int inputInt, int const minimumNumberOfChars, std::string const prefixForPositiveNumbers="+", std::string const prefixForNegativeNumbers="-")
static std::string substringToFirst(std::string const &stringToParse, VectorlikeArray< std::string > const &delimitersOfSubstring, std::string *const remainderString=NULL)
static int stringToInt(std::string const &stringToInterpret)
static void parseByChar(std::string const &stringToParse, VectorlikeArray< std::string > &destinationArray, std::string const &divisionCharSet=whitespaceChars)
static double const notANumber
Definition: UsefulStuff.hpp:28
StoredClass & getFront()
StoredClass & newEnd()