
"Martin" <adrianm@touchdown.se> wrote in message news:loom.20041109T081650-836@post.gmane.org...
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.
Personally I don't feel strongly about it. But P.J.Plaugher, in his proposal to add additional code convertion components to the standard library (http://tinyurl.com/5hal5), mentions the fact that the components do not modify a stream's locale as a feature. I thought others might share this view, and didn't see any reason to prefer a locale-based solution, so I used pword instead. Of course this can be reconsidered.
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.
It does change the locale, but the new locale is mostly a copy of the old one. (I'm sure you know this.)
Both tribool and date_time library uses custom facets for the formatting.
Okay, then this change might improve consitency with the rest of Boost.
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.
I'm aware of that.
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.imbue(mylocale); stream << xxx
sequence_punct would need some template parameter, so it would be better to use object generators, as in std::locale mylocale(std::locale(), punctuate_locale< pair<string, string>
( ... ));
Or how about: std::locale mylocale = std::locale() + punctuate< pair<string, string> >(...); :-) ?
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 the 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.
Right, but get_punctuation() for tuple-like objects already checks for three different facets using pword, and it really should be four (since I forgot to allow users to specify a default punctuation sequence for all types.) Doubling this would lead to a lot of checking. Best Regards, Jonathan