annotate DEPENDENCIES/generic/include/boost/iostreams/detail/codecvt_holder.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
Chris@16 2 // (C) Copyright 2003-2007 Jonathan Turkanis
Chris@16 3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
Chris@16 5
Chris@16 6 // See http://www.boost.org/libs/iostreams for documentation.
Chris@16 7
Chris@16 8 // Contains machinery for performing code conversion.
Chris@16 9
Chris@16 10 #ifndef BOOST_IOSTREAMS_DETAIL_CODECVT_HOLDER_HPP_INCLUDED
Chris@16 11 #define BOOST_IOSTREAMS_DETAIL_CODECVT_HOLDER_HPP_INCLUDED
Chris@16 12
Chris@16 13 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
Chris@16 14 # pragma once
Chris@16 15 #endif
Chris@16 16
Chris@16 17 #include <cwchar> // mbstate_t.
Chris@16 18 #include <locale> // codecvt, locale.
Chris@16 19 #include <boost/config.hpp> // HAS_MACRO_USE_FACET.
Chris@16 20 #include <boost/iostreams/detail/config/codecvt.hpp>
Chris@16 21
Chris@16 22 namespace boost { namespace iostreams { namespace detail {
Chris@16 23
Chris@16 24 struct default_codecvt {
Chris@16 25 typedef wchar_t intern_type, from_type;
Chris@16 26 typedef char extern_type, to_type;
Chris@16 27 typedef std::mbstate_t state_type;
Chris@16 28 };
Chris@16 29
Chris@16 30 template<typename Codecvt>
Chris@16 31 struct codecvt_holder {
Chris@16 32 typedef Codecvt codecvt_type;
Chris@16 33 const codecvt_type& get() const { return codecvt_; }
Chris@16 34 void imbue(const std::locale&) { }
Chris@16 35 Codecvt codecvt_;
Chris@16 36 };
Chris@16 37
Chris@16 38 template<>
Chris@16 39 struct codecvt_holder<default_codecvt> {
Chris@16 40 typedef std::codecvt<wchar_t, char, std::mbstate_t> codecvt_type;
Chris@16 41 codecvt_holder() { reset_codecvt(); }
Chris@16 42 const codecvt_type& get() const { return *codecvt_; }
Chris@16 43 void imbue(const std::locale& loc)
Chris@16 44 {
Chris@16 45 loc_ = loc;
Chris@16 46 reset_codecvt();
Chris@16 47 }
Chris@16 48 void reset_codecvt()
Chris@16 49 {
Chris@16 50 using namespace std;
Chris@16 51 #ifndef BOOST_HAS_MACRO_USE_FACET
Chris@16 52 codecvt_ = & use_facet< codecvt_type >(loc_);
Chris@16 53 #else
Chris@16 54 codecvt_ = & _USE(loc_, codecvt_type);
Chris@16 55 #endif
Chris@16 56 }
Chris@16 57 std::locale loc_; // Prevent codecvt_ from being freed.
Chris@16 58 const codecvt_type* codecvt_;
Chris@16 59 };
Chris@16 60
Chris@16 61 } } } // End namespaces detail, iostreams, boost.
Chris@16 62
Chris@16 63 #endif // #ifndef BOOST_IOSTREAMS_DETAIL_CODECVT_HOLDER_HPP_INCLUDED