Chris@16: #ifndef BOOST_ARCHIVE_BASIC_STREAMBUF_LOCALE_SAVER_HPP Chris@16: #define BOOST_ARCHIVE_BASIC_STREAMBUF_LOCALE_SAVER_HPP Chris@16: Chris@16: // MS compatible compilers support #pragma once Chris@101: #if defined(_MSC_VER) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 Chris@101: // basic_streambuf_locale_saver.hpp Chris@16: Chris@16: // (C) Copyright 2005 Robert Ramey - http://www.rrsd.com Chris@16: Chris@16: // Use, modification and distribution is subject to the Boost Software Chris@16: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // See http://www.boost.org for updates, documentation, and revision history. Chris@16: Chris@16: // note derived from boost/io/ios_state.hpp Chris@16: // Copyright 2002, 2005 Daryle Walker. Use, modification, and distribution Chris@16: // are subject to the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or a copy at .) Chris@16: Chris@16: // See for the library's home page. Chris@16: Chris@16: #ifndef BOOST_NO_STD_LOCALE Chris@16: Chris@16: #include // for std::locale Chris@16: #include // for std::basic_streambuf Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_MSVC Chris@16: # pragma warning(push) Chris@16: # pragma warning(disable : 4511 4512) Chris@16: #endif Chris@16: Chris@16: namespace boost{ Chris@16: namespace archive{ Chris@16: Chris@16: template < typename Ch, class Tr > Chris@16: class basic_streambuf_locale_saver : Chris@16: private boost::noncopyable Chris@16: { Chris@16: public: Chris@16: typedef ::std::basic_streambuf state_type; Chris@16: typedef ::std::locale aspect_type; Chris@16: explicit basic_streambuf_locale_saver( state_type &s ) Chris@16: : s_save_( s ), a_save_( s.getloc() ) Chris@16: {} Chris@101: explicit basic_streambuf_locale_saver( state_type &s, aspect_type const &a ) Chris@16: : s_save_( s ), a_save_( s.pubimbue(a) ) Chris@16: {} Chris@16: ~basic_streambuf_locale_saver() Chris@16: { this->restore(); } Chris@101: void restore(){ Chris@101: s_save_.pubsync(); Chris@101: s_save_.pubimbue( a_save_ ); Chris@101: } Chris@16: private: Chris@16: state_type & s_save_; Chris@16: aspect_type const a_save_; Chris@16: }; Chris@16: Chris@16: } // archive Chris@16: } // boost Chris@16: Chris@16: #ifdef BOOST_MSVC Chris@16: #pragma warning(pop) Chris@16: #endif Chris@16: Chris@16: #endif // BOOST_NO_STD_LOCALE Chris@16: #endif // BOOST_ARCHIVE_BASIC_STREAMBUF_LOCALE_SAVER_HPP