From 2c428cd1307a653b59ad7646f38643f2a989d021 Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Fri, 16 Feb 2024 13:54:55 +0100 Subject: [PATCH] Allow to empty constant values (#55) --- source/src/XMLParser.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/source/src/XMLParser.cc b/source/src/XMLParser.cc index 411a0b4..9bac51d 100644 --- a/source/src/XMLParser.cc +++ b/source/src/XMLParser.cc @@ -873,16 +873,14 @@ namespace marlin{ } const std::string key( value.substr( pos+2 , pos2-pos-2 )) ; - auto findConstant = constants.find( key ) ; - const std::string replacementValue( findConstant != constants.end() ? findConstant->second : "" ) ; - - if( replacementValue.empty() ) { - + const auto findConstant = constants.find( key ) ; + if (findConstant == constants.end()) { std::stringstream str ; str << "XMLParser::performConstantReplacement : constant \"" << key << "\" not found in available constants !" ; throw ParseException( str.str() ) ; } - + const auto& replacementValue = findConstant->second; + value.replace( pos , (pos2+1-pos) , replacementValue ) ; pos2 = pos + replacementValue.size() ; // new end position after replace