3#include "facilities/Util.h"
5#ifdef DEFECT_NO_STRINGSTREAM
22 const std::string& openDel,
23 const std::string& closeDel) {
24 unsigned opLen = openDel.size();
25 unsigned clLen = closeDel.size();
28 int envStart = toExpand->find(openDel.c_str());
29 while (envStart != -1) {
30 int envEnd = toExpand->find(closeDel.c_str());
33 int afterBracket = envStart + opLen;
35 if (!( (envStart==-1) || (envEnd==-1) ))
37 std::string envVariable =
38 toExpand->substr(afterBracket,(envEnd-afterBracket));
39 const char * path = getenv(envVariable.c_str());
41 toExpand->replace(envStart,(envEnd+clLen), path);
42 if (nSuccess > -1) nSuccess++;
45 std::cerr <<
"Util::expandEnvVar unable to translate "
46 << envVariable << std::endl;
47 throw Untranslatable(envVariable);
50 envStart = toExpand->find(openDel.c_str());
63 static char outCharPtr[20];
65#ifdef DEFECT_NO_STRINGSTREAM
68 std::ostrstream locStream(a,100);
70 std::ostringstream locStream;
74#ifdef DEFECT_NO_STRINGSTREAM
75 locStream << std::ends;
77 outStr = locStream.str();
78 strcpy(outCharPtr, outStr.c_str());
94#ifdef DEFECT_NO_STRINGSTREAM
95 std::istrstream locStream(inStr.c_str());
97 std::istringstream locStream(inStr);
100 if (!locStream) {
return 0;}
107 int nItem = sscanf(inStr.c_str(),
"%lg %1s", &val, junk);
118 int nItem = sscanf(inStr.c_str(),
"%d %1s", &val, junk);
126 std::vector<std::string>& tokens,
bool clear) {
127 if (clear) tokens.clear();
129 std::string::size_type j;
130 while ( (j = input.find_first_of(delimiters)) != std::string::npos ) {
131 if (j != 0) tokens.push_back(input.substr(0, j));
132 input = input.substr(j+1);
134 tokens.push_back(input);
135 if (tokens.back() ==
"") tokens.pop_back();
140 const std::string& delimiters,
141 std::map<std::string,std::string>& tokens,
142 const std::string& pairDelimiter,
144 if (clear) tokens.clear();
146 std::vector<std::string> strvec;
148 unsigned advance = pairDelimiter.size();
150 std::vector<std::string>::const_iterator input_itr = strvec.begin();
151 while(input_itr!=strvec.end())
153 std::string current = *input_itr++;
154 std::string::size_type j = current.find(pairDelimiter);
155 std::string
key = current.substr(0, j);
156 std::string value = current.substr(j+advance);
162 std::vector<std::string> names;
164 return *(names.end() - 1);
168 static const char blank=
' ';
169 static const char LF=0xA;
170 static const char FF=0xC;
171 static const char CR=0xD;
173 unsigned orig = toTrim->size();
174 unsigned last = orig - 1;
176 unsigned nTrimmed = 0;
180 char lastChar = (*toTrim)[last];
194 if (nTrimmed) toTrim->resize(orig - nTrimmed);
*************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
static double stringToDouble(const std::string &InStr)
static int expandEnvVar(std::string *toExpand, const std::string &openDel=std::string("$("), const std::string &closeDel=std::string(")"))
static void stringTokenize(std::string input, const std::string &delimiters, std::vector< std::string > &tokens, bool clear=true)
static int atoi(const std::string &InStr)
converts an std::string to an integer
static std::string basename(const std::string &path)
static int stringToInt(const std::string &InStr)
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 const char * itoa(int val, std::string &outStr)
static unsigned trimTrailing(std::string *toTrim)
Exception class used when converting from string to numeric type.