The Micro C++ Library
micxx::traits::Reader< CharType, OffType > Class Template Reference

A Reader class defines methods to read from a Stream. More...

#include <micxx/traits/Reader.hxx>

List of all members.

Public Types

typedef CharType char_type
typedef OffType off_type

Public Member Functions

virtual ~Reader ()
 The Reader destructor.
virtual void ignore (off_type size=1, int delim=EOF)=0
 The stream is positioned either size bytes forward or until delim is read (if this occurs before size bytes could be read).
virtual bool read (Buffer &buffer)
 Try to read size bytes into buffer.
virtual off_type read (void *buffer, off_type size)=0
 Read size Reader::char_type into buffer.

Detailed Description

template<typename CharType, typename OffType = std::size_t>
class micxx::traits::Reader< CharType, OffType >

A Reader class defines methods to read from a Stream.

Author:
Norbert Klose
Date:
November, 2011

Member Typedef Documentation

template<typename CharType, typename OffType = std::size_t>
typedef CharType micxx::traits::Reader< CharType, OffType >::char_type

Reimplemented in micxx::File.

template<typename CharType, typename OffType = std::size_t>
typedef OffType micxx::traits::Reader< CharType, OffType >::off_type

Reimplemented in micxx::File.


Constructor & Destructor Documentation

template<typename CharType, typename OffType = std::size_t>
virtual micxx::traits::Reader< CharType, OffType >::~Reader ( ) [inline, virtual]

The Reader destructor.

{}

Member Function Documentation

template<typename CharType, typename OffType = std::size_t>
virtual void micxx::traits::Reader< CharType, OffType >::ignore ( off_type  size = 1,
int  delim = EOF 
) [pure virtual]

The stream is positioned either size bytes forward or until delim is read (if this occurs before size bytes could be read).

Implemented in micxx::File, and micxx::StreamReader.

template<typename CharType, typename OffType = std::size_t>
virtual off_type micxx::traits::Reader< CharType, OffType >::read ( void *  buffer,
off_type  size 
) [pure virtual]

Read size Reader::char_type into buffer.

If buffer is 0, the stream is positioned size bytes forward.

Returns:
The number of bytes read or skipped.

Implemented in micxx::File, and micxx::StreamReader.

template<typename CharType, typename OffType = std::size_t>
virtual bool micxx::traits::Reader< CharType, OffType >::read ( Buffer buffer) [inline, virtual]

Try to read size bytes into buffer.

Returns:
true, if all buffer.getSize() bytes were successfully read,
false, otherwise. The buffer's size is set to the number of actually read bytes in that case.
    {
        __MICXXTRY__
        off_type bytesRead = read(buffer.getAddress(), buffer.getSize());
        if (bytesRead == buffer.getSize())
        {
            return true;
        }
        buffer.setSize(bytesRead);
        return false;
        __MICXXEND__
    }

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