Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:49

0001 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
0002 // (C) Copyright 2003-2007 Jonathan Turkanis
0003 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0004 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
0005 
0006 // See http://www.boost.org/libs/iostreams for documentation.
0007 
0008 // Contains machinery for performing code conversion.
0009 
0010 #ifndef BOOST_IOSTREAMS_DETAIL_CODECVT_HOLDER_HPP_INCLUDED
0011 #define BOOST_IOSTREAMS_DETAIL_CODECVT_HOLDER_HPP_INCLUDED
0012 
0013 #if defined(_MSC_VER)
0014 # pragma once
0015 #endif
0016 
0017 #include <cwchar>            // mbstate_t.
0018 #include <locale>            // codecvt, locale.
0019 #include <boost/config.hpp>  // HAS_MACRO_USE_FACET.
0020 #include <boost/iostreams/detail/config/codecvt.hpp>
0021 
0022 namespace boost { namespace iostreams { namespace detail {
0023 
0024 struct default_codecvt { 
0025     typedef wchar_t         intern_type, from_type;
0026     typedef char            extern_type, to_type;
0027     typedef std::mbstate_t  state_type;
0028 };
0029 
0030 template<typename Codecvt>
0031 struct codecvt_holder {
0032     typedef Codecvt codecvt_type;
0033     const codecvt_type& get() const { return codecvt_; }
0034     void imbue(const std::locale&) { }
0035     Codecvt codecvt_;
0036 };
0037 
0038 template<>
0039 struct codecvt_holder<default_codecvt> {
0040     typedef std::codecvt<wchar_t, char, std::mbstate_t> codecvt_type;
0041     codecvt_holder() { reset_codecvt(); }
0042     const codecvt_type& get() const { return *codecvt_; }
0043     void imbue(const std::locale& loc) 
0044     { 
0045         loc_ = loc;
0046         reset_codecvt();
0047     }
0048     void reset_codecvt()
0049     {
0050         using namespace std;
0051         #ifndef BOOST_HAS_MACRO_USE_FACET
0052             codecvt_ = & use_facet< codecvt_type >(loc_);
0053         #else
0054             codecvt_ = & _USE(loc_, codecvt_type);
0055         #endif
0056     }
0057     std::locale loc_; // Prevent codecvt_ from being freed.
0058     const codecvt_type* codecvt_;
0059 };
0060 
0061 } } } // End namespaces detail, iostreams, boost.
0062 
0063 #endif // #ifndef BOOST_IOSTREAMS_DETAIL_CODECVT_HOLDER_HPP_INCLUDED