libRocket
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Protected Member Functions | List of all members
Rocket::Core::Stream Class Referenceabstract

#include <Stream.h>

Inheritance diagram for Rocket::Core::Stream:
Rocket::Core::ReferenceCountable Rocket::Core::StreamMemory

Public Types

enum  StreamMode {
  MODE_WRITE = 1 << 0, MODE_APPEND = 1 << 1, MODE_READ = 1 << 2, MODE_ASYNC = 1 << 3,
  MODE_MASK = MODE_WRITE | MODE_APPEND | MODE_READ
}
 

Public Member Functions

 Stream ()
 
virtual ~Stream ()
 
virtual void Close ()
 Closes the stream. More...
 
int GetStreamMode () const
 Returns the mode the stream was opened in. More...
 
const URL & GetSourceURL () const
 Obtain the source url of this stream (if available) More...
 
virtual bool IsEOS () const
 Are we at the end of the stream. More...
 
virtual size_t Length () const =0
 Returns the size of this stream (in bytes). More...
 
virtual size_t Tell () const =0
 Returns the position of the stream pointer (in bytes). More...
 
virtual bool Seek (long offset, int origin) const =0
 Sets the stream position (in bytes). More...
 
virtual size_t Read (void *buffer, size_t bytes) const =0
 Read from the stream. More...
 
virtual size_t Read (Stream *stream, size_t bytes) const
 Read from the stream into another stream. More...
 
virtual size_t Read (String &buffer, size_t bytes) const
 Read from the stream and append to the string buffer. More...
 
virtual size_t Peek (void *buffer, size_t bytes) const
 Read from the stream, without increasing the stream offset. More...
 
virtual size_t Write (const void *buffer, size_t bytes)=0
 Write to the stream at the current position. More...
 
virtual size_t Write (const Stream *stream, size_t bytes)
 Write to this stream from another stream. More...
 
virtual size_t Write (const char *string)
 Write a character array to the stream. More...
 
virtual size_t Write (const String &string)
 Write a string to the stream. More...
 
virtual size_t Truncate (size_t bytes)=0
 Truncate the stream to the specified length. More...
 
virtual size_t PushFront (const void *buffer, size_t bytes)
 Push onto the front of the stream. More...
 
virtual size_t PushBack (const void *buffer, size_t bytes)
 Push onto the back of the stream. More...
 
virtual size_t PopFront (size_t bytes)
 Pop from the front of the stream. More...
 
virtual size_t PopBack (size_t bytes)
 Pop from the back of the stream. More...
 
virtual bool IsReadReady ()=0
 
virtual bool IsWriteReady ()=0
 
- Public Member Functions inherited from Rocket::Core::ReferenceCountable
 ReferenceCountable (int initial_count=1)
 
virtual ~ReferenceCountable ()
 Destructor. The reference count must be 0 when this is invoked. More...
 
virtual int GetReferenceCount ()
 Returns the number of references outstanding against this object. More...
 
virtual void AddReference ()
 Increases the reference count. If this pushes the count above 0, OnReferenceActivate() will be called. More...
 
virtual void RemoveReference ()
 Decreases the reference count. If this pushes the count to 0, OnReferenceDeactivate() will be called. More...
 
ReferenceCountable & operator= (const ReferenceCountable &copy)
 Catches incorrect copy attempts. More...
 

Protected Member Functions

void SetStreamDetails (const URL &url, int stream_mode)
 Sets the mode on the stream; should be called by a stream when it is opened. More...
 
virtual void OnReferenceDeactivate ()
 Deletes the stream. More...
 
- Protected Member Functions inherited from Rocket::Core::ReferenceCountable
virtual void OnReferenceActivate ()
 A hook method called when the reference count climbs from 0. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Rocket::Core::ReferenceCountable
static void DumpLeakReport ()
 If any reference countable objects are still allocated, this function will write a leak report to the log. More...
 

Detailed Description

Abstract class for a media-independent byte stream.

Author
Lloyd Weehuizen

Member Enumeration Documentation

Enumerator
MODE_WRITE 
MODE_APPEND 
MODE_READ 
MODE_ASYNC 
MODE_MASK 

Constructor & Destructor Documentation

