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