BioInt  1.02.00
BioInt: An integrative biological object-oriented application framework and interpreter
BioSocketStream.h
Go to the documentation of this file.
00001 #ifndef BIOSOCKETSTREAM_H
00002 #define BIOSOCKETSTREAM_H
00003 
00004 #include "BioSocketBuffer.h"
00005 #include <iosfwd>
00006 
00007 template <typename _CharT, typename _Traits = std::char_traits<_CharT> >
00008 class BioBasicSocketStream : public std::basic_iostream<_CharT, _Traits>
00009 {
00010 public:
00011         // Types:
00012         typedef _CharT                                  char_type;
00013         typedef _Traits                                 traits_type;
00014 
00015         typedef typename traits_type::int_type          int_type;
00016         typedef typename traits_type::pos_type          pos_type;
00017         typedef typename traits_type::off_type          off_type;
00018 
00019 private:
00020         // Non-standard Types:
00021         typedef BioBasicSocketBuffer<_CharT, _Traits>          __sockbuf_type;
00022         typedef std::basic_iostream<char_type, traits_type>  __iostream_type;
00023         
00024         __sockbuf_type  _M_sockbuf;
00025 
00026 public:
00027         BioBasicSocketStream()
00028         {
00029                 this->init(&_M_sockbuf);
00030         }
00031 
00032 
00033         explicit
00034         BioBasicSocketStream(const BioSocket& sock_)
00035         : _M_sockbuf(sock_)
00036         {
00037                 this->init(&_M_sockbuf);
00038         }
00039 
00045         explicit
00046         BioBasicSocketStream(const BioSocketAddressIn sin_)
00047         : _M_sockbuf(sin_)
00048         {
00049                 this->init(&_M_sockbuf);
00050         }
00051         
00052         virtual ~BioBasicSocketStream()
00053         { }
00054 
00056         bool is_connected() const throw() { return _M_sockbuf.is_connected(); }
00057         
00059         bool
00060         connect(const BioSocketAddressIn& sin_)
00061         {
00062                 return _M_sockbuf.connect(sin_);
00063         }
00064         
00066         bool
00067         connect(const std::string& addr_, uint16_t port_)
00068         {
00069                 return _M_sockbuf.connect(addr_, port_);
00070         }
00071         
00073         bool
00074         close()
00075         {
00076                 return _M_sockbuf.close();
00077         }
00078 };
00079 
00080 typedef BioBasicSocketStream<char> BioSocketStream;
00081 
00082 std::ostream& crlf(std::ostream& o_);
00083 /*
00084 {
00085         o_.put(o_.widen('\x00d'));
00086         o_.put(o_.widen('\x00a'));
00087         o_.flush();
00088         return o_;
00089 }
00090 */
00091 std::ostream& lfcr(std::ostream& o_);
00092 /*{
00093         o_.put(o_.widen('\x00a'));
00094         o_.put(o_.widen('\x00d'));
00095         o_.flush();
00096         return o_;
00097 }
00098 */
00099 
00100 #endif
00101 
00102 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines