mirror of
https://github.com/boostorg/io.git
synced 2025-07-30 12:27:13 +02:00
Added 'restore' member function to recover state (multiple times) within a code block
[SVN r27520]
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
// Boost io/ios_state.hpp header file --------------------------------------//
|
||||
|
||||
// Copyright 2002 Daryle Walker. Use, modification, and distribution are
|
||||
// subject to the Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
|
||||
// Copyright 2002, 2005 Daryle Walker. Use, modification, and distribution
|
||||
// are subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
|
||||
|
||||
// See <http://www.boost.org/libs/io/> for the library's home page.
|
||||
|
||||
@ -39,6 +39,9 @@ public:
|
||||
: s_save_( s ), a_save_( s.flags(a) )
|
||||
{}
|
||||
~ios_flags_saver()
|
||||
{ this->restore(); }
|
||||
|
||||
void restore()
|
||||
{ s_save_.flags( a_save_ ); }
|
||||
|
||||
private:
|
||||
@ -59,6 +62,9 @@ public:
|
||||
: s_save_( s ), a_save_( s.precision(a) )
|
||||
{}
|
||||
~ios_precision_saver()
|
||||
{ this->restore(); }
|
||||
|
||||
void restore()
|
||||
{ s_save_.precision( a_save_ ); }
|
||||
|
||||
private:
|
||||
@ -79,6 +85,9 @@ public:
|
||||
: s_save_( s ), a_save_( s.width(a) )
|
||||
{}
|
||||
~ios_width_saver()
|
||||
{ this->restore(); }
|
||||
|
||||
void restore()
|
||||
{ s_save_.width( a_save_ ); }
|
||||
|
||||
private:
|
||||
@ -103,6 +112,9 @@ public:
|
||||
: s_save_( s ), a_save_( s.rdstate() )
|
||||
{ s.clear(a); }
|
||||
~basic_ios_iostate_saver()
|
||||
{ this->restore(); }
|
||||
|
||||
void restore()
|
||||
{ s_save_.clear( a_save_ ); }
|
||||
|
||||
private:
|
||||
@ -124,6 +136,9 @@ public:
|
||||
: s_save_( s ), a_save_( s.exceptions() )
|
||||
{ s.exceptions(a); }
|
||||
~basic_ios_exception_saver()
|
||||
{ this->restore(); }
|
||||
|
||||
void restore()
|
||||
{ s_save_.exceptions( a_save_ ); }
|
||||
|
||||
private:
|
||||
@ -145,6 +160,9 @@ public:
|
||||
: s_save_( s ), a_save_( s.tie(a) )
|
||||
{}
|
||||
~basic_ios_tie_saver()
|
||||
{ this->restore(); }
|
||||
|
||||
void restore()
|
||||
{ s_save_.tie( a_save_ ); }
|
||||
|
||||
private:
|
||||
@ -166,6 +184,9 @@ public:
|
||||
: s_save_( s ), a_save_( s.rdbuf(a) )
|
||||
{}
|
||||
~basic_ios_rdbuf_saver()
|
||||
{ this->restore(); }
|
||||
|
||||
void restore()
|
||||
{ s_save_.rdbuf( a_save_ ); }
|
||||
|
||||
private:
|
||||
@ -187,6 +208,9 @@ public:
|
||||
: s_save_( s ), a_save_( s.fill(a) )
|
||||
{}
|
||||
~basic_ios_fill_saver()
|
||||
{ this->restore(); }
|
||||
|
||||
void restore()
|
||||
{ s_save_.fill( a_save_ ); }
|
||||
|
||||
private:
|
||||
@ -208,6 +232,9 @@ public:
|
||||
: s_save_( s ), a_save_( s.imbue(a) )
|
||||
{}
|
||||
~basic_ios_locale_saver()
|
||||
{ this->restore(); }
|
||||
|
||||
void restore()
|
||||
{ s_save_.imbue( a_save_ ); }
|
||||
|
||||
private:
|
||||
@ -232,6 +259,9 @@ public:
|
||||
: s_save_( s ), a_save_( s.iword(i) ), i_save_( i )
|
||||
{ s.iword(i) = a; }
|
||||
~ios_iword_saver()
|
||||
{ this->restore(); }
|
||||
|
||||
void restore()
|
||||
{ s_save_.iword( i_save_ ) = a_save_; }
|
||||
|
||||
private:
|
||||
@ -254,6 +284,9 @@ public:
|
||||
: s_save_( s ), a_save_( s.pword(i) ), i_save_( i )
|
||||
{ s.pword(i) = a; }
|
||||
~ios_pword_saver()
|
||||
{ this->restore(); }
|
||||
|
||||
void restore()
|
||||
{ s_save_.pword( i_save_ ) = a_save_; }
|
||||
|
||||
private:
|
||||
@ -276,6 +309,9 @@ public:
|
||||
{}
|
||||
|
||||
~ios_base_all_saver()
|
||||
{ this->restore(); }
|
||||
|
||||
void restore()
|
||||
{
|
||||
s_save_.width( a3_save_ );
|
||||
s_save_.precision( a2_save_ );
|
||||
@ -303,6 +339,9 @@ public:
|
||||
{}
|
||||
|
||||
~basic_ios_all_saver()
|
||||
{ this->restore(); }
|
||||
|
||||
void restore()
|
||||
{
|
||||
s_save_.imbue( a9_save_ );
|
||||
s_save_.fill( a8_save_ );
|
||||
@ -340,6 +379,9 @@ public:
|
||||
{}
|
||||
|
||||
~ios_all_word_saver()
|
||||
{ this->restore(); }
|
||||
|
||||
void restore()
|
||||
{
|
||||
s_save_.pword( i_save_ ) = a2_save_;
|
||||
s_save_.iword( i_save_ ) = a1_save_;
|
||||
|
Reference in New Issue
Block a user