Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_IosAllSaver.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Panzer: A partial differential equation assembly
4// engine for strongly coupled complex multiphysics systems
5//
6// Copyright 2011 NTESS and the Panzer contributors.
7// SPDX-License-Identifier: BSD-3-Clause
8// *****************************************************************************
9// @HEADER
10
11// *******************************************************************
12// This file contains a copy of one function from the io state saver
13// code from boost. Modified to use the panzer namespace and remove
14// locale support. Boost copyright is below.
15// *******************************************************************
16
17// Copyright 2002, 2005 Daryle Walker. Use, modification, and distribution
18// are subject to the Boost Software License, Version 1.0. (See accompanying
19// file LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
20
21// See <http://www.boost.org/libs/io/> for the library's home page.
22
23// *******************************************************************
24// *******************************************************************
25
26#ifndef PANZER_IOS_ALL_SAVER_HPP
27#define PANZER_IOS_ALL_SAVER_HPP
28
29#include "PanzerDiscFE_config.hpp"
30#include <iomanip>
31#include <iosfwd> // for std::char_traits (declaration)
32
33namespace panzer {
34
35 template < typename Ch, class Tr = ::std::char_traits<Ch> >
36 class basic_ios_all_saver;
37
42
51 template < typename Ch, class Tr >
53 {
54 public:
55 typedef ::std::basic_ios<Ch, Tr> state_type;
56
59 : s_save_( s ), a1_save_( s.flags() ), a2_save_( s.precision() )
60 , a3_save_( s.width() ), a4_save_( s.rdstate() )
61 , a5_save_( s.exceptions() ), a6_save_( s.tie() )
62 , a7_save_( s.rdbuf() ), a8_save_( s.fill() )
63 {}
64
67 { this->restore(); }
68
70 void restore()
71 {
72 s_save_.fill( a8_save_ );
73 s_save_.rdbuf( a7_save_ );
74 s_save_.tie( a6_save_ );
75 s_save_.exceptions( a5_save_ );
76 s_save_.clear( a4_save_ );
77 s_save_.width( a3_save_ );
78 s_save_.precision( a2_save_ );
79 s_save_.flags( a1_save_ );
80 }
81
82 private:
83 state_type & s_save_;
84 typename state_type::fmtflags const a1_save_;
85 ::std::streamsize const a2_save_;
86 ::std::streamsize const a3_save_;
87 typename state_type::iostate const a4_save_;
88 typename state_type::iostate const a5_save_;
89 ::std::basic_ostream<Ch, Tr> * const a6_save_;
90 ::std::basic_streambuf<Ch, Tr> * const a7_save_;
91 typename state_type::char_type const a8_save_;
92
94 };
95
96}
97
98#endif
RAII helper that saves a stream's formatting state on construction and restores it on destruction (or...
basic_ios_all_saver & operator=(const basic_ios_all_saver &)
::std::basic_ostream< Ch, Tr > *const a6_save_
state_type::char_type const a8_save_
~basic_ios_all_saver()
Restores the stream's formatting state as captured at construction.
::std::basic_streambuf< Ch, Tr > *const a7_save_
state_type::iostate const a5_save_
state_type::fmtflags const a1_save_
::std::streamsize const a2_save_
state_type::iostate const a4_save_
basic_ios_all_saver(state_type &s)
Captures the current formatting state of the given stream.
::std::streamsize const a3_save_
::std::basic_ios< Ch, Tr > state_type
void restore()
Restores the stream's formatting state as captured at construction.
basic_ios_all_saver< char > ios_all_saver
basic_ios_all_saver for narrow-character streams.
basic_ios_all_saver< wchar_t > wios_all_saver
basic_ios_all_saver for wide-character streams.