00001 #ifndef IOF_STREAM_FMT_HPP_
00002 #define IOF_STREAM_FMT_HPP_
00003
00016 #include <ios>
00017
00018 namespace iof
00019 {
00020
00024 struct stream_fmt
00025 {
00026 const int width, precision;
00027 const char fillChar;
00028 const std::ios::fmtflags flags;
00029
00030
00031 stream_fmt(const std::ios& strm)
00032 : width(strm.width()), precision(strm.precision()),
00033 fillChar(strm.fill()), flags(strm.flags()) {}
00034
00035 stream_fmt(const stream_fmt& fmt)
00036 : width(fmt.width), precision(fmt.precision),
00037 fillChar(fmt.fillChar), flags(fmt.flags) {}
00038
00040 void applyTo(std::ios& strm) const
00041 {
00042 strm.fill(fillChar);
00043 strm.precision(precision);
00044 strm.width(width);
00045 strm.flags(flags);
00046 }
00047
00048 bool operator==(const stream_fmt& rhs) const
00049 {
00050 return rhs.width == width
00051 && rhs.precision == precision
00052 && rhs.fillChar == fillChar
00053 && rhs.flags == flags;
00054 }
00055 bool operator!=(const stream_fmt& rhs) const {return !(*this == rhs);}
00056
00057 };
00058
00059
00060 }
00061
00062
00063 #endif // IOF_STREAM_FMT_HPP_