Source-highlight Library
linebuffer.h
1 //
2 // Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2005
3 //
4 // Copyright: See COPYING file that comes with this distribution
5 //
6 //
7 #ifndef LINEBUFFER_H
8 #define LINEBUFFER_H
9 
10 #include <string>
11 #include <set>
12 #include <boost/shared_ptr.hpp>
13 
14 #include <sstream>
15 
16 namespace srchilite {
17 
21 class LineBuffer {
22 public:
24  typedef std::set<std::string> PostContents;
25 
26 private:
27  ostringstream buffer;
28  PostContents post;
29 
30 public:
31  LineBuffer() {
32  }
33  ~LineBuffer() {
34  }
35 
39  void output(const std::string &s) {
40  buffer << s;
41  }
42 
46  void output_post(const std::string &s) {
47  post.insert(s);
48  }
49 
53  const std::string getContents() const {
54  return buffer.str();
55  }
56 
60  const PostContents &getPostContents() const {
61  return post;
62  }
63 
67  bool empty() const {
68  return (buffer.str().size() == 0 && post.size() == 0);
69  }
70 };
71 
73 typedef boost::shared_ptr<LineBuffer> LineBufferPtr;
74 
75 }
76 
77 #endif
A buffer for a line to be generated.
Definition: linebuffer.h:21
const PostContents & getPostContents() const
Definition: linebuffer.h:60
ostringstream buffer
the line contents
Definition: linebuffer.h:27
void output_post(const std::string &s)
Stores something to be generated after the line.
Definition: linebuffer.h:46
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
std::set< std::string > PostContents
Stores contents to be printed after the line.
Definition: linebuffer.h:24
boost::shared_ptr< LineBuffer > LineBufferPtr
shared pointer for LineBuffer
Definition: linebuffer.h:73
bool empty() const
Definition: linebuffer.h:67
void output(const std::string &s)
Puts something in the buffer.
Definition: linebuffer.h:39
const std::string getContents() const
Definition: linebuffer.h:53
PostContents post
to be generated after the line
Definition: linebuffer.h:28