BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
facilities::Util Class Reference

#include <Util.h>

Static Public Member Functions

static int expandEnvVar (std::string *toExpand, const std::string &openDel=std::string("$("), const std::string &closeDel=std::string(")"))
static const char * itoa (int val, std::string &outStr)
static int atoi (const std::string &InStr)
 converts an std::string to an integer
static double stringToDouble (const std::string &InStr)
static int stringToInt (const std::string &InStr)
static void stringTokenize (std::string input, const std::string &delimiters, std::vector< std::string > &tokens, bool clear=true)
static void keyValueTokenize (std::string input, const std::string &delimiters, std::map< std::string, std::string > &tokenMap, const std::string &pairDelimiter=std::string("="), bool clear=true)
static std::string basename (const std::string &path)
static unsigned trimTrailing (std::string *toTrim)
static int expandEnvVar (std::string *toExpand, const std::string &openDel=std::string("$("), const std::string &closeDel=std::string(")"))
static int catchOptionVal (std::string *toCatch, const int ops=0, const std::string &openDel=std::string("#("), const std::string &closeDel=std::string(")"))
static const char * itoa (int val, std::string &outStr)
static int atoi (const std::string &InStr)
 converts an std::string to an integer
static double stringToDouble (const std::string &InStr)
static int stringToInt (const std::string &InStr)
static void stringTokenize (std::string input, const std::string &delimiters, std::vector< std::string > &tokens, bool clear=true)
static std::string basename (const std::string &path)
static int expandEnvVar (std::string *toExpand, const std::string &openDel=std::string("$("), const std::string &closeDel=std::string(")"))
static const char * itoa (int val, std::string &outStr)
static int atoi (const std::string &InStr)
 converts an std::string to an integer
static double stringToDouble (const std::string &InStr)
static int stringToInt (const std::string &InStr)
static void stringTokenize (std::string input, const std::string &delimiters, std::vector< std::string > &tokens, bool clear=true)
static void keyValueTokenize (std::string input, const std::string &delimiters, std::map< std::string, std::string > &tokenMap, const std::string &pairDelimiter=std::string("="), bool clear=true)
static std::string basename (const std::string &path)
static unsigned trimTrailing (std::string *toTrim)
static int expandEnvVar (std::string *toExpand, const std::string &openDel=std::string("$("), const std::string &closeDel=std::string(")"))
static int catchOptionVal (std::string *toCatch, const int ops=0, const std::string &openDel=std::string("#("), const std::string &closeDel=std::string(")"))
static const char * itoa (int val, std::string &outStr)
static int atoi (const std::string &InStr)
 converts an std::string to an integer
static double stringToDouble (const std::string &InStr)
static int stringToInt (const std::string &InStr)
static void stringTokenize (std::string input, const std::string &delimiters, std::vector< std::string > &tokens, bool clear=true)
static std::string basename (const std::string &path)
static int expandEnvVar (std::string *toExpand, const std::string &openDel=std::string("$("), const std::string &closeDel=std::string(")"))
static const char * itoa (int val, std::string &outStr)
static int atoi (const std::string &InStr)
 converts an std::string to an integer
static double stringToDouble (const std::string &InStr)
static int stringToInt (const std::string &InStr)
static void stringTokenize (std::string input, const std::string &delimiters, std::vector< std::string > &tokens, bool clear=true)
static void keyValueTokenize (std::string input, const std::string &delimiters, std::map< std::string, std::string > &tokenMap, const std::string &pairDelimiter=std::string("="), bool clear=true)
static std::string basename (const std::string &path)
static unsigned trimTrailing (std::string *toTrim)
static int expandEnvVar (std::string *toExpand, const std::string &openDel=std::string("$("), const std::string &closeDel=std::string(")"))
static int catchOptionVal (std::string *toCatch, const int ops=0, const std::string &openDel=std::string("#("), const std::string &closeDel=std::string(")"))
static const char * itoa (int val, std::string &outStr)
static int atoi (const std::string &InStr)
 converts an std::string to an integer
static double stringToDouble (const std::string &InStr)
static int stringToInt (const std::string &InStr)
static void stringTokenize (std::string input, const std::string &delimiters, std::vector< std::string > &tokens, bool clear=true)
static std::string basename (const std::string &path)

