isocket_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_isocket_stream<CharT, Traits>::basic_isocket_stream()
00037   : super(&m_buffer)
00038 {
00039 
00040 } // basic_isocket_stream::basic_isocket_stream()
00041 
00042 /*----------------------------------------------------------------------------*/
00048 template<typename CharT, typename Traits>
00049 claw::net::basic_isocket_stream<CharT, Traits>::basic_isocket_stream
00050 ( const std::string& address, int port )
00051   : super(&m_buffer)
00052 {
00053   open(address, port);
00054 } // basic_isocket_stream::basic_isocket_stream()
00055 
00056 /*----------------------------------------------------------------------------*/
00060 template<typename CharT, typename Traits>
00061 claw::net::basic_isocket_stream<CharT, Traits>::~basic_isocket_stream()
00062 {
00063   // nothing to do
00064 } // basic_isocket_stream::~basic_isocket_stream()
00065 
00066 /*----------------------------------------------------------------------------*/
00070 template<typename CharT, typename Traits>
00071 typename claw::net::basic_isocket_stream<CharT, Traits>::buffer_type*
00072 claw::net::basic_isocket_stream<CharT, Traits>::rdbuf() const
00073 {
00074   return const_cast<buffer_type*>(&m_buffer);
00075 } // basic_isocket_stream::rdbuf()
00076 
00077 /*----------------------------------------------------------------------------*/
00081 template<typename CharT, typename Traits>
00082 bool claw::net::basic_isocket_stream<CharT, Traits>::is_open() const
00083 {
00084   return m_buffer.is_open();
00085 } // basic_isocket_stream::()
00086 
00087 /*----------------------------------------------------------------------------*/
00093 template<typename CharT, typename Traits>
00094 void claw::net::basic_isocket_stream<CharT, Traits>::open
00095 ( const std::string& address, int port )
00096 {
00097   if ( !m_buffer.open(address, port) )
00098     this->setstate(std::ios_base::failbit);
00099   else
00100     this->clear();
00101 } // basic_isocket_stream::open()
00102 
00103 /*----------------------------------------------------------------------------*/
00109 template<typename CharT, typename Traits>
00110 void claw::net::basic_isocket_stream<CharT, Traits>::open( int fd )
00111 {
00112   if ( !m_buffer.open(fd) )
00113     this->setstate(std::ios_base::failbit);
00114   else
00115     this->clear();
00116 } // basic_isocket_stream::open()
00117 
00118 /*----------------------------------------------------------------------------*/
00122 template<typename CharT, typename Traits>
00123 void claw::net::basic_isocket_stream<CharT, Traits>::close()
00124 {
00125   if ( !m_buffer.close() )
00126     this->setstate(std::ios_base::failbit);
00127 } // basic_isocket_stream::close()
00128 

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