nds2-client - ClientDeveloper  0.16.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
nds_impl::Socket::BufferedReader< Reader > Class Template Reference

#include <buffered_reader.hh>

Collaboration diagram for nds_impl::Socket::BufferedReader< Reader >:
Collaboration graph
[legend]

Public Member Functions

 BufferedReader (Reader &r)
 
void write_all (const char *start, const char *end)
 
char * read_available (char *start, char *end)
 
char * read_exactly (char *start, const char *end)
 
char * peek (char *start, const char *end)
 
template<typename It >
std::vector< char > read_until (It begin_set, It end_set)
 
template<typename It , typename OutIt >
OutIt read_until (It begin_set, It end_set, OutIt dest_start, OutIt dest_end)
 
std::vector< char >::size_type __buffered_bytes () const
 

Private Member Functions

void fill_buffer ()
 
void consume (std::vector< char >::size_type count)
 

Private Attributes

Reader & r_
 
std::vector< char > buf_
 

Constructor & Destructor Documentation

template<typename Reader>
nds_impl::Socket::BufferedReader< Reader >::BufferedReader ( Reader &  r)
inlineexplicit

Member Function Documentation

template<typename Reader>
std::vector< char >::size_type nds_impl::Socket::BufferedReader< Reader >::__buffered_bytes ( ) const
inline

A debugging function

Returns
Return the number of bytes in the current buffer
template<typename Reader>
void nds_impl::Socket::BufferedReader< Reader >::consume ( std::vector< char >::size_type  count)
inlineprivate
template<typename Reader>
void nds_impl::Socket::BufferedReader< Reader >::fill_buffer ( )
inlineprivate
template<typename Reader>
char* nds_impl::Socket::BufferedReader< Reader >::peek ( char *  start,
const char *  end 
)
inline

Return the next data (enough to fill [start, end)). No data will be removed from the internal buffer, only added if needed. The data will still be avaialble in the buffered reader for retreival.

Parameters
startStart of the destination
endByte just past the end of the destination
Returns
end
template<typename Reader>
char* nds_impl::Socket::BufferedReader< Reader >::read_available ( char *  start,
char *  end 
)
inline

A read the data that is currently available. This will only result in a read on the underlying reader if the internal buffer is empty.

Parameters
startStart address of the destination
endAddress of the byte past the last in the destination
Returns
A pointer in [start, end] that is the next location
template<typename Reader>
char* nds_impl::Socket::BufferedReader< Reader >::read_exactly ( char *  start,
const char *  end 
)
inline

Read exactly enough data to fill the range [start,end)

Parameters
startStart of the destination
endByte just past the end of the destination
Returns
end
template<typename Reader>
template<typename It >
std::vector< char > nds_impl::Socket::BufferedReader< Reader >::read_until ( It  begin_set,
It  end_set 
)
inline

Read until a value in [begin_set,end_set) is found in the input stream.

Template Parameters
ItAn iterator that dereferences chars
Parameters
begin_setStart of the list of terminators
end_setEnd of the list of terminators
Returns
A std::vector<char> of the data that was read in, including the terminator that was found.

This will retrieve data from the underlying reader as needed

template<typename Reader>
template<typename It , typename OutIt >
OutIt nds_impl::Socket::BufferedReader< Reader >::read_until ( It  begin_set,
It  end_set,
OutIt  dest_start,
OutIt  dest_end 
)
inline

Read until a value in [begin_set,end_set) is found in the input stream. This will write a bounded amount of data up to [dest_start, dest_end)

Template Parameters
ItAn iterator that dereferences chars
Parameters
begin_setStart of the list of terminators
end_setEnd of the list of terminators
dest_startStart of the destination
dest_endone past the last destination point

This will retrieve data from the underlying reader as needed

template<typename Reader>
void nds_impl::Socket::BufferedReader< Reader >::write_all ( const char *  start,
const char *  end 
)
inline

Write data through to the underlying reader object.

Parameters
startBytes to start at
endAddress just past the last byte to send

Member Data Documentation

template<typename Reader>
std::vector< char > nds_impl::Socket::BufferedReader< Reader >::buf_
private
template<typename Reader>
Reader& nds_impl::Socket::BufferedReader< Reader >::r_
private

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