From: Martin (adrianm_at_[hidden])
Date: 2004-11-09 02:42:35
> the user could define. At some point, I decided it was bad manners to keep
> changing a stream's locale.
Why is it bad manners to set the streams locale? The default locale
is "classic" but I always change it to the user's preferred locale. For some
streams (e.g. to generate SQL statements) I specify classic locale to avoid
locale based formatting.
A custom facet doesn't change the locale, it just adds new functionality to
the existing locale just as pword adds new functionality to streams. Both
tribool and date_time library uses custom facets for the formatting.
> By the way, there would be one facet for each selector, e.g., sequence_punc<
> vector<_>, char >.
Yes, but that is not different from your manipulator implementation.
To make it easy you could have a facet where the constructor accepts a
punctuate object. It would work something like this:
std::locale mylocale(std::locale(), new sequence_punct(punctuate< pair<string,
string> >("[ ", " : ", " ]"));
stream << xxx
> I'm not yet familiar with the program options library. With lexical_cast,
> there's no way to specify a locale, so I guess you're talking about setting
> global locale. Right? I'm afraid this might be bad manners, too.
See above about bad manners but you are right about that the global locale
needs to be changed. I suggested that program_options library should include
an imbue method but I don't think the author agreed.
lexical_cast is just broken.
>Mybe I can provide both options.
Should be easy, just check if the facet exists and if not check the pword.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk