FDO API Reference Feature Data Objects
Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

FdoIoFileStream Class Reference

#include <FileStream.h>

Inherits FdoIoStream.

Inheritance diagram for FdoIoFileStream:

[legend]
List of all members.

Detailed Description

FdoIoFileStream provides streamed I/O on a disk file.

Definition at line 26 of file FileStream.h.


Public Member Functions

virtual FDO_API_COMMON FdoBoolean CanRead ()
 gets the reading capability.
virtual FDO_API_COMMON FdoBoolean CanWrite ()
 gets the writing capability.
virtual FDO_API_COMMON FdoInt64 GetIndex ()
 gets the current position for the stream.
virtual FDO_API_COMMON FdoInt64 GetLength ()
 gets the current length of the stream.
virtual FDO_API_COMMON FdoBoolean HasContext ()
 returns whether the stream has any positional context. Streams without context can only be read and written in a forward-only manner. These streams do not allow position and length changes.
virtual FDO_API_COMMON FdoSize Read (FdoByte *buffer, FdoSize count)
 reads the number of bytes indicated by count into the given buffer, or the number of bytes after the current stream position, whichever is less. The stream’s current position is moved ahead by the number of bytes read.
virtual FDO_API_COMMON void Reset ()
 sets the position to the start of the stream.
virtual FDO_API_COMMON void SetLength (FdoInt64 length)
 truncates the stream to the indicated length.
virtual FDO_API_COMMON void Skip (FdoInt64 offset)
 skips over part of the stream.
virtual FDO_API_COMMON void Write (FdoIoStream *stream, FdoSize count=0)
 reads the number of bytes from the given stream, and writes them to this stream.
virtual FDO_API_COMMON void Write (FdoByte *buffer, FdoSize count)
 writes the number of bytes indicated by count, from the given buffer, to the stream. The current position is moved ahead by the number of bytes written.

Static Public Member Functions

FDO_API_COMMON FdoIoFileStreamCreate (FILE *fp)
 creates the stream around a C Runtime file stream.
FDO_API_COMMON FdoIoFileStreamCreate (FdoString *fileName, FdoString *accessModes)
 creates the stream for a named file.

Protected Member Functions

void CheckContext (FdoString *caller)
 FdoIoFileStream (FILE *fp)
 FdoIoFileStream (FdoString *fileName, FdoString *accessModes)
 FdoIoFileStream ()
 Default constructor to satisfy Linux.
int GetFd ()
void InitFileStatus ()
 Sets up the canRead and canWrite flags.
virtual ~FdoIoFileStream (void)

Static Protected Attributes

const size_t mBufferSize = 1024
 Buffer size for writing from another stream.

Constructor & Destructor Documentation

FdoIoFileStream::FdoIoFileStream  )  [inline, protected]
 

Default constructor to satisfy Linux.

Definition at line 71 of file FileStream.h.

FdoIoFileStream::FdoIoFileStream FdoString fileName,
FdoString accessModes
[protected]
 

FdoIoFileStream::FdoIoFileStream FILE *  fp  )  [protected]
 

virtual FdoIoFileStream::~FdoIoFileStream void   )  [protected, virtual]
 


Member Function Documentation

virtual FDO_API_COMMON FdoBoolean FdoIoFileStream::CanRead  )  [virtual]
 

gets the reading capability.

Returns:
Returns true if the stream can be read.

Reimplemented from FdoIoStream.

virtual FDO_API_COMMON FdoBoolean FdoIoFileStream::CanWrite  )  [virtual]
 

gets the writing capability.

Returns:
Returns true if the stream can be written to.

Reimplemented from FdoIoStream.

void FdoIoFileStream::CheckContext FdoString caller  )  [protected]
 

Throw exception if this stream has no context. Context is lost when the file size exceeds MAX_LONG.

FDO_API_COMMON FdoIoFileStream* FdoIoFileStream::Create FILE *  fp  )  [static]
 

creates the stream around a C Runtime file stream.

Parameters:
fp Input the file stream pointer.
Returns:
Returns the created file stream.

