Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using constants in XML files #20

Merged
merged 8 commits into from
Sep 27, 2017
11 changes: 9 additions & 2 deletions source/include/marlin/XMLParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ namespace marlin{

/** Extracts all parameters from the given node and adss them to the current StringParameters object
*/
void parametersFromNode(TiXmlNode* section, std::pair<unsigned,unsigned>* typeCount=0) ;
void parametersFromNode(TiXmlNode* section, std::map<std::string, std::string>& constants, std::pair<unsigned,unsigned>* typeCount=0) ;

/** Return named attribute - throws ParseException if attribute doesn't exist */
const char* getAttribute( TiXmlNode* node , const std::string& name ) ;
Expand All @@ -188,7 +188,14 @@ namespace marlin{
/** Helper method - recursively replace all <include ref="..."> with the corresponding
* file content
*/
void processIncludeElements( TiXmlElement* element );
void processIncludeElements( TiXmlElement* element , const std::map<std::string, std::string>& constants );

void processIncludeElement( TiXmlElement* element , const std::map<std::string, std::string>& constants , TiXmlDocument &document);

void processConstants( TiXmlNode* node , std::map<std::string, std::string>& constants ) ;
void processConstant( TiXmlElement* element , std::map<std::string, std::string>& constants ) ;

std::string &performConstantReplacement( std::string& value, const std::map<std::string, std::string>& constants ) ;

mutable StringParametersMap _map{};
StringParameters* _current ;
Expand Down
3 changes: 2 additions & 1 deletion source/src/Marlin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ int main(int argc, char** argv ){
// save dynamic options into map
cmdlineparams[ cmdlinekey[0] ][ cmdlinekey[1] ] = cmdlinearg[1] ;

cout << "<!-- steering file parameter: [ " << cmdlinekey[0] << "." << cmdlinekey[1] << " ] will be OVERWRITTEN with value: [\"" << cmdlinearg[1] << "\"] -->" << endl;
std::string type = cmdlinekey[0] == "constant" ? "constant" : "parameter" ;
cout << "<!-- steering file " << type << ": [ " << cmdlinekey[0] << "." << cmdlinekey[1] << " ] will be OVERWRITTEN with value: [\"" << cmdlinearg[1] << "\"] -->" << endl;

// erase dynamic options from **argv
for( int j = i ; j < argc-1 ; j++ ){
Expand Down
Loading