socket_stream.tpp

Go to the documentation of this file.
00001 /*
00002   CLAW - a C++ Library Absolutely Wonderful
00003 
00004   CLAW is a free library without any particular aim but being useful to 
00005   anyone.
00006 
00007   Copyright (C) 2005-2008 Julien Jorge
00008 
00009   This library is free software; you can redistribute it and/or
00010   modify it under the terms of the GNU Lesser General Public
00011   License as published by the Free Software Foundation; either
00012   version 2.1 of the License, or (at your option) any later version.
00013 
00014   This library is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017   Lesser General Public License for more details.
00018 
00019   You should have received a copy of the GNU Lesser General Public
00020   License along with this library; if not, write to the Free Software
00021   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023   contact: julien_jorge@yahoo.fr
00024 */
00031 /*----------------------------------------------------------------------------*/
00035 template<typename CharT, typename Traits>
00036 claw::net::basic_socket_stream<CharT, Traits>::basic_socket_stream()
00037 {
00038   init(&m_buffer);
00039 } // basic_socket_stream::basic_socket_stream()
00040 
00041 /*----------------------------------------------------------------------------*/
00047 template<typename CharT, typename Traits>
00048 claw::net::basic_socket_stream<CharT, Traits>::basic_socket_stream
00049 ( const char* address, int port )
00050 {
00051   init(&m_buffer);
00052   open(address, port);
00053 } // basic_socket_stream::basic_socket_stream()
00054 
00055 /*----------------------------------------------------------------------------*/
00059 template<typename CharT, typename Traits>
00060 claw::net::basic_socket_stream<CharT, Traits>::~basic_socket_stream()
00061 {
00062   // nothing to do
00063 } // basic_socket_stream::~basic_socket_stream()
00064 
00065 /*----------------------------------------------------------------------------*/
00069 template<typename CharT, typename Traits>
00070 typename claw::net::basic_socket_stream<CharT, Traits>::buffer_type*
00071 claw::net::basic_socket_stream<CharT, Traits>::rdbuf() const
00072 {
00073   return const_cast<buffer_type*>(&m_buffer);
00074 } // basic_socket_stream::rdbuf()
00075 
00076 /*----------------------------------------------------------------------------*/
00080 template<typename CharT, typename Traits>
00081 bool claw::net::basic_socket_stream<CharT, Traits>::is_open() const
00082 {
00083   return m_buffer.is_open();
00084 } // basic_socket_stream::()
00085 
00086 /*----------------------------------------------------------------------------*/
00092 template<typename CharT, typename Traits>
00093 void claw::net::basic_socket_stream<CharT, Traits>::open( const char* address,
00094                                                           int port )
00095 {
00096   if ( !m_buffer.open(address, port) )
00097     this->setstate(std::ios_base::failbit);
00098   else
00099     this->clear();
00100 } // basic_socket_stream::open()
00101 
00102 /*----------------------------------------------------------------------------*/
00108 template<typename CharT, typename Traits>
00109 void claw::net::basic_socket_stream<CharT, Traits>::open( int fd )
00110 {
00111   if ( !m_buffer.open(fd) )
00112     this->setstate(std::ios_base::failbit);
00113   else
00114     this->clear();
00115 } // basic_socket_stream::open()
00116 
00117 /*----------------------------------------------------------------------------*/
00121 template<typename CharT, typename Traits>
00122 void claw::net::basic_socket_stream<CharT, Traits>::close()
00123 {
00124   if ( !m_buffer.close() )
00125     this->setstate(std::ios_base::failbit);
00126 } // basic_socket_stream::close()
00127 

Generated on 9 Nov 2009 for CLAW Library (a C++ Library Absolutely Wonderful) by  doxygen 1.6.1