@@ -537,20 +537,8 @@ static void replaceSpecialChars(std::string& source)
537537 }
538538}
539539
540- static void replaceColors (std::string& source)
540+ static void replace (std::string& source, const std::unordered_map<std::string, std::string> &substitutionMap )
541541{
542- static const std::unordered_map<std::string, std::string> substitutionMap =
543- {
544- {" {reset}" , ::toString (Color::Reset)},
545- {" {bold}" , ::toString (Color::Bold)},
546- {" {dim}" , ::toString (Color::Dim)},
547- {" {red}" , ::toString (Color::FgRed)},
548- {" {green}" , ::toString (Color::FgGreen)},
549- {" {blue}" , ::toString (Color::FgBlue)},
550- {" {magenta}" , ::toString (Color::FgMagenta)},
551- {" {default}" , ::toString (Color::FgDefault)},
552- };
553-
554542 std::string::size_type index = 0 ;
555543 while ((index = source.find (' {' , index)) != std::string::npos) {
556544 const std::string::size_type end = source.find (' }' , index);
@@ -568,6 +556,21 @@ static void replaceColors(std::string& source)
568556 }
569557}
570558
559+ static void replaceColors (std::string& source) {
560+ static const std::unordered_map<std::string, std::string> substitutionMap =
561+ {
562+ {" {reset}" , ::toString (Color::Reset)},
563+ {" {bold}" , ::toString (Color::Bold)},
564+ {" {dim}" , ::toString (Color::Dim)},
565+ {" {red}" , ::toString (Color::FgRed)},
566+ {" {green}" , ::toString (Color::FgGreen)},
567+ {" {blue}" , ::toString (Color::FgBlue)},
568+ {" {magenta}" , ::toString (Color::FgMagenta)},
569+ {" {default}" , ::toString (Color::FgDefault)},
570+ };
571+ replace (source, substitutionMap);
572+ }
573+
571574std::string ErrorMessage::toString (bool verbose, const std::string &templateFormat, const std::string &templateLocation) const
572575{
573576 // Save this ErrorMessage in plain text.
0 commit comments