StringUtils.hpp File Reference


Detailed Description

StringUtils namespace and GPSTK string utility functions.

Definition in file StringUtils.hpp.

#include <string>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <regex.h>
#include <cctype>
#include <limits>
#include "Exception.hpp"

Include dependency graph for StringUtils.hpp:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Namespaces

namespace  gpstk
namespace  gpstk::StringUtils

Classes

class  StringException
 This is thrown instread of a std::exception when a gpstk::StringUtils function fails. More...
class  HexDumpDataConfig
 Class for configuring the appearance of hexDumpData() output. More...

Functions

void hexDumpData (std::ostream &s, const std::string &data, unsigned indent=0, HexDumpDataConfig cfg=HexDumpDataConfig())
 Perform a formatted hex-dump of the (potentially) binary data to the given stream.
void hexDumpData (std::ostream &s, const std::string &data, const std::string &tag, HexDumpDataConfig cfg=HexDumpDataConfig())
 Perform a formatted hex-dump of the (potentially) binary data to the given stream.
std::string & stripLeading (std::string &s, const std::string &aString, std::string::size_type num=std::string::npos) throw (StringException)
 Remove a string from the beginning of another string.
std::string stripLeading (const std::string &s, const std::string &aString, std::string::size_type num=std::string::npos) throw (StringException)
 Remove a string from the beginning of another string const version.
std::string & stripLeading (std::string &s, const char *pString, std::string::size_type num=std::string::npos) throw (StringException)
 Remove a string from the beginning of another string.
std::string stripLeading (const std::string &s, const char *pString, std::string::size_type num=std::string::npos) throw (StringException)
 Remove a string from the beginning of another string const version.
std::string & stripLeading (std::string &s, const char aCharacter, std::string::size_type num=std::string::npos) throw (StringException)
 Strip character(s) from the beginning of a string.
std::string stripLeading (const std::string &s, const char aCharacter, std::string::size_type num=std::string::npos) throw (StringException)
 Strip character(s) from the beginning of a string const version.
std::string & stripLeading (std::string &s, std::string::size_type num=std::string::npos) throw (StringException)
 Strip blanks from the beginning of a string.
std::string stripLeading (const std::string &s, std::string::size_type num=std::string::npos) throw (StringException)
 Strip blanks from the beginning of a string const version.
std::string & stripTrailing (std::string &s, const std::string &aString, std::string::size_type num=std::string::npos) throw (StringException)
 Remove a string from the end of another string.
std::string stripTrailing (const std::string &s, const std::string &aString, std::string::size_type num=std::string::npos) throw (StringException)
 Remove a string from the end of another string const version.
std::string & stripTrailing (std::string &s, const char *pString, std::string::size_type num=std::string::npos) throw (StringException)
 Remove a string from the end of another string.
std::string stripTrailing (const std::string &s, const char *pString, std::string::size_type num=std::string::npos) throw (StringException)
 Remove a string from the end of another string const version.
std::string & stripTrailing (std::string &s, const char aCharacter, std::string::size_type num=std::string::npos) throw (StringException)
 Strip character(s) from the end of a string.
std::string stripTrailing (const std::string &s, const char aCharacter, std::string::size_type num=std::string::npos) throw (StringException)
 Strip character(s) from the end of a string const version.
std::string & stripTrailing (std::string &s, std::string::size_type num=std::string::npos) throw (StringException)
 Strip blanks from the end of a string.
std::string stripTrailing (const std::string &s, std::string::size_type num=std::string::npos) throw (StringException)
 Strip blanks from the end of a string const version.
std::string & strip (std::string &s, const std::string &aString, std::string::size_type num=std::string::npos) throw (StringException)
 Remove a string from the beginning and end of another string.
std::string strip (const std::string &s, const std::string &aString, std::string::size_type num=std::string::npos) throw (StringException)
 Remove a string from the beginning and end of another string const version.
std::string & strip (std::string &s, const char *pString, std::string::size_type num=std::string::npos) throw (StringException)
 Remove a string from the beginning and end of another string.
std::string strip (const std::string &s, const char *pString, std::string::size_type num=std::string::npos) throw (StringException)
 Remove a string from the beginning and end of another string cosnt version.
std::string & strip (std::string &s, const char aCharacter, std::string::size_type num=std::string::npos) throw (StringException)
 Strip character(s) from the beginning and end of a string.
std::string strip (const std::string &s, const char aCharacter, std::string::size_type num=std::string::npos) throw (StringException)
 Strip character(s) from the beginning and end of a string const version.
std::string & strip (std::string &s, std::string::size_type num=std::string::npos) throw (StringException)
 Strip blanks from the beginning and end of a string.
std::string strip (const std::string &s, std::string::size_type num=std::string::npos) throw (StringException)
 Strip blanks from the beginning and end of a string const version.
std::string translate (const std::string &aString, const std::string &inputChars, const std::string &outputChars, const char pad= ' ')
 Converts all of the receiver's characters that are in the first specified string to the corresponding character in the second specified string.
std::string change (const std::string &aString, const std::string &inputString, const std::string &outputString, std::string::size_type startPos=0, unsigned numChanges=(std::numeric_limits< unsigned >::max)())
 Changes occurrences of a specified pattern to a specified replacement string.
std::string & change (std::string &aString, const std::string &inputString, const std::string &outputString, std::string::size_type startPos=0, unsigned numChanges=(std::numeric_limits< unsigned >::max)())
 Changes occurrences of a specified pattern to a specified replacement string.
std::string & rightJustify (std::string &s, const std::string::size_type length, const char pad= ' ') throw (StringException)
 Right-justifies the receiver in a string of the specified length.
std::string rightJustify (const std::string &s, const std::string::size_type length, const char pad= ' ') throw (StringException)
 Right-justifies the receiver in a string of the specified length (const version).
std::string & leftJustify (std::string &s, const std::string::size_type length, const char pad= ' ') throw (StringException)
 Left-justifies the receiver in a string of the specified length.
std::string leftJustify (const std::string &s, const std::string::size_type length, const char pad= ' ') throw (StringException)
 Left-justifies the receiver in a string of the specified length (const version).
std::string & center (std::string &s, const std::string::size_type length, const char pad= ' ') throw (StringException)
 Change the length of a string by adding to the beginning and end.
std::string center (const std::string &s, const std::string::size_type length, const char pad= ' ') throw (StringException)
 Change the length of a string by adding to the beginning and end (const version).
double asDouble (const std::string &s)
 Convert a string to a double precision floating point number.
long asInt (const std::string &s)
 Convert a string to an integer.
unsigned long asUnsigned (const std::string &s)
 Convert a string to an unsigned integer.
float asFloat (const std::string &s) throw (StringException)
 Convert a string to a single precision floating point number.
long double asLongDouble (const std::string &s) throw (StringException)
 Convert a string to a big precision floating point number.
template<class X>
asData (const std::string &s) throw (StringException)
 Convert a value in a string to a type specified by the template class.
std::string asString (const long double x, const std::string::size_type precision=21)
 Convert a long double to a string in fixed notation.
std::string asString (const double x, const std::string::size_type precision=17)
 Convert a double to a string in fixed notation.
template<class X>
std::string asString (const X x)
 Convert any old object to a string.
std::string & d2x (std::string &s) throw (StringException)
 Convert a decimal string to a hexadecimal string.
std::string d2x (const std::string &s) throw (StringException)
 Convert a decimal string to a hexadecimal string.
std::string & x2d (std::string &s) throw (StringException)
std::string x2d (const std::string &s) throw (StringException)
 Convert a hexadecimal string to a decimal string.
std::string & c2x (std::string &s) throw (StringException)
 Convert a character string to a hexadecimal string.
std::string c2x (const std::string &s) throw (StringException)
 Convert a character string to a hexadecimal string.
unsigned int x2int (const std::string &s) throw (StringException)
std::string int2x (const unsigned int &i) throw (StringException)
 Convert an int to a string.
std::string & replaceAll (std::string &s, const std::string &oldString, const std::string &newString) throw (StringException)
 Replace all instances of oldString with newString in s.
bool isDigitString (const std::string &s)
 isDigitString is exactly like the C function isDigit except it checks all the characters of string s to see if they are all digits.
bool isDecimalString (const std::string &s)
 isDecimalString is like isDigitString() except it allows a single period ('.') character in the string.
bool isScientificString (const std::string &s)
 isScientificString extends isDecimalString() to allow a single exponent (E,e,D,d) character between a decimal string and a (possibly empty) digit string.