Detailed Description

Member Function Documentation

◆ atoi() [1/6]

int facilities::Util::atoi ( const std::string & InStr)
static

converts an std::string to an integer

Definition at line 83 of file Calibration/facilities/src/Util.cxx.

83 {
84 // Purpose and Method: Provide a standard routine to convert std::strings
85 // into integers. The method used depends upon the availability of
86 // the stringstream classes. The stringstream classes are the
87 // standard, but some compilers do yet support them.
88 // The method used is determined by the DEFECT_NO_STRINGSTREAM
89 // macro, defined in the facilities requirements file.
90 // Output: returns an integer
91 // if string cannot be converted to an integer, returns zero
92
93 int val;
94
95#ifdef DEFECT_NO_STRINGSTREAM
96 std::istrstream locStream( inStr.c_str() );
97#else
98 std::istringstream locStream( inStr );
99#endif
100 locStream >> val;
101 if ( !locStream ) { return 0; }
102 return val;
103 }

Referenced by calibUtil::Metadata::getReadInfo().

◆ atoi() [2/6]

int facilities::Util::atoi ( const std::string & InStr)
static

converts an std::string to an integer

◆ atoi() [3/6]

int facilities::Util::atoi ( const std::string & InStr)
static

converts an std::string to an integer

◆ atoi() [4/6]

int facilities::Util::atoi ( const std::string & InStr)
static

converts an std::string to an integer

◆ atoi() [5/6]

int facilities::Util::atoi ( const std::string & InStr)
static

converts an std::string to an integer

◆ atoi() [6/6]

int facilities::Util::atoi ( const std::string & InStr)
static

converts an std::string to an integer

◆ basename() [1/6]

std::string facilities::Util::basename ( const std::string & path)
static

return the "non-directory" part of a (supposed) file identifier, path. Environment variable translation should be done before calling basename.

See also
{ Util::expandEnvVar }
Parameters
pathstring assumed to be a file identifier.

Definition at line 155 of file Calibration/facilities/src/Util.cxx.

155 {
156 std::vector<std::string> names;
157 stringTokenize( path, "\\/", names );
158 return *( names.end() - 1 );
159 }
static void stringTokenize(std::string input, const std::string &delimiters, std::vector< std::string > &tokens, bool clear=true)

Referenced by main().

◆ basename() [2/6]

std::string facilities::Util::basename ( const std::string & path)
static

return the "non-directory" part of a (supposed) file identifier, path. Environment variable translation should be done before calling basename.

See also
{ Util::expandEnvVar }
Parameters
pathstring assumed to be a file identifier.

◆ basename() [3/6]

std::string facilities::Util::basename ( const std::string & path)
static

return the "non-directory" part of a (supposed) file identifier, path. Environment variable translation should be done before calling basename.

See also
{ Util::expandEnvVar }
Parameters
pathstring assumed to be a file identifier.

◆ basename() [4/6]

std::string facilities::Util::basename ( const std::string & path)
static

return the "non-directory" part of a (supposed) file identifier, path. Environment variable translation should be done before calling basename.

See also
{ Util::expandEnvVar }
Parameters
pathstring assumed to be a file identifier.

◆ basename() [5/6]

std::string facilities::Util::basename ( const std::string & path)
static

return the "non-directory" part of a (supposed) file identifier, path. Environment variable translation should be done before calling basename.

See also
{ Util::expandEnvVar }
Parameters
pathstring assumed to be a file identifier.

◆ basename() [6/6]

std::string facilities::Util::basename ( const std::string & path)
static

return the "non-directory" part of a (supposed) file identifier, path. Environment variable translation should be done before calling basename.

See also
{ Util::expandEnvVar }
Parameters
pathstring assumed to be a file identifier.

◆ catchOptionVal() [1/3]

int facilities::Util::catchOptionVal ( std::string * toCatch,
const int ops = 0,
const std::string & openDel = std::string("#("), const std::string &closeDel=std::string(")") )
static

Given input string toCatch catch val from string opt, by default of the form #(opt) and remove "#(opt)" from the original string.

