CatapultServer  v0.5.0.1 (Elephant)
StreamFormatGuard.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "NonCopyable.h"
23 #include <iomanip>
24 
25 namespace catapult { namespace utils {
26 
29  class StreamFormatGuard : public NonCopyable {
30  public:
32  StreamFormatGuard(std::ostream& out, std::ios_base::fmtflags flags, char fill)
33  : m_out(out)
34  , m_flags(m_out.flags(flags))
35  , m_fill(m_out.fill(fill))
36  {}
37 
40  m_out.flags(m_flags);
41  m_out.fill(m_fill);
42  }
43 
44  private:
45  std::ostream& m_out;
46  std::ios_base::fmtflags m_flags;
47  char m_fill;
48  };
49 }}
catapult::utils::StreamFormatGuard::StreamFormatGuard
StreamFormatGuard(std::ostream &out, std::ios_base::fmtflags flags, char fill)
Creates a guard around out that sets format flags and character fill.
Definition: StreamFormatGuard.h:32
catapult::utils::StreamFormatGuard::~StreamFormatGuard
~StreamFormatGuard()
Destroys the guard and restores original stream formatting settings.
Definition: StreamFormatGuard.h:39
catapult::utils::StreamFormatGuard::m_fill
char m_fill
Definition: StreamFormatGuard.h:47
catapult::utils::StreamFormatGuard::m_flags
std::ios_base::fmtflags m_flags
Definition: StreamFormatGuard.h:46
catapult::utils::StreamFormatGuard
Definition: StreamFormatGuard.h:29
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::utils::StreamFormatGuard::m_out
std::ostream & m_out
Definition: StreamFormatGuard.h:45
catapult::utils::NonCopyable
A class that can neither be copied nor moved.
Definition: NonCopyable.h:26
NonCopyable.h