I was just reading through this thread quickly, and I noticed something that I thought I should comment on:
Code:
(ch == '<')? SS << "<" : (ch == '>')? SS << ">" : SS << ch;
That might be easier to read as
Code:
SS << (ch == '<' ? "<" : (ch == '>' ? ">" : ch));
I really don't like nesting the conditional operator, though, so I'd suggest using if/else or switch instead. Or, better yet, perhaps something like this:
Code:
const char *find = "<>";
const char *replace[] = {"<", ">"};
const char *p;
if((p = strchr(find, ch))) SS << replace[p - find];
else SS << ch;
But maybe that's just overkill.