Loading...
Searching...
No Matches
ledger::output_stream_t Class Reference

An output stream. More...

#include <stream.h>

Public Member Functions

void close ()
 Close the output stream, waiting on the pager process if necessary.
 
void flush ()
 Flushing function.
 
void initialize (const optional< path > &output_file=none, const optional< path > &pager_path=none)
 Initialize the output stream object.
 
 operator std::ostream & ()
 Converter to a standard ostream.
 
 output_stream_t ()
 Construct a new output_stream_t.
 
 output_stream_t (const output_stream_t &)
 When copy-constructed, make the copy just be a new output stream.
 
 ~output_stream_t ()
 Destroys an output_stream_t.
 

Public Attributes

std::ostream * os
 A pointer to the ostream.
 

Detailed Description

An output stream.

A stream to output in Ledger may be going to one of three places: to stdout, to a file, or to a pager. Construct an output_stream_t and the stream will automatically be cleaned up upon destruction.

This class suffers from "else-if-heimer's disease," see Marshall Cline's "C++ FAQ Lite". Arguably this should be three different classes, but that introduces additional unneeded complications.

Definition at line 65 of file stream.h.

Constructor & Destructor Documentation

◆ output_stream_t() [1/2]

ledger::output_stream_t::output_stream_t ( )
inline

Construct a new output_stream_t.

Definition at line 82 of file stream.h.

References TRACE_CTOR.

◆ output_stream_t() [2/2]

ledger::output_stream_t::output_stream_t ( const output_stream_t & )
inline

When copy-constructed, make the copy just be a new output stream.

This allows large classes to rely on their default copy-constructor without worrying about pointer copying within output_stream_t.

Definition at line 91 of file stream.h.

References TRACE_CTOR.

◆ ~output_stream_t()

ledger::output_stream_t::~output_stream_t ( )
inline

Destroys an output_stream_t.

This deletes the dynamically allocated ostream, if necessary. It also closes output file descriptor, if necessary.

Definition at line 101 of file stream.h.

References close(), and TRACE_DTOR.

+ Here is the call graph for this function:

Member Function Documentation

◆ close()

void ledger::output_stream_t::close ( )

Close the output stream, waiting on the pager process if necessary.

Referenced by ledger::report_t::quick_close(), ~output_stream_t(), and ledger::report_t::~report_t().

+ Here is the caller graph for this function:

◆ flush()

void ledger::output_stream_t::flush ( )
inline

Flushing function.

A simple proxy for ostream's flush.

Definition at line 129 of file stream.h.

References os.

◆ initialize()

void ledger::output_stream_t::initialize ( const optional< path > & output_file = none,
const optional< path > & pager_path = none )

Initialize the output stream object.

Parameters
output_fileFile to which to send output. If both this and pager are set, output_file takes priority.
pager_pathPath to a pager. To not use a pager, leave this empty.

◆ operator std::ostream &()

ledger::output_stream_t::operator std::ostream & ( )
inline

Converter to a standard ostream.

This is used so that we can stream directly to an object of type output_stream_t.

Definition at line 122 of file stream.h.

References os.

Member Data Documentation

◆ os

std::ostream* ledger::output_stream_t::os

A pointer to the ostream.

Don't delete this; the output_stream_t class takes care of this.

Definition at line 77 of file stream.h.

Referenced by flush(), and operator std::ostream &().


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