File indexing completed on 2025-01-18 09:28:29
0001 #ifndef BOOST_ARCHIVE_BASIC_STREAMBUF_LOCALE_SAVER_HPP
0002 #define BOOST_ARCHIVE_BASIC_STREAMBUF_LOCALE_SAVER_HPP
0003
0004
0005 #if defined(_MSC_VER)
0006 # pragma once
0007 #endif
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #ifndef BOOST_NO_STD_LOCALE
0028
0029 #include <locale> // for std::locale
0030 #include <ios>
0031 #include <streambuf> // for std::basic_streambuf
0032
0033 #include <boost/config.hpp>
0034 #include <boost/noncopyable.hpp>
0035
0036 #ifdef BOOST_MSVC
0037 # pragma warning(push)
0038 # pragma warning(disable : 4511 4512)
0039 #endif
0040
0041 namespace boost{
0042 namespace archive{
0043
0044 template < typename Ch, class Tr >
0045 class basic_streambuf_locale_saver :
0046 private boost::noncopyable
0047 {
0048 public:
0049 explicit basic_streambuf_locale_saver(std::basic_streambuf<Ch, Tr> &s) :
0050 m_streambuf(s),
0051 m_locale(s.getloc())
0052 {}
0053 ~basic_streambuf_locale_saver(){
0054 m_streambuf.pubsync();
0055 m_streambuf.pubimbue(m_locale);
0056 }
0057 private:
0058 std::basic_streambuf<Ch, Tr> & m_streambuf;
0059 std::locale const m_locale;
0060 };
0061
0062 template < typename Ch, class Tr >
0063 class basic_istream_locale_saver :
0064 private boost::noncopyable
0065 {
0066 public:
0067 explicit basic_istream_locale_saver(std::basic_istream<Ch, Tr> &s) :
0068 m_istream(s),
0069 m_locale(s.getloc())
0070 {}
0071 ~basic_istream_locale_saver(){
0072
0073 m_istream.sync();
0074 m_istream.imbue(m_locale);
0075 }
0076 private:
0077 std::basic_istream<Ch, Tr> & m_istream;
0078 std::locale const m_locale;
0079 };
0080
0081 template < typename Ch, class Tr >
0082 class basic_ostream_locale_saver :
0083 private boost::noncopyable
0084 {
0085 public:
0086 explicit basic_ostream_locale_saver(std::basic_ostream<Ch, Tr> &s) :
0087 m_ostream(s),
0088 m_locale(s.getloc())
0089 {}
0090 ~basic_ostream_locale_saver(){
0091 m_ostream.flush();
0092 m_ostream.imbue(m_locale);
0093 }
0094 private:
0095 std::basic_ostream<Ch, Tr> & m_ostream;
0096 std::locale const m_locale;
0097 };
0098
0099
0100 }
0101 }
0102
0103 #ifdef BOOST_MSVC
0104 #pragma warning(pop)
0105 #endif
0106
0107 #endif
0108 #endif