25 typedef std::map<std::string, std::string> VarMap;
33 bool addVariable(
const std::string& key,
const std::string& value)
37 war <<
"TextParser: empty key on variable setting..";
41 variables[key] =
parseText(value.c_str());
48 std::string
ret, startKeyword, endKeyword;
56 startKeyword =
"$ENV{";
58 bool badSymbol =
ret.find(
"$") != std::string::npos;
59 s =
ret.find(startKeyword);
60 e =
ret.find(endKeyword, s);
62 if(s != std::string::npos && e != std::string::npos)
64 std::string envName, envValue;
66 envName =
ret.substr(s + startKeyword.size(), e - s -startKeyword.size());
68 ret =
ret.substr(0, s)+ envValue +
ret.substr(e + endKeyword.size(),
ret.size() - endKeyword.size());
75 s =
ret.find(startKeyword);
76 e =
ret.find(endKeyword, s);
78 if(s != std::string::npos && e != std::string::npos)
80 std::string envName, envValue;
82 envName =
ret.substr(s + startKeyword.size(), e - s -startKeyword.size());
83 envValue = variables[envName];
84 ret =
ret.substr(0, s)+ envValue +
ret.substr(e + endKeyword.size(),
ret.size() - endKeyword.size());
90 war <<
"use of symbol '$' detected but no keyword understood.. possible use: ${foo} for internal variable or $ENV{foo} for environment variable";
102 #endif // TEXTPARSER_H