129 substitute(
const char* str,
const string* fromStrs,
const string* toStrs);
132 static const string RegStrs[] = {
"<",
">",
"&",
"\""};
133 static const string EscStrs[] = {
"<",
">",
"&",
"""};
154 static string newStr = string(
"", 512);
157 if (!str) {
return retStr; }
161 int strLn = strlen(str);
162 for (
int i = 0; str[i] !=
'\0'; ) {
165 int curSub = 0, curSubLn = 0;
166 for (; curSub <
numSubs; curSub++) {
167 curSubLn = fromStrs[curSub].length();
168 if ((strLn-i >= curSubLn) &&
169 (strncmp(str+i, fromStrs[curSub].c_str(), curSubLn) == 0)) {
176 if (curSub < numSubs) {
177 newStr += toStrs[curSub]; i += curSubLn;
179 newStr += str[i]; i++;
static const string RegStrs[]
static const string EscStrs[]
bool WriteAttrStr(std::ostream &os, const char *s, int flags=ESC_TRUE)
bool Skip(std::istream &is, const char *s)
std::string Get(std::istream &is, char end)
std::string EscapeStr(const char *str)
static string substitute(const char *str, const string *fromStrs, const string *toStrs)
bool ReadAttrStr(std::istream &is, std::string &s, int flags=UNESC_TRUE)
std::string UnEscapeStr(const char *str)