DGD Library
Version: 0.1.0.14 | Updated: Thu Aug 10 16:58: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  

dgChannelBuf.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //
00003 // 
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //
00019 // This file is part of Depression Glass library.
00020 //
00021 // Copyright (c) 2002. Dimitry Kloper <kloper@users.sf.net> . 
00022 //
00023 // dgChannelBuf.h -- streambuf which acts as a channel
00024 //
00025 
00026 #ifndef _dgChannelBuf_h_
00027 #define _dgChannelBuf_h_
00028 
00035 #include <iostream>
00036 #include <list>
00037 #include <string>
00038 
00039 namespace DGD {
00040 
00072 class channelbuf: public std::streambuf {
00073    public:
00074       enum Assoc_type { 
00075          Assoc_Append = 0,
00076          Assoc_Assign,
00077          Assoc_Prepend,
00078       };
00079 
00080       typedef std::streambuf Parent;
00081       typedef std::pair<unsigned,unsigned> position_type;
00082 #if defined(__STDC__) && !defined(_STLPORT)
00083       typedef char char_type;
00084       typedef int  int_type;
00085       class traits_type {
00086          public:
00087             static int_type eof() { return -1; }
00088             static void move( char_type* dst, 
00089                               const char_type* src, 
00090                               const int_type len ) {
00091                memmove( dst, src, len );
00092             }
00093             static const char_type* find( const char_type* src, 
00094                                     const int_type len,
00095                                     const char_type ch ) {
00096                return (const char_type*)memchr( src, ch, len );
00097             }
00098       };
00099 #endif
00100 
00101    protected:
00102       typedef std::list< std::ostream* > Assoc_list;
00103 
00104    protected:
00110       virtual Parent* setbuf(char_type*, std::streamsize);
00111 
00112       virtual int sync();
00113 
00114       virtual int_type overflow(int_type = traits_type::eof());
00117       virtual void propagate( const char_type* begin, 
00118                               const char_type* end );
00119       virtual void propagate( const char_type ch,
00120                               std::streamsize size );
00121 
00122       virtual void post_process();
00123 
00124    public:
00125       enum DefaultValues { 
00126          DefaultBufferSize = 100,
00127          DefaultMaxWidth   = 79,
00128          DefaultMinWidth   = 20,
00129          DefaultIndentStep = 8 
00130       };
00131       
00132    public:
00133       channelbuf();
00134       ~channelbuf();
00135 
00136       void         assoc( std::ostream*, 
00137                           const Assoc_type action = Assoc_Append );
00138       bool         dassoc( std::ostream* );
00139       void         dassoc( );
00140 
00141       unsigned int line() const;
00142       unsigned int column() const;
00143 
00144       void         indent_step( unsigned int step );
00145       unsigned int indent_step() const;
00146       void         incr_indent();
00147       void         decr_indent();
00148       void         indent(const unsigned int);
00149       unsigned int indent() const;
00150       
00151       void         min_width( unsigned int width );
00152       unsigned int min_width() const;
00153       void         max_width( unsigned int width );
00154       unsigned int max_width() const;
00155       
00156       void         wrap( bool allow );
00157       bool         wrap() const;
00158       void         word_wrap( bool allow );
00159       bool         word_wrap() const;
00160       
00161       void         space_chars(const char* spc = " \t");
00162       std::string  space_chars() const;
00163 
00164       position_type position() const;
00165       unsigned long bytes_written() const;
00166 
00167 #if defined(_CYGWIN) && !defined(_STLPORT)
00168       Parent* pubsetbuf(char_type* b, std::streamsize s) {
00169          return setbuf(b, s);
00170       }
00171 #endif
00172 
00173    protected:
00174       char_type* find_one_of( const char_type* s, const unsigned int n,
00175                               const char_type* c_set ) const;
00176       bool is_dos_eol( const char_type* p ) const;
00177 
00178    private:
00179       Assoc_list m_assoc;
00180       unsigned int m_line;
00181       unsigned int m_column;
00182       unsigned int m_indent;
00183       unsigned int m_indent_step;
00184       unsigned int m_min_width;
00185       unsigned int m_max_width;
00186       bool         m_wrap;
00187       bool         m_word_wrap;
00188       const char_type* m_word_pos;
00189       std::string  m_spaces;
00190       unsigned long m_bytes;
00191 };
00192 
00193 };
00194 
00195 #endif /* _dgChannelBuf_h_ */
00196 
00197 /* 
00198  * Local Variables:
00199  * compile-command: "make dgChannelBuf.obj"
00200  * End:
00201  */
00202 
00203 
00204 

Generated on Thu Aug 10 16:48:28 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>