ReFRACtor
ostream_pad.h
Go to the documentation of this file.
1 #ifndef OSTREAM_PAD_H
2 #define OSTREAM_PAD_H
3 #include <boost/iostreams/filtering_stream.hpp>
4 #include <boost/foreach.hpp>
5 
6 namespace FullPhysics {
7 class OstreamPadFilter : public boost::iostreams::output_filter {
8 public:
9  OstreamPadFilter(const std::string& Pad)
10  : pad(Pad), need_pad(true) {}
11  template <typename Sink>
12  bool put(Sink& snk, char c)
13  {
14  if(need_pad) {
15  BOOST_FOREACH(char c2, pad)
16  boost::iostreams::put(snk, c2);
17  }
18  need_pad = (c == '\n');
19  return boost::iostreams::put(snk, c);
20  }
21 private:
22  std::string pad;
23  bool need_pad;
24 };
25 
26 /****************************************************************/
32 class OstreamPad : public boost::iostreams::filtering_ostream {
33 public:
34  OstreamPad(std::ostream& Os, const std::string& Pad)
35  : os(Os), p(Pad) { push(p); push(Os); }
36 private:
37  std::ostream& os;
39 };
40 }
41 #endif
This is a filtering stream that adds a pad to the front of every line written out.
Definition: ostream_pad.h:32
OstreamPadFilter(const std::string &Pad)
Definition: ostream_pad.h:9
OstreamPad(std::ostream &Os, const std::string &Pad)
Definition: ostream_pad.h:34
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
bool put(Sink &snk, char c)
Definition: ostream_pad.h:12

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:11