The Micro C++ Library
micxx::traits::Stream Class Reference

A Stream is a generic abstract streaming interface to read and/or write data from and/or to. More...

#include <micxx/traits/Stream.hxx>

Inherits micxx::traits::ToString.

Inherited by micxx::File, and micxx::StreamReader.

List of all members.

Public Types

typedef unsigned long long pos_type

Public Member Functions

 Stream ()
 Create a new Stream object.
 Stream (const std::string &name)
 Create a new Stream object with the specified name.
 Stream (const std::wstring &name)
 Create a new Stream object with the specified name.
virtual ~Stream ()
 The Stream destructor.
virtual void close ()=0
 Close this Stream instance.
virtual pos_type tellg () const
 Return the current stream position.
virtual const std::wstringgetName () const
 Return the stream's name.
virtual std::ios_base::openmode getOpenMode () const
 The std::ios_base::openmode in which the stream has been opened.
virtual void open (std::ios_base::openmode mode)=0
 Open the stream in the specified open mode.
virtual void setPosition (pos_type position)
 Set the current stream position to position.
virtual void setName (const std::wstring &name)
 Set the name for this stream to name.
virtual std::string toString () const
 Return a string representation.

Protected Attributes

std::ios_base::openmode openMode
 The std::ios_base::openmode in which the stream has been opened.

Detailed Description

A Stream is a generic abstract streaming interface to read and/or write data from and/or to.

Author:
Norbert Klose
Date:
April, 2007

Member Typedef Documentation

typedef unsigned long long micxx::traits::Stream::pos_type

Constructor & Destructor Documentation

micxx::traits::Stream::Stream ( ) [inline]

Create a new Stream object.

             :
        openMode(std::ios_base::in | std::ios_base::out),
        position(0)
    {
    }
micxx::traits::Stream::Stream ( const std::string &  name) [inline]

Create a new Stream object with the specified name.

                                   :
                openMode(std::ios_base::in | std::ios_base::out),
                name(Strings::convert(name)),
                position(0)
    {
    }
micxx::traits::Stream::Stream ( const std::wstring name) [inline]

Create a new Stream object with the specified name.

                                    :
        openMode(std::ios_base::in | std::ios_base::out),
        name(name),
        position(0)
    {
    }
virtual micxx::traits::Stream::~Stream ( ) [inline, virtual]

The Stream destructor.

    {
    }

Member Function Documentation

virtual void micxx::traits::Stream::close ( ) [pure virtual]

Close this Stream instance.

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

virtual const std::wstring& micxx::traits::Stream::getName ( ) const [inline, virtual]

Return the stream's name.

    {
        return name;
    }
virtual std::ios_base::openmode micxx::traits::Stream::getOpenMode ( ) const [inline, virtual]

The std::ios_base::openmode in which the stream has been opened.

Defaults to ios_base::in | ios_base::out.

    {
        return openMode;
    }
virtual void micxx::traits::Stream::open ( std::ios_base::openmode  mode) [pure virtual]

Open the stream in the specified open mode.

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

virtual void micxx::traits::Stream::setName ( const std::wstring name) [inline, virtual]

Set the name for this stream to name.

Reimplemented in micxx::File.

    {
        this->name = name;
    }
virtual void micxx::traits::Stream::setPosition ( pos_type  position) [inline, virtual]

Set the current stream position to position.

Reimplemented in micxx::File.

    {
        this->position = position;
    }
virtual pos_type micxx::traits::Stream::tellg ( ) const [inline, virtual]

Return the current stream position.

    {
        return position;
    }
virtual std::string micxx::traits::Stream::toString ( ) const [inline, virtual]

Return a string representation.

Reimplemented from micxx::traits::ToString.


Member Data Documentation

std::ios_base::openmode micxx::traits::Stream::openMode [protected]

The std::ios_base::openmode in which the stream has been opened.


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