Parameters
toCatchstring for which expansion is to be done
openDelopening delimiter (defaults to "#(")
closeDelclosing delimiter (defaults to ")")
Returns
-1 if attempt at expansion failed, else atoi(opt). TODO: Perhaps add optional arguments to specify alternate delimiters.

◆ catchOptionVal() [2/3]

int facilities::Util::catchOptionVal ( std::string * toCatch,
const int ops = 0,
const std::string & openDel = std::string("#("), const std::string &closeDel=std::string(")") )
static

Given input string toCatch catch val from string opt, by default of the form #(opt) and remove "#(opt)" from the original string.

Parameters
toCatchstring for which expansion is to be done
openDelopening delimiter (defaults to "#(")
closeDelclosing delimiter (defaults to ")")
Returns
-1 if attempt at expansion failed, else atoi(opt). TODO: Perhaps add optional arguments to specify alternate delimiters.

◆ catchOptionVal() [3/3]

int facilities::Util::catchOptionVal ( std::string * toCatch,
const int ops = 0,
const std::string & openDel = std::string("#("), const std::string &closeDel=std::string(")") )
static

Given input string toCatch catch val from string opt, by default of the form #(opt) and remove "#(opt)" from the original string.

Parameters
toCatchstring for which expansion is to be done
openDelopening delimiter (defaults to "#(")
closeDelclosing delimiter (defaults to ")")
Returns
-1 if attempt at expansion failed, else atoi(opt). TODO: Perhaps add optional arguments to specify alternate delimiters.

◆ expandEnvVar() [1/6]

int facilities::Util::expandEnvVar ( std::string * toExpand,
const std::string & openDel = std::string("$("), const std::string &closeDel=std::string(")") )
static

Given input string toExpand expand references to environment variables, by default of the form and put the expanded version back into the original string. Alternate delimiters for the varname may optionally be specified

Parameters
toExpandstring for which expansion is to be done
openDelopening delimiter (defaults to "$(")
closeDelclosing delimiter (defaults to ")")
Returns
-1 if attempt at expansion failed at least once, else number of successful expansions.

TODO: Perhaps add optional arguments to specify alternate delimiters.

Referenced by XmlBaseCnv::createObj(), digiRootReaderAlg::initialize(), digiRootWriterAlg::initialize(), main(), main(), calibUtil::Metadata::Metadata(), RootCalBaseCnv::openRead(), RootCalBaseCnv::openWrite(), and xmlBase::XmlParser::parse().

◆ expandEnvVar() [2/6]

int facilities::Util::expandEnvVar ( std::string * toExpand,
const std::string & openDel = std::string("$("), const std::string &closeDel=std::string(")") )
static

Given input string toExpand expand references to environment variables, by default of the form and put the expanded version back into the original string. Alternate delimiters for the varname may optionally be specified

Parameters
toExpandstring for which expansion is to be done
openDelopening delimiter (defaults to "$(")
closeDelclosing delimiter (defaults to ")")
Returns
-1 if attempt at expansion failed at least once, else number of successful expansions.

TODO: Perhaps add optional arguments to specify alternate delimiters.

◆ expandEnvVar() [3/6]

int facilities::Util::expandEnvVar ( std::string * toExpand,
const std::string & openDel = std::string("$("), const std::string &closeDel=std::string(")") )
static

Given input string toExpand expand references to environment variables, by default of the form and put the expanded version back into the original string. Alternate delimiters for the varname may optionally be specified

Parameters
toExpandstring for which expansion is to be done
openDelopening delimiter (defaults to "$(")
closeDelclosing delimiter (defaults to ")")
Returns
-1 if attempt at expansion failed at least once, else number of successful expansions.

TODO: Perhaps add optional arguments to specify alternate delimiters.

◆ expandEnvVar() [4/6]

int facilities::Util::expandEnvVar ( std::string * toExpand,
const std::string & openDel = std::string("$("), const std::string &closeDel=std::string(")") )
static

Given input string toExpand expand references to environment variables, by default of the form and put the expanded version back into the original string. Alternate delimiters for the varname may optionally be specified

Parameters
toExpandstring for which expansion is to be done
openDelopening delimiter (defaults to "$(")
closeDelclosing delimiter (defaults to ")")
Returns
-1 if attempt at expansion failed at least once, else number of successful expansions.

