CARMA C++
LineBuffer.h
Go to the documentation of this file.
1 
14 #ifndef CARMA_SDP_LINEBUFFER_H
15 #define CARMA_SDP_LINEBUFFER_H
16 
17 #include <boost/shared_ptr.hpp>
18 
19 // C++ standard library includes
20 #include <iostream>
21 #include <sstream>
22 
23 // Class definitions
24 namespace carma {
25 namespace sdp {
26 
33 class LineBuffer {
34 public:
35 
42  LineBuffer(const std::string &filename, std::ios_base::openmode mode = std::ios_base::out | std::ios_base::app);
43  LineBuffer(std::streambuf *sb);
44 
48  ~LineBuffer();
49 
53  LineBuffer& operator<<(const std::string &);
54 
58  void setLineIndent(unsigned int indent) {
59  indent_ = indent;
60  };
61 
66  void flush(bool addnewline=true);
67 
68 private:
69 
70  void checkForFull(int extra=0);
71  void indent();
72 
73  boost::shared_ptr<std::iostream> stream_;
74  std::ostringstream linebuf_;
75  unsigned int indent_;
76  const int bs_;
77 };
78 
79 } // namespace carma::sdp
80 } // namespace carma
81 
82 #endif
LineBuffer & operator<<(const std::string &)
Write string data to a line buffer.
~LineBuffer()
Destructor.
void flush(bool addnewline=true)
flush buffer
LineBuffer(const std::string &filename, std::ios_base::openmode mode=std::ios_base::out|std::ios_base::app)
Constructor.
void setLineIndent(unsigned int indent)
of field separators to be written after a newline.
Definition: LineBuffer.h:58
A line buffer class for use in XML output of astro hdr data elements.
Definition: LineBuffer.h:33