Panzer  Version of the Day
Panzer_IosAllSaver.hpp
Go to the documentation of this file.
1 // *******************************************************************
2 // This file contains a copy of one function from the io state saver
3 // code from boost. Modified to use the panzer namespace and remove
4 // locale support. Boost copyright is below.
5 // *******************************************************************
6 
7 // Copyright 2002, 2005 Daryle Walker. Use, modification, and distribution
8 // are subject to the Boost Software License, Version 1.0. (See accompanying
9 // file LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
10 
11 // See <http://www.boost.org/libs/io/> for the library's home page.
12 
13 // *******************************************************************
14 // *******************************************************************
15 
16 #ifndef PANZER_IOS_ALL_SAVER_HPP
17 #define PANZER_IOS_ALL_SAVER_HPP
18 
19 #include "PanzerDiscFE_config.hpp"
20 #include <iomanip>
21 #include <iosfwd> // for std::char_traits (declaration)
22 
23 namespace panzer {
24 
25  template < typename Ch, class Tr = ::std::char_traits<Ch> >
27 
30 
31  template < typename Ch, class Tr >
33  {
34  public:
35  typedef ::std::basic_ios<Ch, Tr> state_type;
36 
38  : s_save_( s ), a1_save_( s.flags() ), a2_save_( s.precision() )
39  , a3_save_( s.width() ), a4_save_( s.rdstate() )
40  , a5_save_( s.exceptions() ), a6_save_( s.tie() )
41  , a7_save_( s.rdbuf() ), a8_save_( s.fill() )
42  {}
43 
45  { this->restore(); }
46 
47  void restore()
48  {
49  s_save_.fill( a8_save_ );
50  s_save_.rdbuf( a7_save_ );
51  s_save_.tie( a6_save_ );
52  s_save_.exceptions( a5_save_ );
53  s_save_.clear( a4_save_ );
54  s_save_.width( a3_save_ );
55  s_save_.precision( a2_save_ );
56  s_save_.flags( a1_save_ );
57  }
58 
59  private:
60  state_type & s_save_;
61  typename state_type::fmtflags const a1_save_;
62  ::std::streamsize const a2_save_;
63  ::std::streamsize const a3_save_;
64  typename state_type::iostate const a4_save_;
65  typename state_type::iostate const a5_save_;
66  ::std::basic_ostream<Ch, Tr> * const a6_save_;
67  ::std::basic_streambuf<Ch, Tr> * const a7_save_;
68  typename state_type::char_type const a8_save_;
69 
71  };
72 
73 }
74 
75 #endif
basic_ios_all_saver< wchar_t > wios_all_saver
basic_ios_all_saver & operator=(const basic_ios_all_saver &)
state_type::char_type const a8_save_
basic_ios_all_saver< char > ios_all_saver
::std::basic_ios< Ch, Tr > state_type
::std::streamsize const a2_save_
state_type::fmtflags const a1_save_
state_type::iostate const a4_save_
::std::streamsize const a3_save_
state_type::iostate const a5_save_
::std::basic_ostream< Ch, Tr > *const a6_save_
::std::basic_streambuf< Ch, Tr > *const a7_save_