Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C++ Class Library Definition - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

class streambuf {
public:
        // constructors and destructors
                _Cdecl streambuf();             // make empty streambuf
                _Cdecl streambuf(char*, int);   // make streambuf with given char array
virtual _Cdecl ~streambuf();

        // use the provided char array for the buffer if possible
virtual streambuf* _Cdecl setbuf(  signed char*, int);
        // WARNING:  this function is not virtual; do not override
    streambuf*  _Cdecl setbuf(unsigned char*, int);

        // obsolete, for streams 1.2 compatibility
    streambuf*  _Cdecl setbuf(char*, int, int);

        // getting (extracting) characters
        int     _Cdecl sgetc();         // peek at next char
        int     _Cdecl snextc();        // advance to and return next char
        int     _Cdecl sbumpc();        // return current char and advance
        void    _Cdecl stossc();        // advance to next character
        int     _Cdecl sgetn(char*, int);   // get next n chars
virtual int _Cdecl do_sgetn(char*, int);    // implementation of sgetn
virtual int _Cdecl underflow();     // fill empty buffer
        int     _Cdecl sputbackc(char); // return char to input
virtual int _Cdecl pbackfail(int);  // implementation of sputbackc
        int     _Cdecl in_avail();      // number of avail chars in buffer

        // putting (inserting) characters
        int     _Cdecl sputc(int);          // put one char
        int     _Cdecl sputn(const char*, int); // put n chars from string
virtual int _Cdecl do_sputn(const char* s, int n); // implementation of sputn
virtual int _Cdecl overflow(int = EOF); // flush buffer and make more room
        int     _Cdecl out_waiting();       // number of unflushed chars

        // moving around in stream
virtual streampos _Cdecl seekoff(streamoff, seek_dir,
                                        int = (ios::in | ios::out) );
virtual streampos _Cdecl seekpos(streampos, int = (ios::in | ios::out));
virtual int _Cdecl sync();

        void    _Cdecl dbp();       // for debugging streambuf implementations

protected:
        char*   _Cdecl base();      // return start of buffer area
        char*   _Cdecl ebuf();      // return end+1 of buffer area
        int     _Cdecl blen();      // return length of buffer area
        char*   _Cdecl pbase();     // return start of put area
        char*   _Cdecl pptr();      // return next location in put area
        char*   _Cdecl epptr();     // return end+1 of put area
        char*   _Cdecl eback();     // return base of putback section of get area
        char*   _Cdecl gptr();      // return next location in get area
        char*   _Cdecl egptr();     // return end+1 of get area
        void    _Cdecl setp(char*, char*);      // initialize the put pointers
        void    _Cdecl setg(char*, char*, char*);   // initialize the get pointers
        void    _Cdecl pbump(int);  // advance the put pointer
        void    _Cdecl gbump(int);  // advance the get pointer
        void    _Cdecl setb(char*, char*, int = 0 );    // set the buffer area
        void    _Cdecl unbuffered(int);// set the buffering state
        int     _Cdecl unbuffered();    // non-zero if not buffered
        int     _Cdecl allocate();  // set up a buffer area
virtual int _Cdecl doallocate();    // implementation of allocate



private:
        short   alloc_;     // non-zero if buffer should be deleted
        short   unbuf_;     // non-zero if unbuffered
        char*   base_;      // start of buffer area
        char*   ebuf_;      // end+1 of buffer area
        char*   pbase_;     // start of put area
        char*   pptr_;      // next put location
        char*   epptr_;     // end+1 of put area
        char*   eback_;     // base of putback section of get area
        char*   gptr_;      // next get location
        char*   egptr_;     // end+1 of get area

        int     _Cdecl do_snextc(); // implementation of snextc

        // these declarations prevent copying of a streambuf
                        _Cdecl streambuf(streambuf&);   // declared but not defined
        void    _Cdecl operator= (streambuf&);  // declared but not defined
};
inline char* _Cdecl streambuf::base() { return base_; }
inline char* _Cdecl streambuf::pbase() { return pbase_; }
inline char* _Cdecl streambuf::pptr() { return pptr_; }
inline char* _Cdecl streambuf::epptr() { return epptr_; }
inline char* _Cdecl streambuf::gptr() { return gptr_; }
inline char* _Cdecl streambuf::egptr()  { return egptr_; }
inline char* _Cdecl streambuf::eback()  { return eback_; }
inline char* _Cdecl streambuf::ebuf()   { return ebuf_; }
inline int   _Cdecl streambuf::unbuffered() { return unbuf_; }
inline int   _Cdecl streambuf::blen() { return (int)(ebuf_ - base_);}
inline streambuf* _Cdecl streambuf::setbuf(unsigned char* _p, int _len) {
                        // call the virtual function
            return setbuf((signed char*)_p, _len);
            }
inline void _Cdecl streambuf::pbump(int _n) { pptr_ += _n; }
inline void _Cdecl streambuf::gbump(int _n) { gptr_ += _n; }
inline void _Cdecl streambuf::unbuffered(int _unb) { unbuf_ = (_unb != 0); }
inline int  _Cdecl streambuf::in_avail() {
                return (egptr_ > gptr_) ? (int)(egptr_ - gptr_) : 0;
                }
inline int  _Cdecl streambuf::out_waiting()
                        { return pptr_ ? (int)(pptr_ - pbase_) : 0; }
inline int  _Cdecl streambuf::allocate() {
                return (base_ || unbuf_) ? 0 : doallocate();
                }
inline int  _Cdecl streambuf::sgetc() {
                return (gptr_ >= egptr_) ? underflow() :
                   (unsigned char)(*gptr_);
                }
inline int  _Cdecl streambuf::snextc() {
                return (! gptr_ || (++gptr_ >= egptr_)) ?
                    do_snextc() :
                    (unsigned char)(*gptr_);
                }
inline int  _Cdecl streambuf::sbumpc() {
                return (gptr_ >= egptr_ && underflow() == EOF) ?
                    EOF :
                    (unsigned char)(*gptr_++);
                }
inline void _Cdecl streambuf::stossc() {
                if( gptr_ >= egptr_ ) underflow();
                else ++gptr_;
                }
inline int  _Cdecl streambuf::sputbackc(char _c) {
                return (gptr_ > eback_) ?
                    (unsigned char)(*--gptr_ = _c) :


                    pbackfail(_c);
                }
inline int  _Cdecl streambuf::sputc(int _c) {
                return (pptr_ >= epptr_) ?
                    overflow((unsigned char)_c) :
                    (unsigned char)(*pptr_++ = _c);
                }
#ifdef _BIG_INLINE_
inline int  _Cdecl streambuf::sputn(const char* _s, int _n) {
                if( _n <= (epptr_ - pptr_) ) {
                    memcpy(pptr_, _s, _n);
                    pbump(_n);
                    return _n;
                }
                return do_sputn(_s, _n);
                }
inline int  _Cdecl streambuf::sgetn(char* _s, int _n) {
                if( _n <= (egptr_ - gptr_) ) {
                    memcpy(_s, gptr_, _n);
                    gbump(_n);
                    return _n;
                }
                return do_sgetn(_s, _n);
                }
#endif

See Also: iostream.h (3)

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson