|
ATLAS Offline Software
|
Go to the documentation of this file.
24 #include <sys/types.h>
38 #define SREPLACE(s) REPLACE(s)
40 #define RESPLOTDIR SREPLACE(RESPLOTDIR_TMP)
46 if (
getenv(
"CONFIG_PATH") ) {
47 std::string config_path =
getenv(
"CONFIG_PATH");
48 std::cout <<
"ReadCards::CONFIG_PATH " << config_path << std::endl;
49 while ( config_path.size() ) {
65 for (
unsigned i=0 ;
i<
m_Path.size() ;
i++ ) {
74 cerr <<
"ReadCards::Construct() cannot open file " <<
filename << endl;
84 else std::sprintf(
tfile,
".readcards-%d",
pid );
91 std::cout <<
"pid: " <<
pid <<
" " <<
tfile << std::endl;
96 cout <<
"ReadCards::Construct() opening " <<
m_FileName << endl;
102 std::sprintf(
cmd,
"rm %s",
tfile );
109 int count(
const std::string&
s,
const std::string&
p ) {
110 if (
s.find(
p)==std::string::npos )
return 0;
112 for (
size_t i=0 ;
i<
s.size() ;
i++ ) {
139 if ( (
pos=
line.find(
"//")) != std::string::npos ) {
143 for (
unsigned iq=0 ; iq<
pos ; iq++ ) {
144 if (
line[iq]==
'\"' ) quotecount++;
145 else if (
line[iq]==
'"' ) quotecount++;
150 if ( quotecount%2==0 ) {
151 std::string tmpline =
chop(
line,
"//");
155 line = std::move(tmpline);
160 if ( (
pos=
line.find(
'#')) != std::string::npos ) {
165 for (
unsigned iq=0 ; iq<
pos ; iq++ ) {
166 if (
line[iq]==
'\"' ) quotecount++;
167 else if (
line[iq]==
'"' ) quotecount++;
172 if ( quotecount%2==0 ) {
173 std::string tmpline =
chop(
line,
"#");
215 while (
pos != std::string::npos ) {
220 size_t n =
count( duff,
"\"" );
237 if (
m_String.find(
'|')==std::string::npos ) {
238 error(
"syntax error, missing semicolon at end of input " +
m_String );
252 for (
size_t iq=0 ; iq<
line.size() ; iq++ ) {
254 if (
line[iq]==
'\"' ) quotecount++;
255 else if (
line[iq]==
'"' ) quotecount++;
256 if (
line[iq]==
'=' )
break;
260 if (
found && quotecount>0 )
error(
"syntax error in tag name : " +
input +
" quotes" );
282 if ( sline.size() )
error(
"syntax error in tag name : " +
input );
295 vector<std::string>
values;
302 for (
size_t iq=0 ; iq<
line.size() ; iq++ ) {
304 if (
line[iq]==
'\"' ) quotecount++;
305 else if (
line[iq]==
'"' ) quotecount++;
306 if (
line[iq]==
'{' && ( quotecount==0 || quotecount%2==0 ) )
break;
309 if (
found && quotecount>0 )
error(
"syntax error in tag name : " +
input +
" quotes" );
319 if ( bra.size()>1 )
error(
"syntax error before brace : " +
input);
320 if ( ket.size()>1 )
error(
"syntax error after brace : " +
input);
321 if ( bra.size()!=ket.size() )
error(
"mismatched braces :" +
input);
329 while (
line.size() ) {
344 if ( qo.size()>1 )
error(
"syntax error before quote : " +
input);
349 if ( qo.size()==1 ) {
354 if ( token.size()== 0 )
error(
"sytax error, missing quote : " +
input);
376 if ( token.find(
' ')!=string::npos )
error(
"space not within quotes : " +
input);
380 if ( qo.empty() && token.empty() )
error(
"missing token : " +
input);
383 size_t pos = token.find(
"####");
384 while (
pos !=std::string::npos ) {
385 token.replace(
pos, 4,
";" );
386 pos = token.find(
"####");
421 if (
s.size() )
error(
"syntax error in tag name : " +
input );
431 vector<std::string>
sv;
438 if ( bra.size()>1 )
error(
"syntax error before { : "+
input);
439 if ( ket.size()>1 )
error(
"syntax error after } : "+
input);
440 if ( bra.size()!=ket.size() )
error(
"mismatched braces :" +
input);
444 string token =
chop(
s,
",");
452 if ( qo.size()>1 || qc.size()>1 )
error(
"syntax error before \" : " +
input);
455 if ( qc.size()!=qo.size() )
error(
"mismatched \" : " +
input);
459 if ( token.find(
' ')!=string::npos )
error(
"space not wintin \"\" : " +
input);
462 if ( token.empty() )
error(
"missing token : " +
input);
498 if (
vals[j].
size()>10 || (
vals.size()>5 && !(j%5) ) ) printf(
"\n\t\t\t");
499 printf(
"%s ",
vals[j].c_str() );
string parseleft(string &s)
bool canopen(const std::string &s)
std::string chomp(std::string &s1, const std::string &s2)
#define RESPLOTDIR
set up the search path for the config files
std::string chopends(std::string &s1, const std::string &s2)
std::string chop(std::string &s1, const std::string &s2)
bool AddTag(const string &tag, const vector< string > &values)
void parse()
parse the remaining cleaned input string
vector< string > parseright(string &s)
int count(const std::string &s, const std::string &p)
static std::vector< std::string > m_Path
std::string chopfirst(std::string &s1, const std::string &s2)
void clean()
remove comments and whitespace
void error(const std::string &s)
std::string chomptoken(std::string &s1, const std::string &s2)
std::vector< Value > m_Values
std::string choplast(std::string &s1, const std::string &s2)
std::string getenv(const std::string &variableName)
get an environment variable
std::string choptoken(std::string &s1, const std::string &s2)
void Construct(const std::string &filename)
check for file in cwd or if not, check in the RESPLOTDIR, then read the file