Rocket::Core::Stream::Stream ( )
virtual Rocket::Core::Stream::~Stream ( )
virtual

Member Function Documentation

virtual void Rocket::Core::Stream::Close ( )
virtual

Closes the stream.

Reimplemented in Rocket::Core::StreamMemory.

const URL& Rocket::Core::Stream::GetSourceURL ( ) const

Obtain the source url of this stream (if available)

int Rocket::Core::Stream::GetStreamMode ( ) const

Returns the mode the stream was opened in.

virtual bool Rocket::Core::Stream::IsEOS ( ) const
virtual

Are we at the end of the stream.

Reimplemented in Rocket::Core::StreamMemory.

virtual bool Rocket::Core::Stream::IsReadReady ( )
pure virtual

Returns true if the stream is ready for reading, false otherwise. This is usually only implemented on streams supporting asynchronous operations.

Implemented in Rocket::Core::StreamMemory.

virtual bool Rocket::Core::Stream::IsWriteReady ( )
pure virtual

Returns true if the stream is ready for writing, false otherwise. This is usually only implemented on streams supporting asynchronous operations.

Implemented in Rocket::Core::StreamMemory.

virtual size_t Rocket::Core::Stream::Length ( ) const
pure virtual

Returns the size of this stream (in bytes).

Implemented in Rocket::Core::StreamMemory.

virtual void Rocket::Core::Stream::OnReferenceDeactivate ( )
protectedvirtual

Deletes the stream.

Reimplemented from Rocket::Core::ReferenceCountable.

virtual size_t Rocket::Core::Stream::Peek ( void *  buffer,
size_t  bytes 
) const
virtual

Read from the stream, without increasing the stream offset.

Reimplemented in Rocket::Core::StreamMemory.

virtual size_t Rocket::Core::Stream::PopBack ( size_t  bytes)
virtual

Pop from the back of the stream.

virtual size_t Rocket::Core::Stream::PopFront ( size_t  bytes)
virtual

Pop from the front of the stream.

Reimplemented in Rocket::Core::StreamMemory.

virtual size_t Rocket::Core::Stream::PushBack ( const void *  buffer,
size_t  bytes 
)
virtual

Push onto the back of the stream.

virtual size_t Rocket::Core::Stream::PushFront ( const void *  buffer,
size_t  bytes 
)
virtual

Push onto the front of the stream.

Reimplemented in Rocket::Core::StreamMemory.

virtual size_t Rocket::Core::Stream::Read ( void *  buffer,
size_t  bytes 
) const
pure virtual

Read from the stream.

Implemented in Rocket::Core::StreamMemory.

virtual size_t Rocket::Core::Stream::Read ( Stream *  stream,
size_t  bytes 
) const
virtual

Read from the stream into another stream.

virtual size_t Rocket::Core::Stream::Read ( String &  buffer,
size_t  bytes 
) const
virtual

Read from the stream and append to the string buffer.

virtual bool Rocket::Core::Stream::Seek ( long  offset,
int  origin 
) const
pure virtual

Sets the stream position (in bytes).

Implemented in Rocket::Core::StreamMemory.

void Rocket::Core::Stream::SetStreamDetails ( const URL &  url,
int  stream_mode 
)
protected

Sets the mode on the stream; should be called by a stream when it is opened.

virtual size_t Rocket::Core::Stream::Tell ( ) const
pure virtual

Returns the position of the stream pointer (in bytes).

Implemented in Rocket::Core::StreamMemory.

virtual size_t Rocket::Core::Stream::Truncate ( size_t  bytes)
pure virtual

Truncate the stream to the specified length.

Implemented in Rocket::Core::StreamMemory.

virtual size_t Rocket::Core::Stream::Write ( const void *  buffer,
size_t  bytes 
)
pure virtual

Write to the stream at the current position.

Implemented in Rocket::Core::StreamMemory.

virtual size_t Rocket::Core::Stream::Write ( const Stream *  stream,
size_t  bytes 
)
virtual

Write to this stream from another stream.

virtual size_t Rocket::Core::Stream::Write ( const char *  string)
virtual

Write a character array to the stream.

virtual size_t Rocket::Core::Stream::Write ( const String &  string)
virtual

Write a string to the stream.


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