Source-highlight Library
srchilite::BufferedOutput Class Reference

The main class for writing into the output. More...

#include <bufferedoutput.h>

Collaboration diagram for srchilite::BufferedOutput:

List of all members.

Public Member Functions

 BufferedOutput (std::ostream &os)
void setAlwaysFlush (bool a=true)
 Whether to flush the output stream at each output operation.
void output (const std::string &s)
 Writes the passed string into the output.
void postLineInsert (const std::string &s)
 Writes the passed string into the contents to be output after the current line.
void postDocInsert (const std::string &s)
 Writes the passed string into the contents to be output after the entire document.
template<typename T >
void postLineInsertFrom (const T &s)
 Writes the elements of the passed generic collection into the contents to be output after the current line.
template<typename T >
void postDocInsertFrom (const T &s)
 Writes the elements of the passed generic collection into the contents to be output after the entire document.
void writePostLine (const std::string &prefix="")
 Writes all the (buffered) elements after the current line (and clear the buffer)
void writePostDoc (const std::string &prefix="")
 Writes all the (buffered) elements after the current document (and clear the buffer)

Private Member Functions

void writePostInfo (PostContents &post, const std::string &prefix="")
 Writes all the (buffered) elements (and clear the buffer)

Private Attributes

std::ostream & outputBuff
 the stream used to output strings
bool alwaysFlush
 whether to flush the output stream at each output operation
PostContents postLineContents
 the contents to be output after each line
PostContents postDocContents
 the contents to be output after the entire document

Detailed Description

The main class for writing into the output.

It wraps an ostream object and can perform buffering. Moreover, it provides functionalities to write something after a line or after an entire document (these contents are buffered so that they can be inserted at any time, with postLineInsert and postDocInsert and will be actually inserted in the output with writePostLine and writePostDoc).


Constructor & Destructor Documentation

Parameters:
osthe ostream where data will be written

Member Function Documentation

void srchilite::BufferedOutput::output ( const std::string &  s)

Writes the passed string into the output.

Parameters:
s
void srchilite::BufferedOutput::postDocInsert ( const std::string &  s)

Writes the passed string into the contents to be output after the entire document.

Parameters:
s
template<typename T >
void srchilite::BufferedOutput::postDocInsertFrom ( const T &  s) [inline]

Writes the elements of the passed generic collection into the contents to be output after the entire document.

Parameters:
s
void srchilite::BufferedOutput::postLineInsert ( const std::string &  s)

Writes the passed string into the contents to be output after the current line.

Parameters:
s
template<typename T >
void srchilite::BufferedOutput::postLineInsertFrom ( const T &  s) [inline]

Writes the elements of the passed generic collection into the contents to be output after the current line.

Parameters:
s
void srchilite::BufferedOutput::setAlwaysFlush ( bool  a = true) [inline]

Whether to flush the output stream at each output operation.

Parameters:
a
void srchilite::BufferedOutput::writePostDoc ( const std::string &  prefix = "")

Writes all the (buffered) elements after the current document (and clear the buffer)

Parameters:
prefixthe string to prefix all the elements
void srchilite::BufferedOutput::writePostInfo ( PostContents post,
const std::string &  prefix = "" 
) [private]

Writes all the (buffered) elements (and clear the buffer)

Parameters:
postthe buffered elements
prefixthe string to prefix all the elements
void srchilite::BufferedOutput::writePostLine ( const std::string &  prefix = "")

Writes all the (buffered) elements after the current line (and clear the buffer)

Parameters:
prefixthe string to prefix all the elements

The documentation for this class was generated from the following files: