Home | History | Annotate | Download | only in libutil++
      1 /**
      2  * @file stream_util.h
      3  * C++ stream utility
      4  *
      5  * @remark Copyright 2003 OProfile authors
      6  * @remark Read the file COPYING
      7  *
      8  * @author Philippe Elie
      9  * @author John Levon
     10  */
     11 
     12 #ifndef STREAM_UTIL_H
     13 #define STREAM_UTIL_H
     14 
     15 #include <iostream>
     16 
     17 /// class which save a stream state and restore it at dtor time
     18 class io_state {
     19 public:
     20 	/**
     21 	 * save the stream flags, precision and fill char.
     22 	 *
     23 	 * width is restored at end of expression, there is no need to save it.
     24 	 * tie and locale are not saved currently
     25 	 *
     26 	 * error state shouldn't be saved.
     27 	 */
     28 	io_state(std::ios & stream);
     29 	/// restore the stream state
     30 	~io_state();
     31 private:
     32 	std::ios & stream;
     33 
     34 	std::ios::fmtflags format;
     35 	std::streamsize precision;
     36 	char fill;
     37 };
     38 
     39 #endif /* !STREAM_UTIL_H */
     40