DGD Library
Version: 0.1.0.14 | Updated: Thu Aug 10 16:57:26 2006
Home
DGD News
FAQ
Code Documentation
DGD Installation Guide
Bugs-n-Features
DGD at Sourceforge.net
Download DGD
Subversion
Code Documentation
Documentation
Namespaces
Class Hierarchy
Class List
File List
Namespace Members
Functions
Globals
Tutorial
Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

DGD::channel Class Reference

Simple debug channel. More...

#include <dgChannel.h>

List of all members.

Public Types

Public Member Functions

  • channel (const std::string &name)
    channel constructor.

  • void open ()
    Open and effectively initialize the channel.

  • void close ()
    Close and effectively disable the channel.

  • bool is_open () const
    Return channel open/close status.

  • operator bool () const
    Return channel open/close status.

  • const std::string & name () const
    Return channel name.

  • channelbuf * rdbuf () const
    Return pointer to channel buffer.

  • channelbuf & rdbuf ()
    Return the channel buffer.

  • void indent_step (unsigned int step)
    Change indentation step.

  • unsigned int indent_step () const
    Return indentation step.

  • void incr_indent ()
    Increment indentation level by indentation step.

  • void decr_indent ()
    Decrement indentation level by indentation step.

  • void indent (unsigned int val)
    Change indentation level.

  • unsigned int indent () const
    Return indentation level.

  • void min_width (unsigned int width)
    Change minimum line width.

  • unsigned int min_width () const
    Return minimum line width.

  • void max_width (unsigned int width)
    Change maximum line width.

  • unsigned int max_width () const
    Return maximum line width.

  • void wrap (bool allow)
    Disable or enable character wrapping.

  • bool wrap () const
    Return character wrapping flag.

  • void word_wrap (bool allow)
    Disable or enable word wrapping.

  • bool word_wrap () const
    Return character wrapping flag.

  • void space_chars (const char *spc="\t")
    Change space characters.

  • std::string space_chars () const
    Return space characters.

  • virtual void header ()
    Dump header information into the channel.

Private Attributes


Detailed Description

Simple debug channel.

This class is a std::ostream with extended functionality. Terminology:

  • Stream input -- a set of characters pushed into the stream for later output.
  • Line -- a set of characters on a single line of output, or alternatively, set of characters between two '\n' or ''.
  • Line width -- the length of the line excluding '\n' or ''.

DGD::channel treats the input as sequence of lines. Similarly to std::ostream it has a set of format flags and other parameters defining how the sequence is formatted. The following formatting options are available:

  • Character wrap. Controlled by void channel::wrap(bool) method. State is received by bool channel::wrap() const method.

    DGD::channel can have character wrapping enabled or disabled. When disabled, DGD::channel discards maximum line width, allowing virtually infinite lines.

    If the character wrapping is enabled DGD::channel tracks maximum line width. Line longer then maximum width (indentation spaces at the beginning of line are considered as part of the line!) is broken into two lines. The first one has at most maximum width. See word wrapping section for more info. The second one is processed in a recursive manner.

  • Maximum line width. Controlled by void channel::max_width(unsigned int). State is received by unsigned int channel::max_width() const method.

    Usually it is good idea to limit the log width. For example log with 79 characters width limit can be nicely viewed in standard 80x24 terminal, default emacs window, etc..., without need for window resizing.

  • Minimum line width. Controlled by void channel::min_width(unsigned int). State is received by unsigned int channel::min_width() const method.

    This parameter controls maximum indent level. Maximum indent column is calculated as minimum between current indent value and maximum line width minus minimum line width. This is true even if character wrapping is disabled.

  • Word wrap. Controlled by void channel::word_wrap(bool) method. State is received by bool channel::word_wrap() const method.

    Word wrapping takes place only if character wrapping is enabled.

    If word wrapping is disabled the line longer then maximum width will be broken in two and the first line of the pair will have exactly maximum width. Otherwise word wrapping takes place. If the line can't be broken into words the character wrapping is performed (if enabled ). The word wrapping is controlled also by space characters set, see void channel::space_chars(const char*) method.

  • Indentation level, indentation step. Controlled by State is received by:

    Indentation level determines amount of leading spaces for each line of output. This amount is considered as part of the line width.

    Indentation level can be set directly by indent(unsigned int) method, or by incrementing/decrementing using incr_indent() and decr_indent() methods. In the later case it is changed by indent step value.

Each channel has string name. Generally it need not be unique, but DGD::Debug factory accepts only unique names for channels.

By default the channel is created in closed state. Closed channel will produce no output. Use open() and close() methods to open channel.