FDO_API_COMMON FdoIoFileStream* FdoIoFileStream::Create FdoString fileName,
FdoString accessModes
[static]
 

creates the stream for a named file.

Parameters:
fileName Input the file name
accessModes Input File access modes. Same as the fopen() C run-time library function (mode parameter).
Returns:
Returns the created file stream.

int FdoIoFileStream::GetFd  )  [inline, protected]
 

Definition at line 76 of file FileStream.h.

virtual FDO_API_COMMON FdoInt64 FdoIoFileStream::GetIndex  )  [virtual]
 

gets the current position for the stream.

Returns:
Returns the position in bytes from the start. When 0, the the position is at the start of the stream. When GetIndex() == GetLength() the position is at the end of the stream.

Implements FdoIoStream.

virtual FDO_API_COMMON FdoInt64 FdoIoFileStream::GetLength  )  [virtual]
 

gets the current length of the stream.

Returns:
Returns the length in bytes. Returns -1 if the length is unknown or undefined.

Implements FdoIoStream.

virtual FDO_API_COMMON FdoBoolean FdoIoFileStream::HasContext  )  [virtual]
 

returns whether the stream has any positional context. Streams without context can only be read and written in a forward-only manner. These streams do not allow position and length changes.

Returns:
Returns true if the stream has context. Returns false if it does not. When a stream does not have context, the SetLength(), Skip() and Reset() functions are not supported.

Reimplemented from FdoIoStream.

void FdoIoFileStream::InitFileStatus  )  [protected]
 

Sets up the canRead and canWrite flags.

virtual FDO_API_COMMON FdoSize FdoIoFileStream::Read FdoByte buffer,
FdoSize  count
[virtual]
 

reads the number of bytes indicated by count into the given buffer, or the number of bytes after the current stream position, whichever is less. The stream’s current position is moved ahead by the number of bytes read.

Parameters:
buffer Output read into this buffer
count Input read this number of bytes into the buffer. The caller is responsible for allocating a buffer that is large enough to hold the bytes.
Returns:
Returns the number of bytes that were read. 0 if already at the end of the stream.

Implements FdoIoStream.

virtual FDO_API_COMMON void FdoIoFileStream::Reset  )  [virtual]
 

sets the position to the start of the stream.

Implements FdoIoStream.

virtual FDO_API_COMMON void FdoIoFileStream::SetLength FdoInt64  length  )  [virtual]
 

truncates the stream to the indicated length.

Parameters:
length Input the new length (in bytes) for the stream. If this is longer than the current stream length then the stream's length is not changed.

Implements FdoIoStream.

virtual FDO_API_COMMON void FdoIoFileStream::Skip FdoInt64  offset  )  [virtual]
 

skips over part of the stream.

Parameters:
offset The number of bytes to skip. if positive then the current position is moved forward. If negative, the position is moved backward. The position will remain between the start and end of the stream. The position is set to the end of the stream if the given offset would put it past the end. Similarily, the position is set to the start if the offset would put it before the start.

Implements FdoIoStream.

virtual FDO_API_COMMON void FdoIoFileStream::Write FdoIoStream stream,
FdoSize  count = 0
[virtual]
 

reads the number of bytes from the given stream, and writes them to this stream.

Parameters:
stream Input write from this buffer
count Input the maximum number of bytes to read and write. When 0, all remaining bytes are read from the given stream.

Implements FdoIoStream.

virtual FDO_API_COMMON void FdoIoFileStream::Write FdoByte buffer,
FdoSize  count
[virtual]
 

writes the number of bytes indicated by count, from the given buffer, to the stream. The current position is moved ahead by the number of bytes written.

Parameters:
buffer Intput write from this buffer
count Input number of bytes to write
Note:
Write will overwrite some of the contents of the stream if the current position is not at the end of the stream.

Implements FdoIoStream.


Member Data Documentation

const size_t FdoIoFileStream::mBufferSize = 1024 [static, protected]
 

Buffer size for writing from another stream.

Definition at line 89 of file FileStream.h.


The documentation for this class was generated from the following file:
Comments or suggestions? Send us feedback.