isocket_stream.hpp
Go to the documentation of this file.
/*
CLAW - a C++ Library Absolutely Wonderful
CLAW is a free library without any particular aim but being useful to
anyone.
Copyright (C) 2005-2011 Julien Jorge
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
contact: julien.jorge@gamned.org
*/
#ifndef __CLAW_ISOCKET_STREAM_HPP__
#define __CLAW_ISOCKET_STREAM_HPP__
#include <claw/basic_socketbuf.hpp>
#include <istream>
namespace claw
{
namespace net
{
template< typename CharT, typename Traits = std::char_traits<CharT> >
class basic_isocket_stream : public std::basic_istream<CharT, Traits>
{
public:
typedef CharT char_type;
typedef Traits traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
typedef basic_socketbuf<char_type, traits_type> buffer_type;
private:
typedef std::basic_istream<CharT, Traits> super;
public:
basic_isocket_stream();
basic_isocket_stream( const std::string& address, int port );
~basic_isocket_stream();
buffer_type* rdbuf() const;
bool is_open() const;
void open( const std::string& address, int port );
void open( int fd );
void close();
private:
buffer_type m_buffer;
}; // class basic_isocket_stream
typedef basic_isocket_stream<char> isocket_stream;
typedef basic_isocket_stream<wchar_t> wisocket_stream;
} // namespace net
} // namespace claw
#include <claw/impl/isocket_stream.tpp>
#endif // __CLAW_ISOCKET_STREAM_HPP__
basic_socketbuf.hpp
Socket buffer to be used with std::basic_socket_stream, for easy socket reading and writing.
claw::net::basic_isocket_stream
A class to use any socket as a classic standard input stream.
Definition isocket_stream.hpp:46
claw::net::basic_isocket_stream::pos_type
traits_type::pos_type pos_type
The type used to represent a position in the stream.
Definition isocket_stream.hpp:58
claw::net::basic_isocket_stream::int_type
traits_type::int_type int_type
The type used to represent integers.
Definition isocket_stream.hpp:55
claw::net::basic_isocket_stream::off_type
traits_type::off_type off_type
The type used to represent a delta in the positions.
Definition isocket_stream.hpp:61
claw::net::basic_isocket_stream::char_type
CharT char_type
The type of the characters in the stream.
Definition isocket_stream.hpp:49
claw::net::basic_isocket_stream::traits_type
Traits traits_type
The traits carry some informations about the char_type.
Definition isocket_stream.hpp:52
claw::net::basic_isocket_stream::buffer_type
basic_socketbuf< char_type, traits_type > buffer_type
The type of the buffer manipulated by this stream.
Definition isocket_stream.hpp:64
claw::net::basic_socketbuf
Socket buffer to be used with std::basic_stream, for easy socket reading and writing.
Definition basic_socketbuf.hpp:50
claw::net
Network communications.
Definition basic_socket.hpp:40
claw::net::isocket_stream
basic_isocket_stream< char > isocket_stream
Implementation of the basic_isocket_stream for the char type.
Definition isocket_stream.hpp:91
claw::net::wisocket_stream
basic_isocket_stream< wchar_t > wisocket_stream
Implementation of the basic_isocket_stream for the wide characters.
Definition isocket_stream.hpp:95
claw
This is the main namespace.
Definition algorithm.hpp:34