By default channel acts as a simple memory buffer. To make the channel act as a multiplexor for any number of std::ostream you will need to call assoc(std::ostream* ,channel&) function. In other words you can associate the channel with any number of files or other std::ostream derivatives. The output from the channel will be copied to all the associated files.


Member Typedef Documentation

typedef std::ostream DGD::channel::Parent
 


Constructor & Destructor Documentation

DGD::channel::channel const std::string & name ) 
 

channel constructor.

This one solves the chicken and egg problem of stream and streambuf construction. It calls std::ostream::init() with NULL pointer, effectively disabling the channel. Use open() method to enable it.


Member Function Documentation

void DGD::channel::open  ) 
 

Open and effectively initialize the channel.

This method calls std::ostream::init() with pointer to m_buffer. Note that m_buffer is not affected by close(), this enables multiple close() and open() operations on the channel.

void DGD::channel::close  ) 
 

Close and effectively disable the channel.

bool DGD::channel::is_open  )  const
 

Return channel open/close status.

DGD::channel::operator bool  )  const
 

Return channel open/close status.

This operator is used for

 if( channel ) { .... }
expressions.

const std::string & DGD::channel::name  )  const
 

Return channel name.

channelbuf * DGD::channel::rdbuf  )  const
 

Return pointer to channel buffer.

See DGD::channelbuf for more info. This method is const so preventing non-const methods on the channel buffer. Use channel::rdbuf() for changing channel buffer directly.

channelbuf & DGD::channel::rdbuf  ) 
 

Return the channel buffer.

This method allows direct access to the channel buffer. See DGD::channelbuf for more info.

Note:
This method must be used carefully since direct access to the channel buffer can cause unexpected results.

void DGD::channel::indent_step unsigned int step ) 
 

Change indentation step.

Note:
This method does not affect the indentation level itself.
See also:
channelbuf::indent_step(unsigned int)

unsigned int DGD::channel::indent_step  )  const
 

Return indentation step.

See also:
channelbuf::indent_step() const

void DGD::channel::incr_indent  ) 
 

Increment indentation level by indentation step.

See also:
channelbuf::incr_indent()

void DGD::channel::decr_indent  ) 
 

Decrement indentation level by indentation step.

See also:
channelbuf::decr_indent()

void DGD::channel::indent unsigned int val ) 
 

Change indentation level.

Note:
The parameter need not to be multiple of the indentation level.
See also:
channelbuf::indent(unsigned int)

unsigned int DGD::channel::indent  )  const
 

Return indentation level.

See also:
channelbuf::indent() const

void DGD::channel::min_width unsigned int width ) 
 

Change minimum line width.

The effective indentation level is determined as

 * elevel = min( indentation level, max_width()-min_width() );
 * 
See also:
channelbuf::min_width(unsigned int)

unsigned int DGD::channel::min_width  )  const
 

Return minimum line width.

See also:
channelbuf::min_width() const

void DGD::channel::max_width unsigned int width ) 
 

Change maximum line width.

See also:
channelbuf::max_width(unsigned int)

unsigned int DGD::channel::max_width  )  const
 

Return maximum line width.

See also:
channelbuf::max_width() const

void DGD::channel::wrap bool allow ) 
 

Disable or enable character wrapping.

See also:
channelbuf::wrap(bool)

bool DGD::channel::wrap  )  const
 

Return character wrapping flag.

See also:
channelbuf::wrap() const

void DGD::channel::word_wrap bool allow ) 
 

Disable or enable word wrapping.

See also:
channelbuf::word_wrap(bool)

bool DGD::channel::word_wrap  )  const
 

Return character wrapping flag.

See also:
channelbuf::word_wrap() const

void DGD::channel::space_chars const char * spc = " \t"  ) 
 

Change space characters.

This method accepts a null-terminated character string. Each character in the string will be considering like a space between words during word wrapping.

See also:
channelbuf::space_chars(const char*)

std::string DGD::channel::space_chars  )  const
 

Return space characters.

See also:
channelbuf::space_chars() const

void DGD::channel::header  )  [virtual]
 

Dump header information into the channel.

Normally this method is invoked by assoc(), but it can be called in any other places.


Member Data Documentation

bool DGD::channel::m_is_open [private]
 

std::string DGD::channel::m_name [private]
 

channelbuf DGD::channel::m_buffer [private]
 

channelbuf DGD::channel::m_tmp_buffer [private]
 


The documentation for this class was generated from the following files:
Generated on Thu Aug 10 16:48:30 2006 for DGD Library by doxygen1.3

SourceForge.net Logo Powered by Mason Powered by Perl
Web design derived from Pasilda design found on www.oswd.org.
Copyright (c) 2002, 2003. Dimitry Kloper <kloper@users.sourceforge.net>