MrSID Decode SDK for Raster Reference Manual  9.1.0.4045
LTIOSubStream Class Reference

LTIOSubStream. More...

#include <lt_ioSubStream.h>

Inheritance diagram for LTIOSubStream:
Collaboration diagram for LTIOSubStream:

Public Member Functions

Construction, destruction, initialization
 LTIOSubStream ()
 Default Constructor. More...
 
virtual ~LTIOSubStream ()
 Destructor. More...
 
virtual LT_STATUS initialize (LTIOStreamInf *stream, lt_int64 start, lt_int64 end, bool takeOwnership=false)
 Initializes the stream. More...
 
Status accessors
virtual bool isEOF ()
 Indicates whether the stream is at the end of its data or not. More...
 
Opening and closing
virtual bool isOpen ()
 Is the stream open? More...
 
virtual LT_STATUS open ()
 Opens the stream. More...
 
virtual LT_STATUS close ()
 Closes the stream. More...
 
Data access
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. More...
 
virtual lt_uint32 write (const lt_uint8 *pSrc, lt_uint32 numBytes)
 Store the specified number of bytes in the data source. More...
 
Positioning
virtual LT_STATUS seek (lt_int64 offset, LTIOSeekDir origin)
 Moves the the data access position to origin + offset. More...
 
virtual lt_int64 tell ()
 Returns the current data access position as an offset from the start of the data. More...
 
Other operations
virtual LTIOStreamInfduplicate ()
 Clone the stream. More...
 
virtual LT_STATUS getLastError () const
 Clone the stream. More...
 
virtual const char * getID () const
 Clone the stream. More...
 
- Public Member Functions inherited from LTIOStreamInf
virtual ~LTIOStreamInf ()=0
 

Protected Member Functions

void cleanup ()
 cleanup method More...
 

Protected Attributes

LTIOStreamInfm_stream
 
bool m_ownsStream
 
lt_int64 m_startOffset
 
lt_int64 m_endOffset
 
bool m_isEOF
 

Detailed Description

A SubStream is a stream which wraps another stream, but provides access to only a (contiguous) subset of the bytes of the parent stream – without revealing any of the surrounding bytes.

Consider the following situation: the MG2 decoder always assumes byte 0 of the image stream given to it is the start of the image, but you have an image embedded in some larger stream – say from byte offset 100 to 2100. By creating a substream from the larger stream and giving that to the decoder, the decoder will be doing the right thing when it naively issues a "seek-to-beginning" request.

Note that the SubStream does NOT take ownership of the stream given to it. The caller should duplicate() the main stream first, if needed. Closing the substream will close the parent stream, but deleting the substream will not delete the parent stream.

Note that the results might be undefined if the parent or child stream is modified at any point – try to avoid such situations.

Examples:
UsingStreams.cpp.

Definition at line 46 of file lt_ioSubStream.h.

Constructor & Destructor Documentation

LTIOSubStream::LTIOSubStream ( )
virtual LTIOSubStream::~LTIOSubStream ( )
virtual

Member Function Documentation

void LTIOSubStream::cleanup ( )
protected
virtual LT_STATUS LTIOSubStream::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.

virtual LTIOStreamInf* LTIOSubStream::duplicate ( )
virtual

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* LTIOSubStream::getID ( ) const
virtual

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 LT_STATUS LTIOSubStream::getLastError ( ) const
virtual

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 LT_STATUS LTIOSubStream::initialize ( LTIOStreamInf stream,
lt_int64  start,
lt_int64  end,
bool  takeOwnership = false 
)
virtual
Parameters
streamthe parent stream to be subsetted
startthe byte offset to be byte 0 of the subset stream
endthe byte offset to be the last byte of the subset stream: reading or writing past this byte will be handled as an EOF condition
takeOwnershipif true, this object will take ownership of stream and delete it
virtual bool LTIOSubStream::isEOF ( )
virtual
Returns
true the stream is valid and at the end of its data.
Return values
falseotherwise

Implements LTIOStreamInf.

virtual bool LTIOSubStream::isOpen ( )
virtual
Return values
truethe stream is valid and in a state that allows data access.
falseotherwise

Implements LTIOStreamInf.

virtual LT_STATUS LTIOSubStream::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 the stream is already open
LT_STS_SuccessOn success.
LT_STS_FailureOtherwise.

Implements LTIOStreamInf.

virtual lt_uint32 LTIOSubStream::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 LTIOSubStream::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

Implements LTIOStreamInf.

virtual lt_int64 LTIOSubStream::tell ( )
virtual
Return values
postionNumber of bytes from the start of the data
-1On error.

Implements LTIOStreamInf.

virtual lt_uint32 LTIOSubStream::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.

Member Data Documentation

lt_int64 LTIOSubStream::m_endOffset
protected

Definition at line 223 of file lt_ioSubStream.h.

bool LTIOSubStream::m_isEOF
protected

Definition at line 225 of file lt_ioSubStream.h.

bool LTIOSubStream::m_ownsStream
protected

Definition at line 221 of file lt_ioSubStream.h.

lt_int64 LTIOSubStream::m_startOffset
protected

Definition at line 222 of file lt_ioSubStream.h.

LTIOStreamInf* LTIOSubStream::m_stream
protected

Definition at line 220 of file lt_ioSubStream.h.


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

LizardTech