/* * Copyright (c) 1996 Gunther Schadow. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _SOCKSTREAM_H #define _SOCKSTREAM_H #pragma interface #include #include #include // // IOStream class wrappers // class SockStreamBase : virtual public ios { private: SockBuf *_sb; public: SockStreamBase(const char *address); SockStreamBase(SockBuf *s); SockStreamBase(Socket *); // for accept() SockBuf* rdbuf() const { return (SockBuf*)ios::rdbuf(); } SockBuf* operator -> () const { return (SockBuf*)ios::rdbuf(); } private: // copying is disabled SockStreamBase(const SockStreamBase&); const SockStreamBase& operator = (const SockStreamBase&); }; class SockIStream : public SockStreamBase, public istream { public: SockIStream(const char *address) : SockStreamBase(address) {} SockIStream(SockBuf *s) : SockStreamBase(s) {} private: // copying is disabled SockIStream(const SockIStream&); const SockIStream& operator = (const SockIStream&); }; class SockOStream : public SockStreamBase, public ostream { public: SockOStream(const char *address) : SockStreamBase(address) {} SockOStream(SockBuf *s) : SockStreamBase(s) {} private: // copying is disabled SockOStream(const SockOStream&); const SockOStream& operator = (const SockOStream&); }; class SockIOStream : public SockStreamBase, public iostream { public: SockIOStream(const char *address) : SockStreamBase(address) {} SockIOStream(SockBuf *s) : SockStreamBase(s) {} private: // copying is disabled SockIOStream(const SockIOStream&); const SockIOStream& operator = (const SockIOStream&); }; // // The `endm' and `endt' manipulator: // // actually require SockIStream/SockOStream &arguments // istream& endm(istream& os); // consumes an `end-of-message' token ostream& endm(ostream& os); // emits an `end-of-message' token istream& endt(istream& os); // consumes an `end-of-transmission' token ostream& endt(ostream& os); // emits an `end-of-transmission' token #endif