From e7a9321e43e53b73d4c454a9375d9bad0eeb9f4d Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Fri, 15 Dec 2006 00:30:46 +0000 Subject: [PATCH] Provide do_put methods for inserting all remaining basic type values into wide streams on systems where sizeof(wchar_t) == 2. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16275 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/docstring.C | 73 ++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/src/support/docstring.C b/src/support/docstring.C index e440b38b70..0c3739a014 100644 --- a/src/support/docstring.C +++ b/src/support/docstring.C @@ -439,53 +439,66 @@ public: }; protected: + iter_type + do_put(iter_type oit, std::ios_base & b, char_type fill, bool v) const + { + return do_put_helper(oit, b, fill, v); + } + 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; + return do_put_helper(oit, b, fill, v); } iter_type do_put(iter_type oit, std::ios_base & b, char_type fill, unsigned 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; + return do_put_helper(oit, b, fill, v); } +#ifdef _GLIBCXX_USE_LONG_LONG + iter_type + do_put(iter_type oit, std::ios_base & b, char_type fill, long long v) const + { + return do_put_helper(oit, b, fill, v); + } + + iter_type + do_put(iter_type oit, std::ios_base & b, char_type fill, unsigned long long v) const + { + return do_put_helper(oit, b, fill, v); + } +#endif + iter_type do_put(iter_type oit, std::ios_base & b, char_type fill, double v) const + { + return do_put_helper(oit, b, fill, v); + } + + iter_type + do_put(iter_type oit, std::ios_base & b, char_type fill, long double v) const + { + return do_put_helper(oit, b, fill, v); + } + + iter_type + do_put(iter_type oit, std::ios_base & b, char_type fill, void const * v) const + { + return do_put_helper(oit, b, fill, v); + } + +private: + template + iter_type + do_put_helper(iter_type oit, std::ios_base & b, char_type fill, ValueType v) const { if (fill >= 0x80) throw num_put_failure(); - std::string s; // 64 is large enough - s.resize(64); + std::string s(64, '\0'); string_num_put_facet f; std::string::const_iterator cit = s.begin(); std::string::const_iterator end =