TODO: Perhaps add optional arguments to specify alternate delimiters.

◆ expandEnvVar() [5/6]

int facilities::Util::expandEnvVar ( std::string * toExpand,
const std::string & openDel = std::string("$("), const std::string &closeDel=std::string(")") )
static

Given input string toExpand expand references to environment variables, by default of the form and put the expanded version back into the original string. Alternate delimiters for the varname may optionally be specified

Parameters
toExpandstring for which expansion is to be done
openDelopening delimiter (defaults to "$(")
closeDelclosing delimiter (defaults to ")")
Returns
-1 if attempt at expansion failed at least once, else number of successful expansions.

TODO: Perhaps add optional arguments to specify alternate delimiters.

◆ expandEnvVar() [6/6]

int facilities::Util::expandEnvVar ( std::string * toExpand,
const std::string & openDel = std::string("$("), const std::string &closeDel=std::string(")") )
static

Given input string toExpand expand references to environment variables, by default of the form and put the expanded version back into the original string. Alternate delimiters for the varname may optionally be specified

Parameters
toExpandstring for which expansion is to be done
openDelopening delimiter (defaults to "$(")
closeDelclosing delimiter (defaults to ")")
Returns
-1 if attempt at expansion failed at least once, else number of successful expansions.

TODO: Perhaps add optional arguments to specify alternate delimiters.

◆ itoa() [1/6]

const char * facilities::Util::itoa ( int val,
std::string & outStr )
static

Given an input integer val to convert and an output string outStr converts val into a std::string. This method duplicates the stdlib.h method itoa, except that it returns std::string rather than char*.

Parameters
val
outStrwill be modified by this method
Returns
const char* based on the contents of outStr.c_str()

Definition at line 56 of file Calibration/facilities/src/Util.cxx.

56 {
57 // Purpose and Method: Provide a standard routine to convert integers
58 // into std::string. The method used depends upon the availability of
59 // the stringstream classes. The stringstream classes are the
60 // standard, but some compilers do yet support them.
61 // The method used is determined by the DEFECT_NO_STRINGSTREAM
62 // macro, defined in the facilities requirements file.
63
64 static char outCharPtr[20];
65
66#ifdef DEFECT_NO_STRINGSTREAM
67 // Using static buffer to avoid problems with memory allocation
68 char a[100] = "";
69 std::ostrstream locStream( a, 100 );
70#else
71 std::ostringstream locStream;
72 locStream.str( "" );
73#endif
74 locStream << val;
75#ifdef DEFECT_NO_STRINGSTREAM
76 locStream << std::ends;
77#endif
78 outStr = locStream.str();
79 strcpy( outCharPtr, outStr.c_str() );
80 return outCharPtr;
81 }

Referenced by rdbModel::MysqlConnection::dbRequest(), xmlBase::XmlErrorHandler::error(), xmlBase::XmlErrorHandler::fatalError(), calibUtil::Metadata::findBest(), calibUtil::Metadata::findSoonAfter(), calibUtil::Metadata::getReadInfo(), main(), calibUtil::Metadata::registerCalib(), rdbModel::MysqlConnection::select(), and rdbModel::Table::supersedeRow().

◆ itoa() [2/6]

const char * facilities::Util::itoa ( int val,
std::string & outStr )
static

Given an input integer val to convert and an output string outStr converts val into a std::string. This method duplicates the stdlib.h method itoa, except that it returns std::string rather than char*.

Parameters
val
outStrwill be modified by this method
Returns
const char* based on the contents of outStr.c_str()

◆ itoa() [3/6]

const char * facilities::Util::itoa ( int val,
std::string & outStr )
static

Given an input integer val to convert and an output string outStr converts val into a std::string. This method duplicates the stdlib.h method itoa, except that it returns std::string rather than char*.

Parameters
val
outStrwill be modified by this method
Returns
const char* based on the contents of outStr.c_str()

◆ itoa() [4/6]

const char * facilities::Util::itoa ( int val,
std::string & outStr )
static

Given an input integer val to convert and an output string outStr converts val into a std::string. This method duplicates the stdlib.h method itoa, except that it returns std::string rather than char*.

Parameters
val
outStrwill be modified by this method
Returns
const char* based on the contents of outStr.c_str()

