5 #include "StringParameters.h"
6 #include "marlin/tinyxml.h"
18 typedef std::map< std::string , std::shared_ptr<StringParameters> > StringParametersMap;
116 std::vector< std::string >& _tokens ;
122 LCTokenizer( std::vector< std::string >& tokens,
char del,
size_t max=-1 ) : _tokens(tokens) , _del(del), _last(del), _max(max) {
126 void operator()(
const char& c) {
128 if( c != _del or _tokens.size() >= _max ) {
130 if( _last == _del and _tokens.size() < _max ) {
131 _tokens.push_back(
"") ;
133 _tokens.back() += c ;
143 std::vector<std::string> & result() {
151 XMLParser(
const std::string& fileName,
bool forCCheck=
false ) ;
156 _cmdlineparams = cmdlineparams ;
163 std::shared_ptr<StringParameters>
getParameters(
const std::string& sectionName )
const ;
166 void write(
const std::string &filen)
const ;
171 void parametersFromNode(
TiXmlNode* section, std::map<std::string, std::string>& constants, std::pair<unsigned,unsigned>* typeCount=0) ;
182 const std::string& attribute,
const std::string& value ) ;
195 void processIncludeElement(
TiXmlElement* element ,
const std::map<std::string, std::string>& constants ,
TiXmlDocument &document);
197 void processConstants(
TiXmlNode* node , std::map<std::string, std::string>& constants ) ;
198 void processConstant(
TiXmlElement* element , std::map<std::string, std::string>& constants ) ;
200 std::string &performConstantReplacement( std::string& value,
const std::map<std::string, std::string>& constants ) ;
202 void checkForNestedIncludes(
const TiXmlNode *node );
204 mutable StringParametersMap _map{};
205 StringParameters* _current ;
206 std::unique_ptr<TiXmlDocument> _doc{};
208 std::string _fileName ;
211 XMLParser() =
delete;
216 CommandLineParametersMap _cmdlineparams{};
XML parser for Marlin steering files.
Definition: XMLParser.h:106
void setCmdLineParameters(const CommandLineParametersMap &cmdlineparams)
set command line parameters
Definition: XMLParser.h:155
void write(const std::string &filen) const
Write the parsed XML tree in an other file.
Definition: XMLParser.cc:306
void processIncludeElements(TiXmlElement *element, const std::map< std::string, std::string > &constants)
Helper method - recursively replace all with the corresponding file content.
Definition: XMLParser.cc:583
const char * getAttribute(TiXmlNode *node, const std::string &name)
Return named attribute - throws ParseException if attribute doesn't exist.
Definition: XMLParser.cc:315
void processconditions(TiXmlNode *current, const std::string &conditions)
Helper method - recursively moves processors from <if> tags to top level (<execute>) and adds corresp...
Definition: XMLParser.cc:524
Interface for a parser of a steering file to be used with marlin.
Definition: IParser.h:19
Helper class for XMLParser.
Definition: XMLParser.h:114
std::shared_ptr< StringParameters > getParameters(const std::string §ionName) const
Return the StringParameters for the section as read from the xml file.
Definition: XMLParser.cc:511
Always the top level node.
Definition: tinyxml.h:1366
TiXmlNode * findElement(TiXmlNode *node, const std::string &type, const std::string &attribute, const std::string &value)
Helper method - finds child element of node with given type and attribute value.
Definition: XMLParser.cc:946
void parse()
Parse the input file.
Definition: XMLParser.cc:24
The parent class for everything in the Document Object Model.
Definition: tinyxml.h:425
void replacegroups(TiXmlNode *section)
Helper method - replaces all <group> tag with corresponding <processor> tags.
Definition: XMLParser.cc:899
void parametersFromNode(TiXmlNode *section, std::map< std::string, std::string > &constants, std::pair< unsigned, unsigned > *typeCount=0)
Extracts all parameters from the given node and adss them to the current StringParameters object...
Definition: XMLParser.cc:336
The element is a container class.
Definition: tinyxml.h:943