Public Types | Public Member Functions | Private Types | Private Attributes

claw::net::basic_isocket_stream< CharT, Traits > Class Template Reference

A class to use any socket as a classic standard input stream. More...

#include <isocket_stream.hpp>

List of all members.

Public Types

typedef CharT char_type
typedef Traits traits_type
typedef traits_type::int_type int_type
typedef traits_type::pos_type pos_type
typedef traits_type::off_type off_type
typedef basic_socketbuf
< char_type, traits_type
buffer_type

Public Member Functions

 basic_isocket_stream ()
 Constructor.
 basic_isocket_stream (const std::string &address, int port)
 Constructor.
 ~basic_isocket_stream ()
 Destructor.
buffer_typerdbuf () const
 Get the input buffer.
bool is_open () const
 Tell if the stream is open.
void open (const std::string &address, int port)
 Connect the socket to an address.
void open (int fd)
 Link the socket to a file descriptor.
void close ()
 Close the connection.

Private Types

typedef std::basic_istream
< CharT, Traits > 
super

Private Attributes

buffer_type m_buffer
 The buffer used for input operations.

Detailed Description

template<typename CharT, typename Traits = std::char_traits<CharT>>
class claw::net::basic_isocket_stream< CharT, Traits >

A class to use any socket as a classic standard input stream.

Author:
Julien Jorge

Definition at line 45 of file isocket_stream.hpp.


Member Typedef Documentation

template<typename CharT, typename Traits = std::char_traits<CharT>>
typedef basic_socketbuf<char_type, traits_type> claw::net::basic_isocket_stream< CharT, Traits >::buffer_type

Definition at line 54 of file isocket_stream.hpp.

template<typename CharT, typename Traits = std::char_traits<CharT>>
typedef CharT claw::net::basic_isocket_stream< CharT, Traits >::char_type

Definition at line 48 of file isocket_stream.hpp.

template<typename CharT, typename Traits = std::char_traits<CharT>>
typedef traits_type::int_type claw::net::basic_isocket_stream< CharT, Traits >::int_type

Definition at line 50 of file isocket_stream.hpp.

template<typename CharT, typename Traits = std::char_traits<CharT>>
typedef traits_type::off_type claw::net::basic_isocket_stream< CharT, Traits >::off_type

Definition at line 52 of file isocket_stream.hpp.

template<typename CharT, typename Traits = std::char_traits<CharT>>
typedef traits_type::pos_type claw::net::basic_isocket_stream< CharT, Traits >::pos_type

Definition at line 51 of file isocket_stream.hpp.

template<typename CharT, typename Traits = std::char_traits<CharT>>
typedef std::basic_istream<CharT, Traits> claw::net::basic_isocket_stream< CharT, Traits >::super [private]

Definition at line 57 of file isocket_stream.hpp.

template<typename CharT, typename Traits = std::char_traits<CharT>>
typedef Traits claw::net::basic_isocket_stream< CharT, Traits >::traits_type

Definition at line 49 of file isocket_stream.hpp.


Constructor & Destructor Documentation

template<typename CharT , typename Traits >
claw::net::basic_isocket_stream< CharT, Traits >::basic_isocket_stream (  ) 

Constructor.

Definition at line 36 of file isocket_stream.tpp.

  : super(&m_buffer)
{

} // basic_isocket_stream::basic_isocket_stream()

template<typename CharT , typename Traits >
claw::net::basic_isocket_stream< CharT, Traits >::basic_isocket_stream ( const std::string &  address,
int  port 
)

Constructor.

Parameters:
address The address to which we will connect.
port The port number to use for the connection.

Definition at line 50 of file isocket_stream.tpp.

  : super(&m_buffer)
{
  open(address, port);
} // basic_isocket_stream::basic_isocket_stream()

template<typename CharT , typename Traits >
claw::net::basic_isocket_stream< CharT, Traits >::~basic_isocket_stream (  ) 

Destructor.

Definition at line 61 of file isocket_stream.tpp.

{
  // nothing to do
} // basic_isocket_stream::~basic_isocket_stream()


Member Function Documentation

template<typename CharT , typename Traits >
void claw::net::basic_isocket_stream< CharT, Traits >::close (  ) 

Close the connection.

Definition at line 123 of file isocket_stream.tpp.

References claw::net::basic_socketbuf< CharT, Traits >::close(), and claw::net::basic_isocket_stream< CharT, Traits >::m_buffer.

{
  if ( !m_buffer.close() )
    this->setstate(std::ios_base::failbit);
} // basic_isocket_stream::close()

template<typename CharT , typename Traits >
bool claw::net::basic_isocket_stream< CharT, Traits >::is_open (  )  const

Tell if the stream is open.

Definition at line 82 of file isocket_stream.tpp.

References claw::net::basic_socketbuf< CharT, Traits >::is_open(), and claw::net::basic_isocket_stream< CharT, Traits >::m_buffer.

{
  return m_buffer.is_open();
} // basic_isocket_stream::()

template<typename CharT , typename Traits >
void claw::net::basic_isocket_stream< CharT, Traits >::open ( int  fd  ) 

Link the socket to a file descriptor.

Parameters:
fd The file descriptor.
Remarks:
This method should be only called by claw::net::socket_server.

Definition at line 110 of file isocket_stream.tpp.

References claw::net::basic_isocket_stream< CharT, Traits >::m_buffer, and claw::net::basic_socketbuf< CharT, Traits >::open().

{
  if ( !m_buffer.open(fd) )
    this->setstate(std::ios_base::failbit);
  else
    this->clear();
} // basic_isocket_stream::open()

template<typename CharT , typename Traits >
void claw::net::basic_isocket_stream< CharT, Traits >::open ( const std::string &  address,
int  port 
)

Connect the socket to an address.

Parameters:
address The address to which we will connect.
port The port number to use for the connection.

Definition at line 95 of file isocket_stream.tpp.

{
  if ( !m_buffer.open(address, port) )
    this->setstate(std::ios_base::failbit);
  else
    this->clear();
} // basic_isocket_stream::open()

template<typename CharT , typename Traits >
claw::net::basic_isocket_stream< CharT, Traits >::buffer_type * claw::net::basic_isocket_stream< CharT, Traits >::rdbuf (  )  const

Get the input buffer.

Definition at line 72 of file isocket_stream.tpp.

References claw::net::basic_isocket_stream< CharT, Traits >::m_buffer.

{
  return const_cast<buffer_type*>(&m_buffer);
} // basic_isocket_stream::rdbuf()


Member Data Documentation

template<typename CharT, typename Traits = std::char_traits<CharT>>
buffer_type claw::net::basic_isocket_stream< CharT, Traits >::m_buffer [private]

The documentation for this class was generated from the following files: