9 _current(0) , _fileName( fileName ) {
45 if( tokens.
size() < 1 )
continue ;
48 if( tokens[0] ==
".begin" ) {
50 if( tokens.
size() < 2 ) {
51 std::cerr <<
" Parser::parse : section has to have a name: .begin sectionName " <<
std::endl ;
54 _map[ tokens[1] ] = std::make_shared<StringParameters>();
58 }
else if ( tokens[0] ==
".end" ) {
82 availableProcs.
push_back(
"AvailableProcessors") ;
86 for( StringParametersMap::const_iterator iter =
_map.
begin() ; iter !=
_map.
end() ; iter++){
94 if( type.
size() > 0 ) {
99 if( name ==
"Global" )
109 global->
add( availableProcs ) ;
115 for( StringParametersMap::const_iterator iter =
_map.
begin() ; iter !=
_map.
end() ; iter++){
122 return _map[ sectionName ] ;
134 while( ! stream.
eof() ) {
136 getline( stream , str ) ;
139 char firstChar =
' ' ;
140 bool haveFirst = false ;
142 for(
unsigned int i=0; i < str.
length() ; i ++){
145 if( (str[i] ==
'\t') || (str[i] ==
'\r') ) str[i] =
' ' ;
148 if( ! haveFirst && str[i] !=
' ' ){
154 if( str.
length() != 0 && firstChar !=
'#' )
178 outFile << inFile.rdbuf() ;
std::shared_ptr< StringParameters > getParameters(const std::string §ionName) const
Return the StringParameters defined for this section of the steering file.
void add(const std::string &key, const std::vector< std::string > &values)
const std::string & getStringVal(const std::string &key)
int readNextValidLine(std::string &str, std::istream &stream)
Helper method that reads the next line from a stream that is not empty or starts with a '#'...
void parse()
Parse the input file.
void write(const std::string &fname) const
Write down the parsed file in a new file.
StringParameters * _current
Simple parameters class for Marlin.