9 static int FormatTemplate(std::basic_string<T>& s,
const std::map<std::basic_string<T>, std::basic_string<T>>& variables,
const std::basic_string<T>& left,
const std::basic_string<T>& right)
11 if (left.empty() || right.empty())
13 throw std::exception(
"Missing l/r delimiter(s)");
24 while ((ii = s.find(left, ii)) != s.npos)
26 int jj = s.find(right, ii + left.length());
30 int replace_length = jj - ii + right.length();
31 int variable_length = jj - ii - left.length();
33 std::basic_string<T> variable = s.substr(ii + left.length(), variable_length);
34 std::map<std::basic_string<T>, std::basic_string<T>>::const_iterator iter = variables.find(variable);
35 if (iter != variables.end())
37 std::basic_string<T> variable_value = iter->second;
38 s.replace(ii, replace_length, variable_value);
39 ii += variable_value.length();