Source-highlight Library: /home/bettini/work/source-highlight/src-highlite/lib/srchilite/bufferedoutput.h Source File

Source-highlight Library
bufferedoutput.h
1 //
2 // Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2004-2008
3 //
4 // Copyright: See COPYING file that comes with this distribution
5 //
6 
7 #ifndef BUFFEREDOUTPUT_H_
8 #define BUFFEREDOUTPUT_H_
9 
10 #include <ostream>
11 #include <string>
12 #include <set>
13 
14 namespace srchilite {
15 
17  typedef std::set<std::string> PostContents;
18 
28  class BufferedOutput {
30   std::ostream &outputBuff;
31 
33   bool alwaysFlush;
34 
36   PostContents postLineContents;
37 
39   PostContents postDocContents;
40 
46  void writePostInfo(PostContents &post, const std::string &prefix = "");
47 
48 public:
52  BufferedOutput(std::ostream &os);
53  ~BufferedOutput();
54 
59   void setAlwaysFlush(bool a = true) {
60  alwaysFlush = a;
61  }
62 
67  void output(const std::string &s);
68 
73  void postLineInsert(const std::string &s);
74 
79  void postDocInsert(const std::string &s);
80 
86   template<typename T> void postLineInsertFrom(const T &s) {
87  for (typename T::const_iterator it = s.begin(); it != s.end(); ++it)
88  postLineInsert(*it);
89  }
90 
96   template<typename T> void postDocInsertFrom(const T &s) {
97  for (typename T::const_iterator it = s.begin(); it != s.end(); ++it)
98  postDocInsert(*it);
99  }
100 
105  void writePostLine(const std::string &prefix = "");
106 
111  void writePostDoc(const std::string &prefix = "");
112 
113 };
114 
115 }
116 
117 #endif /*BUFFEREDOUTPUT_H_*/
void setAlwaysFlush(bool a=true)
Whether to flush the output stream at each output operation.
Definition: bufferedoutput.h:59
void writePostDoc(const std::string &prefix="")
Writes all the (buffered) elements after the current document (and clear the buffer) ...
Definition: bufferedoutput.cpp:54
void postLineInsertFrom(const T &s)
Writes the elements of the passed generic collection into the contents to be output after the current...
Definition: bufferedoutput.h:86
void writePostLine(const std::string &prefix="")
Writes all the (buffered) elements after the current line (and clear the buffer)
Definition: bufferedoutput.cpp:50
std::set< std::string > PostContents
the contents to be put after a line or after the document
Definition: bufferedoutput.h:17
void postDocInsertFrom(const T &s)
Writes the elements of the passed generic collection into the contents to be output after the entire ...
Definition: bufferedoutput.h:96
void output(const std::string &s)
Writes the passed string into the output.
Definition: bufferedoutput.cpp:24
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
PostContents postLineContents
the contents to be output after each line
Definition: bufferedoutput.h:36
BufferedOutput(std::ostream &os)
Definition: bufferedoutput.cpp:17
bool alwaysFlush
whether to flush the output stream at each output operation
Definition: bufferedoutput.h:33
void postLineInsert(const std::string &s)
Writes the passed string into the contents to be output after the current line.
Definition: bufferedoutput.cpp:31
The main class for writing into the output.
Definition: bufferedoutput.h:28
void postDocInsert(const std::string &s)
Writes the passed string into the contents to be output after the entire document.
Definition: bufferedoutput.cpp:36
PostContents postDocContents
the contents to be output after the entire document
Definition: bufferedoutput.h:39
void writePostInfo(PostContents &post, const std::string &prefix="")
Writes all the (buffered) elements (and clear the buffer)
Definition: bufferedoutput.cpp:41
std::ostream & outputBuff
the stream used to output strings
Definition: bufferedoutput.h:30

AltStyle によって変換されたページ (->オリジナル) /