00001 /** 00002 * @file stream_util.h 00003 * C++ stream utility 00004 * 00005 * @remark Copyright 2003 OProfile authors 00006 * @remark Read the file COPYING 00007 * 00008 * @author Philippe Elie 00009 * @author John Levon 00010 */ 00011 00012 #ifndef STREAM_UTIL_H 00013 #define STREAM_UTIL_H 00014 00015 #include <iostream> 00016 00017 /// class which save a stream state and restore it at dtor time 00018 class io_state { 00019 public: 00020 /** 00021 * save the stream flags, precision and fill char. 00022 * 00023 * width is restored at end of expression, there is no need to save it. 00024 * tie and locale are not saved currently 00025 * 00026 * error state shouldn't be saved. 00027 */ 00028 io_state(std::ios & stream); 00029 /// restore the stream state 00030 ~io_state(); 00031 private: 00032 std::ios & stream; 00033 00034 std::ios::fmtflags format; 00035 std::streamsize precision; 00036 char fill; 00037 }; 00038 00039 #endif /* !STREAM_UTIL_H */
1.6.1