◆ itoa() [5/6]

const char * facilities::Util::itoa ( int val,
std::string & outStr )
static

Given an input integer val to convert and an output string outStr converts val into a std::string. This method duplicates the stdlib.h method itoa, except that it returns std::string rather than char*.

Parameters
val
outStrwill be modified by this method
Returns
const char* based on the contents of outStr.c_str()

◆ itoa() [6/6]

const char * facilities::Util::itoa ( int val,
std::string & outStr )
static

Given an input integer val to convert and an output string outStr converts val into a std::string. This method duplicates the stdlib.h method itoa, except that it returns std::string rather than char*.

Parameters
val
outStrwill be modified by this method
Returns
const char* based on the contents of outStr.c_str()

◆ keyValueTokenize() [1/3]

void facilities::Util::keyValueTokenize ( std::string input,
const std::string & delimiters,
std::map< std::string, std::string > & tokenMap,
const std::string & pairDelimiter = std::string( "=" ),
bool clear = true )
static

This routine breaks down a string into key/value token pairs and stores them in the user-supplied map. , based on the characters appearing in the string delimiters and the value of pairDelimiter. In a typical example, input could be "key1=val1,key2=val2,key3=val3". In this case invoke with delimiters=std::string(",") and pairDelimiter=std::string("=") (or omit pairDelimiter since it has the default value)

Parameters
inputstring to be tokenized
delimitersstring containing one or more delimiter characters
tokenMapmap of strings to hold resulting tokens
pairDelimiterstring separating key and value; defaults to "="
clearif true (default) tokens will be cleared at the start of processing

Definition at line 135 of file Calibration/facilities/src/Util.cxx.

137 {
138 if ( clear ) tokens.clear();
139
140 std::vector<std::string> strvec;
141 stringTokenize( input, delimiters, strvec, true );
142 unsigned advance = pairDelimiter.size();
143
144 std::vector<std::string>::const_iterator input_itr = strvec.begin();
145 while ( input_itr != strvec.end() )
146 {
147 std::string current = *input_itr++;
148 std::string::size_type j = current.find( pairDelimiter );
149 std::string key = current.substr( 0, j );
150 std::string value = current.substr( j + advance );
151 tokens[key] = value;
152 }
153 }
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
Definition Taupair.h:42

Referenced by main().

◆ keyValueTokenize() [2/3]

void facilities::Util::keyValueTokenize ( std::string input,
const std::string & delimiters,
std::map< std::string, std::string > & tokenMap,
const std::string & pairDelimiter = std::string("="),
bool clear = true )
static

This routine breaks down a string into key/value token pairs and stores them in the user-supplied map. , based on the characters appearing in the string delimiters and the value of pairDelimiter. In a typical example, input could be "key1=val1,key2=val2,key3=val3". In this case invoke with delimiters=std::string(",") and pairDelimiter=std::string("=") (or omit pairDelimiter since it has the default value)

Parameters
inputstring to be tokenized
delimitersstring containing one or more delimiter characters
tokenMapmap of strings to hold resulting tokens
pairDelimiterstring separating key and value; defaults to "="
clearif true (default) tokens will be cleared at the start of processing

◆ keyValueTokenize() [3/3]

void facilities::Util::keyValueTokenize ( std::string input,
const std::string & delimiters,
std::map< std::string, std::string > & tokenMap,
const std::string & pairDelimiter = std::string("="),
bool clear = true )
static

This routine breaks down a string into key/value token pairs and stores them in the user-supplied map. , based on the characters appearing in the string delimiters and the value of pairDelimiter. In a typical example, input could be "key1=val1,key2=val2,key3=val3". In this case invoke with delimiters=std::string(",") and pairDelimiter=std::string("=") (or omit pairDelimiter since it has the default value)

Parameters
inputstring to be tokenized
delimitersstring containing one or more delimiter characters
tokenMapmap of strings to hold resulting tokens
pairDelimiterstring separating key and value; defaults to "="
clearif true (default) tokens will be cleared at the start of processing

◆ stringToDouble() [1/6]

double facilities::Util::stringToDouble ( const std::string & InStr)
static

converts a std::string to a double. If string contents are not of proper form, throws facilities::WrongType

