MrSID Decode SDK for Raster Reference Manual  9.5.4.4709
LTIOCallbackStream Class Reference

Stream driven entirely by user-defined callbacks. More...

#include <lt_ioCallbackStream.h>

Inheritance diagram for LTIOCallbackStream:
LTIOStreamInf

List of all members.

Public Member Functions

 LTIOCallbackStream ()
virtual ~LTIOCallbackStream ()
virtual LT_STATUS initialize (LTIOCallbackStream_Open open, LTIOCallbackStream_Close close, LTIOCallbackStream_Read read, LTIOCallbackStream_Write write, LTIOCallbackStream_Seek seek, LTIOCallbackStream_Tell tell, LTIOCallbackStream_IsEOF isEOF, LTIOCallbackStream_IsOpen isOpen, LTIOCallbackStream_Duplicate duplicate, void *user)
 initialize
virtual bool isEOF ()
 Test for end-of-stream.
virtual bool isOpen ()
 Test for stream openness.
virtual LT_STATUS open ()
 Opens the stream.
virtual LT_STATUS close ()
 Closes the stream.
virtual lt_uint32 read (lt_uint8 *pDest, lt_uint32 numBytes)
 Retrieve the specified number of bytes from the data source and place them in pDest.
virtual lt_uint32 write (const lt_uint8 *pSrc, lt_uint32 numBytes)
 Store the specified number of bytes in the data source.
virtual LT_STATUS seek (lt_int64 offset, LTIOSeekDir origin)
 Moves the data access position to origin + offset.
virtual lt_int64 tell ()
 Returns the current data access position as an offset from the start of the data.
virtual LTIOStreamInfduplicate ()
 Clone the stream.
virtual LT_STATUS getLastError () const
 Get status code of last error event.
virtual const char * getID () const
 Get a URI describing the stream object.

Detailed Description

This class implements a stream whose operations -- read(), write(), open(), close(), etc -- are all defined by functions passed in from the user.

This class can be used as an alternative to deriving custom stream classes from LTIOStreamInf. This class also forms the basis for the C-callable stream defined in lt_ioCStream.h.

Definition at line 36 of file lt_ioCallbackStream.h.


Constructor & Destructor Documentation


Member Function Documentation

virtual LT_STATUS LTIOCallbackStream::close ( ) [virtual]

Puts the stream in a state that does not allow data access. May free up resources, but only in such a way that doesn't inhibit successful future calls to open()

Return values:
LT_STS_SuccessOn success, or if the stream is already closed.
LT_STS_FailureOtherwise.

Implements LTIOStreamInf.

Create new stream of the same type with the same initialization parameters. The transmission of these parameters is the responsibility of the derived type. The new stream should initially return false for isOpen().

Return values:
NULLthe stream could not be duplicated; valid LTIOStreamInf* otherwise.

Implements LTIOStreamInf.

virtual const char* LTIOCallbackStream::getID ( ) const [virtual]

This function returns a UTF-8, null-terminated string which is a URI describing the origin of the stream object -- for example, "file://foo.txt" or "lt_memstream:". This string is only intended for diagnostic purposes, i.e. it may not be valid to pass it to the ctor in an attempt to reopen the stream.

Return values:
urithe uri string

Implements LTIOStreamInf.

virtual LT_STATUS LTIOCallbackStream::getLastError ( ) const [virtual]

read(), write(), tell(), and duplicate() do not explicitly return status codes in the event of an error. When an error has occurred, this function returns the appropriate status code. Note calling this function after a successful I/O operation will return an undefined value.

Return values:
statusthe error code

Implements LTIOStreamInf.

The parameters to this function are a set of function pointers which implement all the required operations needed to support a stream. Their semantics exactly mirror the semantics of the corresponding member functions in LTIOStreamInf.

The user parameter is a pointer to a user-defined area containing information about the stream itself, e.g. the filename and a FILE*. This pointer is passed as the first argument to each of the user's stream functions. This class never attempts to interpret this data directly.

Note that the implementation of the duplicate function is required to create a new copy of this user-defined data by whatever means appropriate. The user retains ownership of the copied user data.

Parameters:
openpointer to user's open function
closepointer to user's close function
readpointer to user's read function
writepointer to user's write function
seekpointer to user's seek function
tellpointer to user's tell function
isEOFpointer to user's isEOF function
isOpenpointer to user's isOpen function
duplicatepointer to user's duplicate function
userpointer to user-defined stream data
Returns:
status code indicating success or failure
virtual bool LTIOCallbackStream::isEOF ( ) [virtual]

Returns true after the first read operation that attempts to read past the end of the stream. It returns false if the current position is not end of stream.

Return values:
trueend of stream
falseotherwise

Implements LTIOStreamInf.

virtual bool LTIOCallbackStream::isOpen ( ) [virtual]
Return values:
trueThe stream is open
falseotherwise

Implements LTIOStreamInf.

virtual LT_STATUS LTIOCallbackStream::open ( ) [virtual]

Opening a stream puts it in a state that allows data access based on cached initialization parameters.

Return values:
LT_STS_IOStreamUninitializedThe stream has not been initialized with enough information to open the stream
LT_STS_IOStreamInvalidStateThe stream is already open
LT_STS_SuccessOn success.
LT_STS_FailureFailure.
otherImplementations may return other codes

Implements LTIOStreamInf.

virtual lt_uint32 LTIOCallbackStream::read ( lt_uint8 pDest,
lt_uint32  numBytes 
) [virtual]
Parameters:
pDestbuffer in which to store read data
numBytesnumber of bytes to read from stream
Return values:
numBytesThe number of bytes actually read

Implements LTIOStreamInf.

virtual LT_STATUS LTIOCallbackStream::seek ( lt_int64  offset,
LTIOSeekDir  origin 
) [virtual]
Parameters:
offsetnumber of bytes from origin at which to the next read or write will take place
originplace in stream from which to seek
Return values:
LT_STS_IOStreamUnsupportedThe stream is not seekable
LT_STS_IOStreamInvalidArgsThe offset and origin do not specify a valid location in the stream
LT_STS_SuccessOn success
LT_STS_FailureOtherwise
otherImplementations may return other codes

Implements LTIOStreamInf.

virtual lt_int64 LTIOCallbackStream::tell ( ) [virtual]
Return values:
postionNumber of bytes from the start of the data
-1On error.
otherImplementations may return other codes

Implements LTIOStreamInf.

virtual lt_uint32 LTIOCallbackStream::write ( const lt_uint8 pSrc,
lt_uint32  numBytes 
) [virtual]
Parameters:
pSrcbuffer from which to store data
numBytesnumber of bytes to write to stream
Return values:
numBytesnumber of bytes actually written

Implements LTIOStreamInf.


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