ROSE  0.9.9.109
FormatRestorer.h
1 #ifndef ROSE_FormatRestorer_H
2 #define ROSE_FormatRestorer_H
3 
4 #include <iostream>
5 
53 protected:
54  std::ostream &stream;
55  std::ios_base::fmtflags fmt;
56 
57 public:
59  FormatRestorer(std::ostream &o): stream(o) {
60  save(o);
61  }
62 
65  restore();
66  }
67 
69  void save(std::ostream &o) {
70  fmt = o.flags();
71  }
72 
74  void restore() {
75  stream.flags(fmt);
76  }
77 };
78 
79 #endif
Restores output stream flags to original values.
FormatRestorer(std::ostream &o)
Constructor saves output stream flags.
~FormatRestorer()
Destructor restores output stream flags.
void save(std::ostream &o)
Save current output stream flags.
void restore()
Restore saved flags.