DGD Library
Version: 0.1.0.14 | Updated: Thu Aug 10 16:57:36 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::channelbuf Class Reference

Simple formatting std::streambuf. More...

#include <dgChannelBuf.h>

Inheritance diagram for DGD::channelbuf:

DGD::funnelbufList of all members.

Public Types

Public Member Functions

  • channelbuf ()
    Default constructor.

  • ~channelbuf ()
    Destructor.

  • void assoc (std::ostream *, const Assoc_type action=Assoc_Append)
    Append the given stream to the association list.

  • bool dassoc (std::ostream *)
    Remove the specified stream from the association list.

  • void dassoc ()
    Clean the association list.

  • unsigned int line () const
    Return current channel line.

  • unsigned int column () const
    Return current channel column.

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

  • unsigned int indent_step () const
    Return indentation step value.

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

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

  • void indent (const unsigned int)
    Change indentation level directly.

  • unsigned int indent () const
    Return indentation level value.

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

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

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

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

  • void wrap (bool allow)
    Set character wrapping.

  • bool wrap () const
    Return character wrapping state.

  • void word_wrap (bool allow)
    Set word wrapping.

  • bool word_wrap () const
    Return word wrapping state.

  • void space_chars (const char *spc="\t")
    Set space character set.

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

  • position_type position () const
    Return current channel line and column.

  • unsigned long bytes_written () const
    Return amount of bytes written to the output stream.

Protected Types

Protected Member Functions

  • virtual void propagate (const char_type *begin, const char_type *end)
    Propagate character string to associated streams.

  • virtual void propagate (const char_type ch, std::streamsize size)
    Propagate given character to associated streams.

  • virtual void post_process ()
    This is a virtual callback.

  • char_type * find_one_of (const char_type *s, const unsigned int n, const char_type *c_set) const
    strchr() equivalent.

  • bool is_dos_eol (const char_type *p) const
  • virtual Parent * setbuf (char_type *, std::streamsize)
    Sets or resets channelbuf internal buffer.

  • virtual int sync ()
    Synchronizes (i.e.

  • virtual int_type overflow (int_type=traits_type::eof())
    Called every time there is no enough space in the internal buffer.

Private Attributes


Detailed Description

Simple formatting std::streambuf.

This is a core class of DGD. Here actual output formatting takes place. Please refer to DGD::channel for general explanation on the channel formatting capabilities. The discussion below is focused on technical aspects of the formatting.

DGD::channelbuf has it's own memory buffer which can be controlled by channelbuf::setbuf(char_type*,std::streamsize) method. All channel input (see DGD::channel for the terminology) formatted by std::ostream operators is put into it. DGD::channelbuf scans the buffer (see channelbuf::overflow(int_type)) and makes the additional formatting.

DGD::channelbuf acts as a stream multiplexor. It maintains a list of DGD::stream objects which are "associated" with this channel buffer (see channelbuf::assoc(std::ostream*)). If the list is empty no output is produced. The channelbuf output is copied to all objects on the list when it is ready.

std::ostream object can be associated with DGD::channelbuf by calling channelbuf::assoc(std::ostream*) method, but it is more appropriate to use DGD::assoc(std::ostream*,channel&) or assoc(std::ostream*,const std::string&) functions.

Since channelbuf usually can't figure out whether its input contains a complete line or only part of it, channelbuf does not flush the entire buffer, but only part of it. To keep track of current state of the output it has m_line and m_column variables which can be queried using channelbuf::position() method.


Member Typedef Documentation

typedef std::streambuf DGD::channelbuf::Parent
 

typedef std::pair<unsigned,unsigned> DGD::channelbuf::position_type
 

typedef std::list< std::ostream* > DGD::channelbuf::Assoc_list [protected]
 


Member Enumeration Documentation

enum DGD::channelbuf::Assoc_type
 

Enumeration values:
Assoc_Append 
Assoc_Assign 
Assoc_Prepend 

enum DGD::channelbuf::DefaultValues
 

Enumeration values:
DefaultBufferSize 
DefaultMaxWidth 
DefaultMinWidth 
DefaultIndentStep 


Constructor & Destructor Documentation

DGD::channelbuf::channelbuf  ) 
 

Default constructor.

DGD::channelbuf::~channelbuf  ) 
 

Destructor.

Note that channelbuf tries to sync itself before being destructed.


Member Function Documentation

channelbuf::Parent * DGD::channelbuf::setbuf char_type * ptr,
std::streamsize size
[protected, virtual]
 

Sets or resets channelbuf internal buffer.

Parameters:
ptr - if NULL causes automatic buffer allocation.
size - if zero DefaultBufferSize is used. Otherwise defines the allocated buffer size.

int DGD::channelbuf::sync  )  [protected, virtual]
 

Synchronizes (i.e.

flushes) the buffer.

Returns:
always 0

channelbuf::int_type DGD::channelbuf::overflow int_type ch = traits_type::eof()  )  [protected, virtual]
 

Called every time there is no enough space in the internal buffer.

This function overrides the same function in std::streambuf.

Once called, this function processes the content of the buffer, makes formatting decisions and then propagates the formatted output to associated streams.

Parameters:
ch - character which failed to be pushed into stream. could be set to char_traits::eof value to indicate empty value.
Returns:
always 0
See also:
DGD::channel

void DGD::channelbuf::propagate const char_type * begin,
const char_type * end
[protected, virtual]
 

Propagate character string to associated streams.

Parameters:
begin - pointer to beginning of propagated string
end - pointer to the end of the propagated string (one character after the end!)

void DGD::channelbuf::propagate const char_type ch,
std::streamsize size
[protected, virtual]
 

Propagate given character to associated streams.

Parameters:
ch - character to propagate
size - number of duplications.

void DGD::channelbuf::post_process  )  [protected, virtual]
 

This is a virtual callback.

This function is called every time overflow() or sync() finished their work, so the channelbuf is in consistent state. Subclasses can overload this function in order to add functionality.

See also:
overflow()

sync()

Reimplemented in DGD::funnelbuf.

void DGD::channelbuf::assoc std::ostream * dgs,
const Assoc_type action = Assoc_Append
 

Append the given stream to the association list.

Parameters:
dgs - pointer to the physical stream.
action - affects the operation performed with the association list. Assoc_Assign will clear the list before appending, Assoc_Append and Assoc_Prepend will put the pointer at the end or at the beginning of the list.
See also:
DGD::channel

bool DGD::channelbuf::dassoc std::ostream * dgs ) 
 

Remove the specified stream from the association list.

If there is a number of same pointers on the list dassoc(std::ostream*) must be called again.

See also:
assoc(std::ostream*)

dassoc()

void DGD::channelbuf::dassoc  ) 
 

Clean the association list.

See also:
assoc(std::ostream*)

dassoc(std::ostream*)

unsigned int DGD::channelbuf::line  )  const
 

Return current channel line.

unsigned int DGD::channelbuf::column  )  const
 

Return current channel column.

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

Change indentation step.

Note:
sync() is called before the value is actually changed. So this operation affects only future input.
See also:
channel::indent_step(unsigned int)

unsigned int DGD::channelbuf::indent_step  )  const
 

Return indentation step value.

See also:
channel::indent_step() const

void DGD::channelbuf::incr_indent  ) 
 

Increment indentation level by value of indentation step.

Note:
sync() is called before the value is actually changed. So this operation affects only future input.
See also:
channel::incr_indent()

void DGD::channelbuf::decr_indent  ) 
 

Decrement indentation level by value of indentation step.

Note:
sync() is called before the value is actually changed. So this operation affects only future input.
See also:
channel::decr::indent()

void DGD::channelbuf::indent const unsigned int val ) 
 

Change indentation level directly.

Note:
sync() is called before the value is actually changed. So this operation affects only future input.
See also:
channel::indent(const unsigned int)

unsigned int DGD::channelbuf::indent  )  const
 

Return indentation level value.

See also:
channel::indent() const

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

Change minimum line width.

Note:
sync() is called before the value is actually changed. So this operation affects only future input.
See also:
channel::min_width(unsigned int)

unsigned int DGD::channelbuf::min_width  )  const
 

Return minimum line width value.

See also:
channel::min_width() const

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

Change maximum line width.

Note:
sync() is called before the value is actually changed. So this operation affects only future input.
See also:
channel::max_width(unsigned int)

unsigned int DGD::channelbuf::max_width  )  const
 

Return maximum line width value.

See also:
channel::max_width() const

void DGD::channelbuf::wrap bool allow ) 
 

Set character wrapping.

Note:
sync() is called before the value is actually changed. So this operation affects only future input.
See also:
channel::wrap(bool)

bool DGD::channelbuf::wrap  )  const
 

Return character wrapping state.

See also:
channel::wrap() const

void DGD::channelbuf::word_wrap bool allow ) 
 

Set word wrapping.

Note:
sync() is called before the value is actually changed. So this operation affects only future input.
See also:
channel::word_wrap(bool)

bool DGD::channelbuf::word_wrap  )  const
 

Return word wrapping state.

See also:
channel::word_wrap() const

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

Set space character set.

Note:
sync() is called before the value is actually changed. So this operation affects only future input.
See also:
channel::space_chars(const char*)

std::string DGD::channelbuf::space_chars  )  const
 

Return space characters set.

See also:
channel::space_chars() const

channelbuf::position_type DGD::channelbuf::position  )  const
 

Return current channel line and column.

unsigned long DGD::channelbuf::bytes_written  )  const
 

Return amount of bytes written to the output stream.

channelbuf::char_type * DGD::channelbuf::find_one_of const char_type * s,
const unsigned int n,
const char_type * c_set
const [protected]
 

strchr() equivalent.

Given string s with length n, finds a first occurrence of any character found in null-terminated string c_set.

bool DGD::channelbuf::is_dos_eol const char_type * p )  const [protected]
 


Member Data Documentation

Assoc_list DGD::channelbuf::m_assoc [private]
 

unsigned int DGD::channelbuf::m_line [private]
 

unsigned int DGD::channelbuf::m_column [private]
 

unsigned int DGD::channelbuf::m_indent [private]
 

unsigned int DGD::channelbuf::m_indent_step [private]
 

unsigned int DGD::channelbuf::m_min_width [private]
 

unsigned int DGD::channelbuf::m_max_width [private]
 

bool DGD::channelbuf::m_wrap [private]
 

bool DGD::channelbuf::m_word_wrap [private]
 

const char_type* DGD::channelbuf::m_word_pos [private]
 

std::string DGD::channelbuf::m_spaces [private]
 

unsigned long DGD::channelbuf::m_bytes [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>