Definition at line 105 of file Calibration/facilities/src/Util.cxx.

105 {
106 double val;
107 char junk[3];
108 int nItem = sscanf( inStr.c_str(), "%lg %1s", &val, junk );
109 if ( nItem != 1 ) { throw WrongType( inStr, "double" ); }
110 return val;
111 }

Referenced by xmlBase::IFile::getDouble(), xmlBase::Dom::getDoubleAttribute(), xmlBase::Dom::getDoublesAttribute(), xmlBase::Dom::getFloatsAttribute(), and main().

◆ stringToDouble() [2/6]

double facilities::Util::stringToDouble ( const std::string & InStr)
static

converts a std::string to a double. If string contents are not of proper form, throws facilities::WrongType

◆ stringToDouble() [3/6]

double facilities::Util::stringToDouble ( const std::string & InStr)
static

converts a std::string to a double. If string contents are not of proper form, throws facilities::WrongType

◆ stringToDouble() [4/6]

double facilities::Util::stringToDouble ( const std::string & InStr)
static

converts a std::string to a double. If string contents are not of proper form, throws facilities::WrongType

◆ stringToDouble() [5/6]

double facilities::Util::stringToDouble ( const std::string & InStr)
static

converts a std::string to a double. If string contents are not of proper form, throws facilities::WrongType

◆ stringToDouble() [6/6]

double facilities::Util::stringToDouble ( const std::string & InStr)
static

converts a std::string to a double. If string contents are not of proper form, throws facilities::WrongType

◆ stringToInt() [1/6]

int facilities::Util::stringToInt ( const std::string & InStr)
static

converts a std::string to an int. If string contents are not of proper form, throws facilities::WrongType

Definition at line 113 of file Calibration/facilities/src/Util.cxx.

113 {
114 int val;
115 char junk[3];
116 int nItem = sscanf( inStr.c_str(), "%d %1s", &val, junk );
117 if ( nItem != 1 ) { throw WrongType( inStr, "int" ); }
118 return val;
119 }

Referenced by rdbModel::XercesBuilder::buildRdb(), Coverage::checkType(), xmlBase::IFile::getInt(), xmlBase::Dom::getIntAttribute(), xmlBase::Dom::getIntsAttribute(), rdbModel::MysqlResults::getRowCon(), main(), and rdbModel::MysqlConnection::open().

◆ stringToInt() [2/6]

int facilities::Util::stringToInt ( const std::string & InStr)
static

converts a std::string to an int. If string contents are not of proper form, throws facilities::WrongType

◆ stringToInt() [3/6]

int facilities::Util::stringToInt ( const std::string & InStr)
static

converts a std::string to an int. If string contents are not of proper form, throws facilities::WrongType

◆ stringToInt() [4/6]

int facilities::Util::stringToInt ( const std::string & InStr)
static

converts a std::string to an int. If string contents are not of proper form, throws facilities::WrongType

◆ stringToInt() [5/6]

int facilities::Util::stringToInt ( const std::string & InStr)
static

converts a std::string to an int. If string contents are not of proper form, throws facilities::WrongType

◆ stringToInt() [6/6]

int facilities::Util::stringToInt ( const std::string & InStr)
static

converts a std::string to an int. If string contents are not of proper form, throws facilities::WrongType

◆ stringTokenize() [1/6]

void facilities::Util::stringTokenize ( std::string input,
const std::string & delimiters,
std::vector< std::string > & tokens,
bool clear = true )
static

This routine breaks down a string into tokens, based on the characters appearing in the string delimiters.

Parameters
inputstring to be tokenized
delimitersstring containing one or more delimiter characters
tokensvector of strings to hold resulting tokens
clearif true (default) tokens will be cleared at the start of processing

Definition at line 121 of file Calibration/facilities/src/Util.cxx.

122 {
123 if ( clear ) tokens.clear();
124
125 std::string::size_type j;
126 while ( ( j = input.find_first_of( delimiters ) ) != std::string::npos )
127 {
128 if ( j != 0 ) tokens.push_back( input.substr( 0, j ) );
129 input = input.substr( j + 1 );
130 }
131 tokens.push_back( input );
132 if ( tokens.back() == "" ) tokens.pop_back();
133 }

