source: NonGTP/Boost/boost/archive/codecvt_null.hpp @ 857

Revision 857, 3.4 KB checked in by igarcia, 19 years ago (diff)
Line 
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
24namespace std{
25    #if defined(__LIBCOMO__)
26        using ::mbstate_t;
27    #elif defined(_QNXNTO_)
28        using std::mbstate_t;
29    #elif defined(BOOST_DINKUMWARE_STDLIB)
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
38namespace boost {
39namespace archive {
40
41template<class Ch>
42class codecvt_null;
43
44template<>
45class codecvt_null<char> : public std::codecvt<char, char, std::mbstate_t>
46{
47    virtual bool do_always_noconv() const throw() {
48        return true;   
49    }
50public:
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
56template<>
57class 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// this befuddles the msvc 6 compiler so we can't use it
91#if ! ((defined _MSC_VER) && (_MSC_VER <= 1300)) \
92&&  ! defined(__BORLANDC__)
93
94#if defined(__SGI_STL_PORT)
95#if defined(_STLPORT_VERSION) && (_STLPORT_VERSION < 0x500)
96namespace std {
97
98#if 0
99template <>
100locale::locale(
101    const locale& __loc,
102    boost::archive::codecvt_null<char> * __f
103){
104     _M_impl = 0;
105    //      _M_impl = this->_S_copy_impl(__loc._M_impl, __f != 0);
106    new(this) locale(__loc._M_impl, __f != 0);
107    if (__f != 0)
108        this->_M_insert(__f, boost::archive::codecvt_null<char> ::id);
109}
110
111template <>
112locale::locale(
113    const locale& __loc,
114    boost::archive::codecvt_null<wchar_t> * __f
115){
116     _M_impl = 0;
117    //      _M_impl = this->_S_copy_impl(__loc._M_impl, __f != 0);
118    new(this) locale(__loc._M_impl, __f != 0);
119    if (__f != 0)
120        this->_M_insert(__f, boost::archive::codecvt_null<wchar_t> ::id);
121}
122#endif
123
124} // namespace std
125#endif
126#endif
127
128#endif
129
130#endif //BOOST_ARCHIVE_CODECVT_NULL_HPP
Note: See TracBrowser for help on using the repository browser.