ROSE  0.11.96.11
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
FormatRestorer::~FormatRestorer
~FormatRestorer()
Destructor restores output stream flags.
Definition: FormatRestorer.h:64
FormatRestorer
Restores output stream flags to original values.
Definition: FormatRestorer.h:52
FormatRestorer::restore
void restore()
Restore saved flags.
Definition: FormatRestorer.h:74
FormatRestorer::FormatRestorer
FormatRestorer(std::ostream &o)
Constructor saves output stream flags.
Definition: FormatRestorer.h:59
FormatRestorer::save
void save(std::ostream &o)
Save current output stream flags.
Definition: FormatRestorer.h:69