25 #ifndef INCLUDED_IndentingStream_h_GUID_05296193_1397_4991_ACE4_D6FA08655E0B 26 #define INCLUDED_IndentingStream_h_GUID_05296193_1397_4991_ACE4_D6FA08655E0B 32 #include <boost/iostreams/concepts.hpp> 33 #include <boost/iostreams/filtering_stream.hpp> 49 : m_theSpaces(spaces,
' '), m_lastWasNewline(
true) {}
51 static const char NEWLINE =
'\n';
52 static const char CR =
'\r';
53 void setLastWasNewline() { m_lastWasNewline =
true; }
54 template <
typename Sink>
bool put(Sink &snk,
char c) {
56 namespace io = boost::iostreams;
63 m_lastWasNewline =
true;
64 }
else if (m_lastWasNewline) {
66 !io::write(snk, m_theSpaces.data(), m_theSpaces.size());
67 m_lastWasNewline =
false;
69 failure += !io::put(snk, c);
74 std::vector<char> m_theSpaces;
75 bool m_lastWasNewline;
85 : m_filter(spaces), m_os(stream) {
86 push(boost::ref(m_filter));
90 void reset() { m_filter.setLastWasNewline(); }
99 #endif // INCLUDED_IndentingStream_h_GUID_05296193_1397_4991_ACE4_D6FA08655E0B Definition: RunLoopManager.h:42
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
A boost::iostreams::output_filter that inserts the given number of spaces before the first character ...
Definition: IndentingStream.h:46
Definition: newuoa.h:1888
A boost::iostreams::filtering_ostream with a constructor that automatically sets it up to indent the ...
Definition: IndentingStream.h:82
A class that lightly wraps a bool, in order to provide easier maintenance of a "dirty" flag...
Definition: Flag.h:43