Sparse Virtual File System  0.4.0
A Sparse Virtual File System.
SaveStreamState.h
Go to the documentation of this file.
1 
32 #ifndef CPPSVF_SAVESTREAMSTATE_H
33 #define CPPSVF_SAVESTREAMSTATE_H
34 
35 #include <iostream>
36 
41 {
42 public:
44  explicit SaveStreamState (std::ios& stream)
45  : m_stream_ref (stream),
46  m_stream_flags (stream.flags()),
47  m_stream_precision (stream.precision()),
48  m_stream_fill (stream.fill())
49  {
50  // FIX: 2002-08-30 When the stream state is saved
51  // it also clears any prior flags such as 'fixed' etc.
52  // Uses the default ctor for std::ios_base::fmtflags
53  stream.flags(std::ios_base::fmtflags());
54  }
56  virtual ~SaveStreamState() {
57  try {
58  if (m_stream_ref) {
62  }
63  }
64  catch (...) {}
65  }
66 protected:
67  // Protected members
68  std::ios& m_stream_ref;
69  std::ios_base::fmtflags m_stream_flags;
70  std::streamsize m_stream_precision;
72 private:
73 };
74 
75 #endif //CPPSVF_SAVESTREAMSTATE_H
Class that saves the current iostream state and restores it on destruction.
std::streamsize m_stream_precision
SaveStreamState(std::ios &stream)
std::ios & m_stream_ref
virtual ~SaveStreamState()
std::ios_base::fmtflags m_stream_flags