From 55f85a4d1f8e649441225620bc1043bdddc6f20a Mon Sep 17 00:00:00 2001 From: Robert Ramey Date: Mon, 11 Nov 2013 02:25:58 +0000 Subject: [PATCH] changed codecvt_utf8 so that serialization uses the standard one if available. If there is no standard one available, it uses the one in boost/utility. [SVN r86614] --- include/boost/detail/utf8_codecvt_facet.hpp | 39 +++++++++++++-------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/include/boost/detail/utf8_codecvt_facet.hpp b/include/boost/detail/utf8_codecvt_facet.hpp index eb65418..8344384 100644 --- a/include/boost/detail/utf8_codecvt_facet.hpp +++ b/include/boost/detail/utf8_codecvt_facet.hpp @@ -85,6 +85,10 @@ #include #include +#ifndef BOOST_NO_CXX11_HDR_CODECVT +#include +#endif + #if defined(BOOST_NO_STDC_NAMESPACE) namespace std { using ::mbstate_t; @@ -92,13 +96,6 @@ namespace std { } #endif -#if defined(_CPPLIB_VER) && (_CPPLIB_VER < 540) - #define BOOST_CODECVT_DO_LENGTH_CONST const -#else - #define BOOST_CODECVT_DO_LENGTH_CONST -#endif - -// maximum lenght of a multibyte string #define MB_LENGTH_MAX 8 BOOST_UTF8_BEGIN_NAMESPACE @@ -167,17 +164,30 @@ protected: } // How many char objects can I process to get <= max_limit - // wchar_t objects? + // wchar_t objects? + // This is the "official version which implements the standar + // library interface virtual int do_length( - BOOST_CODECVT_DO_LENGTH_CONST std::mbstate_t &, + std::mbstate_t & state, const char * from, const char * from_end, std::size_t max_limit -#if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) - ) const throw(); -#else - ) const; -#endif + ) const + #if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) + throw() + #endif + { + return do_length(const_cast(state), from, from_end, max_limit); + } + + // this version handles versions of the standard library which pass + // the state with a "const". This means early dinkumware standard library + virtual int do_length( + const std::mbstate_t & state, + const char * from, + const char * from_end, + std::size_t max_limit + ) const; // Largest possible value do_length(state,from,from_end,1) could return. virtual int do_max_length() const throw () { @@ -185,6 +195,7 @@ protected: } }; + BOOST_UTF8_END_NAMESPACE #endif // BOOST_UTF8_CODECVT_FACET_HPP