Referenced by basename(), xmlBase::Dom::getDoublesAttribute(), xmlBase::Dom::getFloatsAttribute(), xmlBase::Dom::getIntsAttribute(), keyValueTokenize(), and main().

◆ stringTokenize() [2/6]

void facilities::Util::stringTokenize ( std::string input,
const std::string & delimiters,
std::vector< std::string > & tokens,
bool clear = true )
static

This routine breaksdown a string into tokens, based on the characters appearing in the string delimiters.

Parameters
inputstring to be tokenized
delimitersstring containing one or more delimiter characters
tokensvector of strings to hold resulting tokens
clearif true (default) tokens will be cleared at the start of processing

◆ stringTokenize() [3/6]

void facilities::Util::stringTokenize ( std::string input,
const std::string & delimiters,
std::vector< std::string > & tokens,
bool clear = true )
static

This routine breaks down a string into tokens, based on the characters appearing in the string delimiters.

Parameters
inputstring to be tokenized
delimitersstring containing one or more delimiter characters
tokensvector of strings to hold resulting tokens
clearif true (default) tokens will be cleared at the start of processing

◆ stringTokenize() [4/6]

void facilities::Util::stringTokenize ( std::string input,
const std::string & delimiters,
std::vector< std::string > & tokens,
bool clear = true )
static

This routine breaksdown a string into tokens, based on the characters appearing in the string delimiters.

Parameters
inputstring to be tokenized
delimitersstring containing one or more delimiter characters
tokensvector of strings to hold resulting tokens
clearif true (default) tokens will be cleared at the start of processing

◆ stringTokenize() [5/6]

void facilities::Util::stringTokenize ( std::string input,
const std::string & delimiters,
std::vector< std::string > & tokens,
bool clear = true )
static

This routine breaks down a string into tokens, based on the characters appearing in the string delimiters.

Parameters
inputstring to be tokenized
delimitersstring containing one or more delimiter characters
tokensvector of strings to hold resulting tokens
clearif true (default) tokens will be cleared at the start of processing

◆ stringTokenize() [6/6]

void facilities::Util::stringTokenize ( std::string input,
const std::string & delimiters,
std::vector< std::string > & tokens,
bool clear = true )
static

This routine breaksdown a string into tokens, based on the characters appearing in the string delimiters.

Parameters
inputstring to be tokenized
delimitersstring containing one or more delimiter characters
tokensvector of strings to hold resulting tokens
clearif true (default) tokens will be cleared at the start of processing

◆ trimTrailing() [1/3]

unsigned facilities::Util::trimTrailing ( std::string * toTrim)
static

Trim trailing white space characters from the supplied string. White space characters for this purpose are blank, carriage return, line feed and form feed. Return # of characters trimmed.

Definition at line 161 of file Calibration/facilities/src/Util.cxx.

161 {
162 static const char blank = ' ';
163 static const char LF = 0xA; // new line
164 static const char FF = 0xC; // form feed
165 static const char CR = 0xD; // carriage return
166
167 unsigned orig = toTrim->size();
168 unsigned last = orig - 1;
169 bool notDone = true;
170 unsigned nTrimmed = 0;
171
172 while ( notDone )
173 {
174 char lastChar = ( *toTrim )[last];
175 switch ( lastChar )
176 {
177 case blank:
178 case LF:
179 case FF:
180 case CR:
181 last--;
182 nTrimmed++;
183 break;
184 default: notDone = false; break;
185 }
186 }
187 if ( nTrimmed ) toTrim->resize( orig - nTrimmed );
188
189 return nTrimmed;
190 }

Referenced by XmlBaseCnv::createObj(), and main().

◆ trimTrailing() [2/3]

unsigned facilities::Util::trimTrailing ( std::string * toTrim)
static

Trim trailing white space characters from the supplied string. White space characters for this purpose are blank, carriage return, line feed and form feed. Return # of characters trimmed.

◆ trimTrailing() [3/3]

unsigned facilities::Util::trimTrailing ( std::string * toTrim)
static

Trim trailing white space characters from the supplied string. White space characters for this purpose are blank, carriage return, line feed and form feed. Return # of characters trimmed.


The documentation for this class was generated from the following files: