gpstk::StringUtils Namespace Reference
[GPSTk data structuresGPSTk data structures]


Detailed Description

Stuff to make the C++ string class a little easier to use.

All the functionality here is inlined since they are farily small functions.

All functions here will throw gpstk::StringUtils::StringException on an error. Any std::exception is converted to a gpstk::StringUtils::StringException so that's the only exception a user of this class needs to catch.

For any function that modifies a string, make sure there is a non-const (std::string&) version and a const (const std::string&) version. The convention for writing the functions is the non-const version fully implements the function and the const version calls the non-const version.

See also:
stringutiltest.cpp for some examples.


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

std::string asString (const VariableSet &vset)
std::string asString (const Variable &v)
std::string asString (const CarrierCode &cc) throw ()
 Decode Carrier Code to a string.
std::string asString (const RangeCode &rc) throw ()
 Decode Range Code to a string.
std::string asString (const NavCode &nc) throw ()
 Decode Navigation Message Code to a string.
std::string asString (const ExternalFrequencyStatus &e) throw ()
 Decode external frequency status to a string.
std::string asString (const ObsID &p)
 convert this object to a string representation
std::string asString (const RinexObsID &p)
 convert this object to a string representation
std::string asString (const SatID &p)
std::string asString (const SourceID &p)
 Convert this object to a string representation.
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 x2uint (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::vector< std::string > split (const std::string &str, const char delimiter= ' ') throw (StringException)
 Split a string str into words as defined by delimiter.
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 doubleToScientific (const double &d, const std::string::size_type length, const std::string::size_type precision, const std::string::size_type explen, bool showPlus=false)
 Convert a double to scientific notation; this routine works better, on Windows particularly, than doub2sci.
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.
std::string asString (const TypeID &p)
 convert this object to a string representation


Function Documentation

std::string asString const TypeID &  p  ) 
 

convert this object to a string representation

Definition at line 395 of file TypeID.cpp.

References TypeID::dump().

Referenced by SatPass::addData(), GPSZcount::addWeeks(), GPSZcount::addZcounts(), SVExclusionList::buildFailString(), HarrisPriesterDrag::computeDensity(), CiraExponentialDrag::computeDensity(), FileSpec::convertFileSpecType(), RinexMetHeader::convertObsType(), FileSpec::createSearchString(), SatPass::data(), SRIleastSquares::dataUpdate(), Rinex3ObsHeader::dump(), Rinex3ObsData::dump(), MDPPVTSolution::dump(), MDPObsEpoch::Observation::dump(), AshtechPBEN::dump(), AshtechMBEN::code_block::dump(), AntexData::dump(), GeneralEquations::dumpSourceSatData(), IonexStore::findDCB(), MSCStore::findMSC(), GPSEphemerisStore::findNearEphemeris(), GalEphemerisStore::findNearEphemeris(), GPSOrbElemStore::findNearOrbElem(), GPSOrbElemStore::findOrbElem(), GPSEphemerisStore::findUserEphemeris(), GalEphemerisStore::findUserEphemeris(), GDCPass::finish(), ConfDataItem::format(), FICData::generateUniqueKey(), SatPass::getCount(), SatPass::getData(), FICData::getElementLabel(), EOPStore::getEOP(), GPSEphemerisStore::getEphMap(), GalEphemerisStore::getEphMap(), SatPass::getFlag(), IonexData::getIndex(), GPSOrbElemStore::getOrbElemMap(), FileSpec::init(), SatPass::LLI(), main(), gpstk::NutationDEps(), gpstk::NutationDPsi(), FICData::operator AlmOrbit(), FICData::operator EngEphemeris(), Rinex3ClockHeader::ParseHeaderRecord(), gpstk::PolarMotionX(), gpstk::PolarMotionY(), Rinex3ObsHeader::PrepareVer2Write(), SolarSystem::readASCIIdata(), PlanetEphemeris::readASCIIdata(), SolarSystem::readASCIIheader(), PlanetEphemeris::readASCIIheader(), SP3Header::reallyGetRecord(), SP3Data::reallyGetRecord(), SMODFData::reallyGetRecord(), RinexObsHeader::reallyGetRecord(), RinexObsData::reallyGetRecord(), RinexNavHeader::reallyGetRecord(), RinexMetHeader::reallyGetRecord(), Rinex3ObsHeader::reallyGetRecord(), Rinex3ObsData::reallyGetRecord(), Rinex3NavHeader::reallyGetRecord(), IonexHeader::reallyGetRecord(), FICData::reallyGetRecord(), AntexHeader::reallyGetRecord(), gpstk::reallyGetRecordVer2(), SP3Header::reallyPutRecord(), SP3Data::reallyPutRecord(), SMODFData::reallyPutRecord(), SEMData::reallyPutRecord(), RinexObsHeader::reallyPutRecord(), RinexObsData::reallyPutRecord(), RinexNavHeader::reallyPutRecord(), RinexMetHeader::reallyPutRecord(), RinexMetData::reallyPutRecord(), RinexClockHeader::reallyPutRecord(), RinexClockData::reallyPutRecord(), Rinex3ObsHeader::reallyPutRecord(), Rinex3ObsData::reallyPutRecord(), Rinex3NavHeader::reallyPutRecord(), MSCData::reallyPutRecord(), IonexHeader::reallyPutRecord(), IonexData::reallyPutRecord(), AntexHeader::reallyPutRecord(), AntexData::reallyPutRecord(), gpstk::reallyPutRecordVer2(), SatPassIterator::SatPassIterator(), MDPHeader::setCRC(), Rinex3NavHeader::setFileSystem(), SatPass::setFlag(), SatPass::SSI(), SatPass::time(), SatPass::timeoffset(), IonexHeader::DCB::toString(), gpstk::UT1mUTC(), SolarSystem::writeASCIIheader(), PlanetEphemeris::writeASCIIheader(), RinexObsHeader::WriteHeaderRecords(), Rinex3ObsHeader::WriteHeaderRecords(), IonexHeader::WriteHeaderRecords(), and AntexHeader::WriteHeaderRecords().

std::string asString const SourceID &  p  ) 
 

Convert this object to a string representation.

Definition at line 153 of file SourceID.cpp.

References SourceID::dump().

std::string asString const SatID &  p  )  [inline]
 

Definition at line 166 of file SatID.hpp.

References SatID::dump().

std::string asString const RinexObsID &  id  ) 
 

convert this object to a string representation

Definition at line 95 of file RinexObsID.cpp.

References RinexObsID::asString().

std::string asString const ObsID &  id  ) 
 

convert this object to a string representation

Definition at line 465 of file ObsID.cpp.

References ObsID::dump().

std::string asString const ExternalFrequencyStatus e  )  throw () [inline]
 

Decode external frequency status to a string.

Parameters:
e the external frequency status to convert.
Returns:
the Carrier Code as a string.

Definition at line 142 of file miscenum.hpp.

References gpstk::efsLocked, and gpstk::efsNotLocked.

std::string asString const NavCode nc  )  throw () [inline]
 

Decode Navigation Message Code to a string.

Parameters:
nc the Navigation Code to convert.
Returns:
the Navigation Code as a string.

Definition at line 126 of file miscenum.hpp.

References gpstk::ncICD_200_2, gpstk::ncICD_200_4, gpstk::ncICD_700_M, and gpstk::ncICD_705_L5.

std::string asString const RangeCode rc  )  throw () [inline]
 

Decode Range Code to a string.

Parameters:
rc the Range Code to convert.
Returns:
the Range Code as a string.

Definition at line 105 of file miscenum.hpp.

References gpstk::rcCA, gpstk::rcCL, gpstk::rcCM, gpstk::rcCMCL, gpstk::rcCodeless, gpstk::rcI5, gpstk::rcPcode, gpstk::rcQ5, and gpstk::rcYcode.

std::string asString const CarrierCode cc  )  throw () [inline]
 

Decode Carrier Code to a string.

Parameters:
cc the Carrier Code to convert.
Returns:
the Carrier Code as a string.

Definition at line 90 of file miscenum.hpp.

References gpstk::ccL1, gpstk::ccL2, and gpstk::ccL5.

std::string asString const Variable &  v  )  [inline]
 

Definition at line 374 of file Variable.hpp.

References Variable::getSatellite(), Variable::getSatIndexed(), Variable::getSource(), Variable::getSourceIndexed(), Variable::getType(), and Variable::getTypeIndexed().

std::string asString const VariableSet vset  )  [inline]
 

Examples:
example12.cpp.

Definition at line 330 of file Equation.hpp.

References Variable::getType().

Referenced by FICData::reallyGetRecord().


Generated on Fri Dec 6 03:31:23 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1