MrSID Decode SDK for LiDAR Reference Manual  1.1.3.4427
StreamReader Class Reference

StreamReader implements buffered reads from IO objects. More...

#include <Stream.h>

Inheritance diagram for StreamReader:
Collaboration diagram for StreamReader:

Public Member Functions

 ~StreamReader (void)
 
 StreamReader (void)
 
void init (IO *io, bool open, size_t bufferSize=DefaultBufferSize)
 Initalize the reader. More...
 
void init (const IO::Location &location, size_t bufferSize=DefaultBufferSize)
 Initalize the reader. More...
 
void open (size_t bufferSize=DefaultBufferSize)
 Open the IO object. More...
 
void close (void)
 Close the IO object. More...
 
void flush (void)
 Flush the memory buffer. More...
 
void seek (offset_type offset, Mode whence)
 Set the file offset. More...
 
offset_type tell (void)
 Get the current file offset. More...
 
size_t read (void *buf, size_t nbytes)
 Read data. More...
 
template<typename TYPE >
bool get_le (TYPE &value)
 Read little endian data. More...
 
template<typename TYPE >
bool get_be (TYPE &value)
 Read big endian data. More...
 
bool get_str (char *&line, size_t &length)
 Read the next line of text. More...
 
- Public Member Functions inherited from Stream
IOgetIO ()
 Get the underlying IO object. More...
 

Additional Inherited Members

- Public Types inherited from Stream
enum  { DefaultBufferSize = 1 << 12 }
 Default Buffer Size (4096). More...
 
enum  Mode { MODE_SET = 0, MODE_CUR = 1, MODE_END = 2 }
 Seek offset origin. More...
 
typedef IO::offset_type offset_type
 Integer data type for seek() and tell() offsets. More...
 
- Protected Types inherited from Stream
typedef unsigned char byte_t
 
- Protected Member Functions inherited from Stream
 ~Stream (void)
 
 Stream (void)
 
- Protected Attributes inherited from Stream
IOm_io
 
size_t m_size
 
offset_type m_pos
 
byte_tm_head
 
byte_tm_cur
 
byte_tm_tail
 

Detailed Description

See Also
See examples/src/support.cpp compareTXTFiles() for an example of reading a file.

Definition at line 75 of file Stream.h.

Constructor & Destructor Documentation

StreamReader::~StreamReader ( void  )
StreamReader::StreamReader ( void  )

Member Function Documentation

void StreamReader::close ( void  )

This method closes the underlying IO object.

void StreamReader::flush ( void  )

This method disregard any data in the buffer and causes the next read() to get dat from the underlying IO object.

template<typename TYPE >
bool StreamReader::get_be ( TYPE &  value)
inline

This method reads sizeof(TYPE) bytes and endian swaps as needed.

Parameters
valuethe destination
Returns
true for success

Definition at line 179 of file Stream.h.

References HOST_IS_LITTLE_ENDIAN, and read().

template<typename TYPE >
bool StreamReader::get_le ( TYPE &  value)
inline

This method reads sizeof(TYPE) bytes and endian swaps as needed.

Parameters
valuethe destination
Returns
true for success

Definition at line 163 of file Stream.h.

References HOST_IS_BIG_ENDIAN, and read().

bool StreamReader::get_str ( char *&  line,
size_t &  length 
)

This method reads the next line of the file. It uses '
' as the line terminator. This method also allocates memory as needed and it is the responsible of the caller to DEALLOC() the returned line buffer.

Parameters
linepointer to the line buffer
lengththe length of the line buffer
Returns
true for success
void StreamReader::init ( IO io,
bool  open,
size_t  bufferSize = DefaultBufferSize 
)

This method binds the stream to a IO object.

Parameters
iothe source IO object
openif true init() will call open()
bufferSizethe buffer size that is passed to open()
void StreamReader::init ( const IO::Location location,
size_t  bufferSize = DefaultBufferSize 
)

This method binds the stream to a IO object and seeks to the given offset.

Parameters
locationthe source IO object and the begining offset
bufferSizethe buffer size that is passed to open()
void StreamReader::open ( size_t  bufferSize = DefaultBufferSize)

This method opens the underlying IO object.

Parameters
bufferSizethe size of buffered reads
size_t StreamReader::read ( void *  buf,
size_t  nbytes 
)

This method reads nbytes into the given buffer.

Parameters
bufthe destination buffer
nbytesthe number of bytes to read
Returns
the number bytes actually read

Referenced by get_be(), and get_le().

void StreamReader::seek ( offset_type  offset,
Mode  whence 
)

This method sets the file offset. See Mode for offset origin.

Parameters
offsetnumber bytes to move
whencethe origin of movement
offset_type StreamReader::tell ( void  )

This method get the current file offset.


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

LizardTech