Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
RandomAccessStream Class Referenceabstract

#include <elm/io/RandomAccessStream.h>

+ Inheritance diagram for RandomAccessStream:

Public Types

typedef t::uint64 pos_t
 
typedef t::uint64 size_t
 
typedef int access_t
 

Public Member Functions

virtual pos_t pos (void) const =0
 
virtual size_t size (void) const =0
 
virtual bool moveTo (pos_t pos)=0
 
virtual bool moveForward (pos_t pos)=0
 
virtual bool moveBackward (pos_t pos)=0
 
virtual void resetPos (void)
 
- Public Member Functions inherited from InStream
virtual ~InStream (void)
 
virtual int read (void *buffer, int size)=0
 
virtual int read (void)
 
virtual CString lastErrorMessage (void)
 
- Public Member Functions inherited from OutStream
virtual ~OutStream (void)
 
virtual int write (const char *buffer, int size)=0
 
virtual int write (char byte)
 
virtual int flush (void)=0
 
virtual CString lastErrorMessage (void)
 
virtual bool supportsANSI () const
 

Static Public Member Functions

static RandomAccessStreamopenFile (const sys::Path &path, access_t access=READ)
 
static RandomAccessStreamcreateFile (const sys::Path &path, access_t access=WRITE)
 

Static Public Attributes

static const int READ = 1
 
static const int WRITE = 2
 
static const int READ_WRITE = READ | WRITE
 
- Static Public Attributes inherited from InStream
static const int FAILED = -1
 
static const int ENDED = -2
 
static InStreamnull = _null
 
- Static Public Attributes inherited from OutStream
static OutStreamnull = _null
 

Detailed Description

A stream allowing to move the read/write head along the file.

Member Typedef Documentation

◆ access_t

typedef int access_t

◆ pos_t

typedef t::uint64 pos_t

◆ size_t

typedef t::uint64 size_t

Member Function Documentation

◆ createFile()

RandomAccessStream * createFile ( const sys::Path path,
access_t  access = WRITE 
)
static

Create a random access stream from a file, removing it if it already exists.

Parameters
pathPath of the file to open.
accessType of access (one of READ, WRITE, READ_WRITE).
Returns
Opened file.
Exceptions
IOExceptionThrown if there is an error.

References System::createRandomFile().

◆ moveBackward()

bool moveBackward ( pos_t  pos)
pure virtual

Move the read/write pointer to the given position, relatively back from the current position.

Parameters
posRelative position to move backward from.
Returns
True if the operation succeeded, false else.

◆ moveForward()

bool moveForward ( pos_t  pos)
pure virtual

Move the read/write pointer to the given position, relatively to the current position.

Parameters
posRelative position to move to.
Returns
True if the operation succeeded, false else.

◆ moveTo()

bool moveTo ( pos_t  pos)
pure virtual

size_t RandomAccessStream::size(void) const; Get the size of the current stream.

Returns
Stream size.

Move the read/write pointer to the given position.

Parameters
posPosition to set the pointer to.
Returns
True if the operation succeeded, false else.

Referenced by RandomAccessStream::resetPos().

◆ openFile()

RandomAccessStream * openFile ( const sys::Path path,
access_t  access = READ 
)
static

Open a random access stream from a file.

Parameters
pathPath of the file to open.
accessType of access (one of READ, WRITE, READ_WRITE).
Returns
Opened file.
Exceptions
IOExceptionThrown if there is an error.

References System::openRandomFile().

◆ pos()

pos_t pos ( void  ) const
pure virtual

Get the current position in the file.

Returns
Current position.

◆ resetPos()

void resetPos ( void  )
inlinevirtual

Reset the position of the read/write pointer to the start of the file.

References RandomAccessStream::moveTo().

◆ size()

virtual size_t size ( void  ) const
pure virtual

Member Data Documentation

◆ READ

const int READ = 1
static

◆ READ_WRITE

const int READ_WRITE = READ | WRITE
static

◆ WRITE

const int WRITE = 2
static

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