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
14namespace srchilite {
15
17typedef std::set<std::string> PostContents;
18
30 std::ostream &outputBuff;
31
34
37
40
46 void writePostInfo(PostContents &post, const std::string &prefix = "");
47
48public:
52 BufferedOutput(std::ostream &os);
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_*/
The main class for writing into the output.
Definition: bufferedoutput.h:28
bool alwaysFlush
whether to flush the output stream at each output operation
Definition: bufferedoutput.h:33
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
std::ostream & outputBuff
the stream used to output strings
Definition: bufferedoutput.h:30
void postDocInsert(const std::string &s)
Writes the passed string into the contents to be output after the entire document.
Definition: bufferedoutput.cpp:36
void writePostDoc(const std::string &prefix="")
Writes all the (buffered) elements after the current document (and clear the buffer)
Definition: bufferedoutput.cpp:54
void postLineInsert(const std::string &s)
Writes the passed string into the contents to be output after the current line.
Definition: bufferedoutput.cpp:31
void writePostInfo(PostContents &post, const std::string &prefix="")
Writes all the (buffered) elements (and clear the buffer)
Definition: bufferedoutput.cpp:41
PostContents postLineContents
the contents to be output after each line
Definition: bufferedoutput.h:36
void setAlwaysFlush(bool a=true)
Whether to flush the output stream at each output operation.
Definition: bufferedoutput.h:59
void output(const std::string &s)
Writes the passed string into the output.
Definition: bufferedoutput.cpp:24
void writePostLine(const std::string &prefix="")
Writes all the (buffered) elements after the current line (and clear the buffer)
Definition: bufferedoutput.cpp:50
BufferedOutput(std::ostream &os)
Definition: bufferedoutput.cpp:17
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
PostContents postDocContents
the contents to be output after the entire document
Definition: bufferedoutput.h:39
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
std::set< std::string > PostContents
the contents to be put after a line or after the document
Definition: bufferedoutput.h:17