[29] | 1 | #ifndef BOOST_ARCHIVE_CODECVT_NULL_HPP |
---|
| 2 | #define BOOST_ARCHIVE_CODECVT_NULL_HPP |
---|
| 3 | |
---|
| 4 | // MS compatible compilers support #pragma once |
---|
| 5 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) |
---|
| 6 | # pragma once |
---|
| 7 | #endif |
---|
| 8 | |
---|
| 9 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 |
---|
| 10 | // codecvt_null.hpp: |
---|
| 11 | |
---|
| 12 | // (C) Copyright 2004 Robert Ramey - http://www.rrsd.com . |
---|
| 13 | // Use, modification and distribution is subject to the Boost Software |
---|
| 14 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
---|
| 15 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
| 16 | |
---|
| 17 | // See http://www.boost.org for updates, documentation, and revision history. |
---|
| 18 | |
---|
| 19 | #include <locale> |
---|
| 20 | #include <cstddef> |
---|
| 21 | |
---|
| 22 | #include <boost/config.hpp> |
---|
| 23 | |
---|
| 24 | namespace std{ |
---|
| 25 | #if defined(__LIBCOMO__) |
---|
| 26 | using ::mbstate_t; |
---|
| 27 | #elif defined(__QNXNTO__) |
---|
| 28 | using std::mbstate_t; |
---|
| 29 | #elif defined(BOOST_DINKUMWARE_STDLIB) && BOOST_DINKUMWARE_STDLIB == 1 |
---|
| 30 | using ::mbstate_t; |
---|
| 31 | #elif defined(__SGI_STL_PORT) |
---|
| 32 | #elif defined(BOOST_NO_STDC_NAMESPACE) |
---|
| 33 | using ::codecvt; |
---|
| 34 | using ::mbstate_t; |
---|
| 35 | #endif |
---|
| 36 | } // namespace std |
---|
| 37 | |
---|
| 38 | namespace boost { |
---|
| 39 | namespace archive { |
---|
| 40 | |
---|
| 41 | template<class Ch> |
---|
| 42 | class codecvt_null; |
---|
| 43 | |
---|
| 44 | template<> |
---|
| 45 | class codecvt_null<char> : public std::codecvt<char, char, std::mbstate_t> |
---|
| 46 | { |
---|
| 47 | virtual bool do_always_noconv() const throw() { |
---|
| 48 | return true; |
---|
| 49 | } |
---|
| 50 | public: |
---|
| 51 | explicit codecvt_null(std::size_t no_locale_manage = 0) : |
---|
| 52 | std::codecvt<char, char, std::mbstate_t>(no_locale_manage) |
---|
| 53 | {} |
---|
| 54 | }; |
---|
| 55 | |
---|
| 56 | template<> |
---|
| 57 | class codecvt_null<wchar_t> : public std::codecvt<wchar_t, char, std::mbstate_t> |
---|
| 58 | { |
---|
| 59 | virtual std::codecvt_base::result |
---|
| 60 | do_out( |
---|
| 61 | std::mbstate_t & state, |
---|
| 62 | const wchar_t * first1, |
---|
| 63 | const wchar_t * last1, |
---|
| 64 | const wchar_t * & next1, |
---|
| 65 | char * first2, |
---|
| 66 | char * last2, |
---|
| 67 | char * & next2 |
---|
| 68 | ) const; |
---|
| 69 | virtual std::codecvt_base::result |
---|
| 70 | do_in( |
---|
| 71 | std::mbstate_t & state, |
---|
| 72 | const char * first1, |
---|
| 73 | const char * last1, |
---|
| 74 | const char * & next1, |
---|
| 75 | wchar_t * first2, |
---|
| 76 | wchar_t * last2, |
---|
| 77 | wchar_t * & next2 |
---|
| 78 | ) const; |
---|
| 79 | virtual int do_encoding( ) const throw( ){ |
---|
| 80 | return sizeof(wchar_t) / sizeof(char); |
---|
| 81 | } |
---|
| 82 | virtual int do_max_length( ) const throw( ){ |
---|
| 83 | return do_encoding(); |
---|
| 84 | } |
---|
| 85 | }; |
---|
| 86 | |
---|
| 87 | } // namespace archive |
---|
| 88 | } // namespace boost |
---|
| 89 | |
---|
| 90 | #endif //BOOST_ARCHIVE_CODECVT_NULL_HPP |
---|