From 948877d92073830ac5bc7b9cc65d93cb836fecee Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 15 Oct 2023 20:16:52 -0400 Subject: [PATCH] Remove the string-based code. --- string_algorithms.cpp | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/string_algorithms.cpp b/string_algorithms.cpp index 299ecba..f14993f 100644 --- a/string_algorithms.cpp +++ b/string_algorithms.cpp @@ -139,7 +139,6 @@ namespace Alepha::Cavorite ::detail:: string_algorithms std::string exports::expandVariables( const std::string &text, const VarMap &vars, const char sigil ) { - #if 1 std::ostringstream oss; oss << StartSubstitutions{ sigil, vars }; @@ -147,47 +146,6 @@ namespace Alepha::Cavorite ::detail:: string_algorithms oss << EndSubstitutions; return std::move( oss ).str(); - #else - if( C::debugExpansion ) error() << "Expanding variables in " << text << std::endl; - - std::string rv; - std::string varName; - - enum { Symbol, Normal } mode= Normal; - - for( const char ch: text ) - { - if( mode == Normal and ch == sigil ) - { - mode= Symbol; - varName.clear(); - continue; - } - if( mode == Symbol and ch == sigil ) - { - mode= Normal; - if( not varName.empty() ) - { - if( not vars.contains( varName ) ) - { - throw std::runtime_error( "No such variable: `" + varName + "`" ); - } - if( C::debugExpansion ) error() << "Expanding variable with name `" << varName << "`" << std::endl; - rv+= vars.at( varName )(); - } - else rv+= sigil; - continue; - } - - auto ¤t= mode == Normal ? rv : varName; - current+= ch; - } - - if( mode != Normal ) throw std::runtime_error( "Unterminated variable `" + varName + " in expansion of `" + text + "`" ); - if( C::debugExpansion ) error() << "Expansion was: `" << rv << "`" << std::endl; - - return rv; - #endif } std::vector< std::string >