Annotation of GNUtools/libg++/libio/indstream.h, revision 1.1.1.1

1.1       root        1: /* This is part of libio/iostream, providing -*- C++ -*- input/output.
                      2: Copyright (C) 1993 Free Software Foundation
                      3: 
                      4: This file is part of the GNU IO Library.  This library is free
                      5: software; you can redistribute it and/or modify it under the
                      6: terms of the GNU General Public License as published by the
                      7: Free Software Foundation; either version 2, or (at your option)
                      8: any later version.
                      9: 
                     10: This library is distributed in the hope that it will be useful,
                     11: but WITHOUT ANY WARRANTY; without even the implied warranty of
                     12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     13: GNU General Public License for more details.
                     14: 
                     15: You should have received a copy of the GNU General Public License
                     16: along with GNU CC; see the file COPYING.  If not, write to
                     17: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
                     18: 
                     19: As a special exception, if you link this library with files
                     20: compiled with a GNU compiler to produce an executable, this does not cause
                     21: the resulting executable to be covered by the GNU General Public License.
                     22: This exception does not however invalidate any other reasons why
                     23: the executable file might be covered by the GNU General Public License.
                     24: 
                     25: Written by Per Bothner ([email protected]). */
                     26: 
                     27: #ifndef _INDSTREAM_H
                     28: #define _INDSTREAM_H
                     29: 
                     30: #ifdef __GNUG__
                     31: #pragma interface
                     32: #pragma cplusplus
                     33: #endif
                     34: 
                     35: #include <iostream.h>
                     36: 
                     37: // An indirectbuf is one that forwards all of its I/O requests
                     38: // to another streambuf.
                     39: // All get-related requests are sent to get_stream().
                     40: // All put-related requests are sent to put_stream().
                     41: 
                     42: // An indirectbuf can be used to implement Common Lisp
                     43: // synonym-streams and two-way-streams.
                     44: //
                     45: // class synonymbuf : public indirectbuf {
                     46: //    Symbol *sym;
                     47: //    synonymbuf(Symbol *s) { sym = s; }
                     48: //    virtual streambuf *lookup_stream(int mode) {
                     49: //        return coerce_to_streambuf(lookup_value(sym)); }
                     50: // };
                     51: 
                     52: class indirectbuf : public streambuf {
                     53:   protected:
                     54:     streambuf *_get_stream;  // Optional cache for get_stream().
                     55:     streambuf *_put_stream;  // Optional cache for put_stream().
                     56:     int _delete_flags;
                     57:   public:
                     58:     streambuf *get_stream()
                     59:        { return _get_stream ? _get_stream : lookup_stream(ios::in); }
                     60:     streambuf *put_stream()
                     61:        { return _put_stream ? _put_stream : lookup_stream(ios::out); }
                     62:     virtual streambuf *lookup_stream(int/*mode*/) { return NULL; } // ERROR!
                     63:     indirectbuf(streambuf *get=NULL, streambuf *put=NULL, int delete_mode=0);
                     64:     virtual ~indirectbuf();
                     65:     virtual int xsputn(const char* s, int n);
                     66:     virtual int xsgetn(char* s, int n);
                     67:     virtual int underflow();
                     68:     virtual int overflow(int c = EOF);
                     69:     virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
                     70:     virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out);
                     71:     virtual int sync();
                     72:     virtual int pbackfail(int c);
                     73: };
                     74: 
                     75: #endif /* !_INDSTREAM_H */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.