bool isAlphaString (const std::string &s)
 isAlphaString is exactly like the C function isAlpha except it checks all the characters of string s to see if they are all alphabet characters.
std::string matches (const std::string &s, const std::string &aPattern, const char zeroOrMore= '*', const char oneOrMore= '+', const char anyChar= '.') throw (StringException)
 Perform pattern matching on strings.
bool isLike (const std::string &s, const std::string &aPattern, const char zeroOrMore= '*', const char oneOrMore= '+', const char anyChar= '.') throw (StringException)
 Perform pattern matching on strings.
bool isLike (const std::string &s, const char *pPattern, const char zeroOrMore= '*', const char oneOrMore= '+', const char anyChar= '.') throw (StringException)
 Perform pattern matching on strings.
template<class T>
std::string formattedPrint (const std::string &fmt, const std::string &pat, const std::string &rep, T to) throw (StringException)
 Work-horse method for printf.
std::string subString (const std::string &s, const std::string::size_type startPos=0, const std::string::size_type length=std::string::npos, const char pad= ' ') throw (StringException)
 Get a substring of a string.
std::string & lowerCase (std::string &s)
 Change all upper-case letters in a string to lower-case.
std::string lowerCase (const std::string &s)
 Change all upper-case letters in a string to lower-case.
std::string & upperCase (std::string &s)
 Change all lower-case letters in a string to upper-case.
std::string upperCase (const std::string &s)
 Change all lower-case letters in a string to upper-case.
std::string memToString (const void *p, const std::string::size_type size)
 Make a string from a void pointer.
std::string firstWord (const std::string &s, const char delimiter= ' ') throw (StringException)
 Returns the first word in string s without modifying the string.
int numWords (const std::string &s, const char delimiter= ' ') throw (StringException)
 Counts the number of words in s and returns it.
std::string words (const std::string &s, const std::string::size_type firstWord=0, const std::string::size_type numWords=std::string::npos, const char delimiter= ' ') throw (StringException)
 Returns numWords words starting with firstWord from s (if any).
std::string word (const std::string &s, const std::string::size_type wordNum=0, const char delimiter= ' ') throw (StringException)
 Returns word number wordNum from s (if any).
std::string stripFirstWord (std::string &s, const char delimiter= ' ') throw (StringException)
 Removes the first word off string s and returns it.
std::string & removeWords (std::string &s, const std::string::size_type first=0, const std::string::size_type wordsToReplace=std::string::npos, const char delimiter= ' ') throw (StringException)
 Removes indicated words from the string s.
std::string doub2sci (const double &d, const std::string::size_type length, const std::string::size_type expLen, const bool showSign=true, const bool checkSwitch=true)
 Convert a double to a scientific notation number.
std::string & sci2for (std::string &aStr, const std::string::size_type startPos=0, const std::string::size_type length=std::string::npos, const std::string::size_type expLen=3, const bool checkSwitch=true) throw (StringException)
 Convert scientific notation to FORTRAN notation.
std::string doub2for (const double &d, const std::string::size_type length, const std::string::size_type expLen, const bool checkSwitch=true) throw (StringException)
 Convert double precision floating point to a string containing the number in FORTRAN notation.
double for2doub (const std::string &aStr, const std::string::size_type startPos=0, const std::string::size_type length=std::string::npos)
 Convert FORTRAN representation of a double precision floating point in a string to a number.
std::string printable (const std::string &aStr) throw (StringException)
 Change a string into printable characters.
std::string & prettyPrint (std::string &aStr, const std::string &lineDelim="\n", const std::string &indent="", const std::string &firstIndent=" ", const std::string::size_type len=80, const char wordDelim= ' ') throw (StringException)
 Nicely expands the input string into several lines, non-const version.
std::string prettyPrint (const std::string &aStr, const std::string &lineDelim="\n", const std::string &indent="", const std::string &firstIndent=" ", const std::string::size_type len=80, const char wordDelim= ' ') throw (StringException)
 Const version of prettyPrint, which nicely expands the input string into several lines.
std::vector< std::string > split (const std::string &aStr, const std::string &theDelimiters=" ", bool trimWhitespace=false, bool ignoreEmpty=true)
 Split a string by some delimiters.


Generated on Wed Feb 8 03:31:20 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1