+/// Facet for outputting numbers to odocstreams as ascii.
+/// Here we simply need defining the virtual do_put functions.
+class ascii_num_put_facet : public std::num_put<lyx::char_type, std::ostreambuf_iterator<lyx::char_type, std::char_traits<lyx::char_type> > >
+{
+ typedef std::ostreambuf_iterator<lyx::char_type, std::char_traits<lyx::char_type> > iter_type;
+public:
+ ascii_num_put_facet(size_t refs = 0) : std::num_put<lyx::char_type, iter_type>(refs) {}
+
+ /// Facet for converting numbers to ascii strings.
+ class string_num_put_facet : public std::num_put<char, std::basic_string<char>::iterator>
+ {
+ public:
+ string_num_put_facet() : std::num_put<char, std::basic_string<char>::iterator>(1) {}
+ };
+
+protected:
+ iter_type
+ do_put(iter_type oit, std::ios_base & b, char_type fill, long v) const
+ {
+ if (fill >= 0x80)
+ throw num_put_failure();
+
+ std::string s;
+ // 64 is large enough
+ s.resize(64);
+ string_num_put_facet f;
+ std::string::const_iterator cit = s.begin();
+ std::string::const_iterator end =
+ f.put(s.begin(), b, fill, v);
+ for (; cit != end; ++cit, ++oit)
+ *oit = *cit;
+
+ return oit;
+ }
+};
+
+
+/// class to add our facets to the global locale