
22 Sep
2004
22 Sep
'04
6:14 a.m.
John Torjo wrote:
I would suggest every formatter takes only one string which parses and finds all decorators itself. Each formatter will have one or more escape sequences which it uses to find the decorators.
Something like:
// in this case, '%' is used for identifying an element // '*' is to mean "leave default" (don't change)
std::vector<int> v; // equivalent to your "[ ", ", ", " ]" std::cout << formatob(v, "[ %, % ]"); ....... // for pair - you have "%1" and "%2" std::vector< std::pair<int,long> > vp; // write XML std::cout << formatob(vp, containerfmt("<elem> % </elem><elem> % </elem>",
And how do you know what to output if there's only one element? - Volodya