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

Allow to empty constant values #55

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions source/src/XMLParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading