]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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) | |
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> // NULL, size_t | |
21 | #include <cwchar> // for mbstate_t | |
22 | #include <boost/config.hpp> | |
23 | #include <boost/archive/detail/auto_link_archive.hpp> | |
24 | #include <boost/archive/detail/abi_prefix.hpp> // must be the last header | |
25 | ||
26 | #if defined(BOOST_NO_STDC_NAMESPACE) | |
27 | namespace std { | |
28 | // For STLport on WinCE, BOOST_NO_STDC_NAMESPACE can get defined if STLport is putting symbols in its own namespace. | |
29 | // In the case of codecvt, however, this does not mean that codecvt is in the global namespace (it will be in STLport's namespace) | |
30 | # if !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) | |
31 | using ::codecvt; | |
32 | # endif | |
33 | using ::mbstate_t; | |
34 | using ::size_t; | |
35 | } // namespace | |
36 | #endif | |
37 | ||
38 | #ifdef BOOST_MSVC | |
39 | # pragma warning(push) | |
40 | # pragma warning(disable : 4511 4512) | |
41 | #endif | |
42 | ||
43 | namespace boost { | |
44 | namespace archive { | |
45 | ||
46 | template<class Ch> | |
47 | class codecvt_null; | |
48 | ||
49 | template<> | |
50 | class codecvt_null<char> : public std::codecvt<char, char, std::mbstate_t> | |
51 | { | |
52 | virtual bool do_always_noconv() const throw() { | |
53 | return true; | |
54 | } | |
55 | public: | |
56 | explicit codecvt_null(std::size_t no_locale_manage = 0) : | |
57 | std::codecvt<char, char, std::mbstate_t>(no_locale_manage) | |
58 | {} | |
59 | virtual ~codecvt_null(){}; | |
60 | }; | |
61 | ||
62 | template<> | |
63 | class BOOST_SYMBOL_VISIBLE codecvt_null<wchar_t> : public std::codecvt<wchar_t, char, std::mbstate_t> | |
64 | { | |
65 | virtual BOOST_WARCHIVE_DECL std::codecvt_base::result | |
66 | do_out( | |
67 | std::mbstate_t & state, | |
68 | const wchar_t * first1, | |
69 | const wchar_t * last1, | |
70 | const wchar_t * & next1, | |
71 | char * first2, | |
72 | char * last2, | |
73 | char * & next2 | |
74 | ) const; | |
75 | virtual BOOST_WARCHIVE_DECL std::codecvt_base::result | |
76 | do_in( | |
77 | std::mbstate_t & state, | |
78 | const char * first1, | |
79 | const char * last1, | |
80 | const char * & next1, | |
81 | wchar_t * first2, | |
82 | wchar_t * last2, | |
83 | wchar_t * & next2 | |
84 | ) const; | |
85 | virtual int do_encoding( ) const throw( ){ | |
86 | return sizeof(wchar_t) / sizeof(char); | |
87 | } | |
88 | virtual int do_max_length( ) const throw( ){ | |
89 | return do_encoding(); | |
90 | } | |
91 | public: | |
92 | explicit codecvt_null(std::size_t no_locale_manage = 0) : | |
93 | std::codecvt<wchar_t, char, std::mbstate_t>(no_locale_manage) | |
94 | {} | |
95 | virtual ~codecvt_null(){}; | |
96 | }; | |
97 | ||
98 | } // namespace archive | |
99 | } // namespace boost | |
100 | ||
101 | #ifdef BOOST_MSVC | |
102 | # pragma warning(pop) | |
103 | #endif | |
104 | #include <boost/archive/detail/abi_suffix.hpp> // pop pragmas | |
105 | ||
106 | #endif //BOOST_ARCHIVE_CODECVT_NULL_HPP |