Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

vul_ios_state.h

Go to the documentation of this file.
00001 // This is core/vul/vul_ios_state.h
00002 #ifndef vul_ios_state_h_
00003 #define vul_ios_state_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief saves and restores stream state
00010 // \author Ian Scott, Imorphics.
00011 // \date   03 April 2007
00012 //
00013 // Modifications are subject to the VXL license.
00014 //
00015 // Copied from http://www.boost.org/boost/io/ios_state.hpp
00016 //
00017 //  Original:
00018 //  Copyright 2002, 2005 Daryle Walker.  Use, modification, and distribution
00019 //  are subject to the Boost Software License, Version 1.0.  (See accompanying
00020 //  file LICENSE_1_0.txt or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
00021 //
00022 // Boost Software License - Version 1.0 - August 17th, 2003
00023 //
00024 // Permission is hereby granted, free of charge, to any person or organization
00025 // obtaining a copy of the software and accompanying documentation covered by
00026 // this license (the "Software") to use, reproduce, display, distribute,
00027 // execute, and transmit the Software, and to prepare derivative works of the
00028 // Software, and to permit third-parties to whom the Software is furnished to
00029 // do so, all subject to the following:
00030 //
00031 // The copyright notices in the Software and this entire statement, including
00032 // the above license grant, this restriction and the following disclaimer,
00033 // must be included in all copies of the Software, in whole or in part, and
00034 // all derivative works of the Software, unless such copies or derivative
00035 // works are solely in the form of machine-executable object code generated by
00036 // a source language processor.
00037 //
00038 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00039 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00040 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
00041 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
00042 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
00043 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00044 // DEALINGS IN THE SOFTWARE.
00045 
00046 #include <vcl_ios.h>
00047 
00048 class vul_ios_state_saver
00049 {
00050   public:
00051     explicit  vul_ios_state_saver( vcl_ios_base &s )
00052         : stream_( s ),
00053         flags_( s.flags() ),
00054         precision_( s.precision() ),
00055         width_( s.width() )
00056     {}
00057     ~vul_ios_state_saver()
00058     { this->restore(); }
00059 
00060     void  restore()
00061     {
00062       stream_.width(width_);
00063       stream_.precision(precision_);
00064       stream_.flags(flags_);
00065     }
00066 
00067   private:
00068     vcl_ios_base & stream_;
00069     const vcl_ios_fmtflags flags_;
00070     const vcl_streamsize precision_;
00071     const vcl_streamsize width_;
00072 };
00073 
00074 #endif

Generated on Thu Jan 10 14:41:00 2008 for core/vul by  doxygen 1.4.4