MrSID Decode SDK for LiDAR Reference Manual 1.1.5.5244
StreamWriter Class Reference

StreamWriter implements buffered writes to IO objects. More...

#include <Stream.h>

Inheritance diagram for StreamWriter:
Collaboration diagram for StreamWriter:

Public Member Functions

 ~StreamWriter (void)
 
 StreamWriter (void)
 
void init (IO *io, bool open, size_t bufferSize=DefaultBufferSize)
 Initalize the writer. More...
 
void open (size_t bufferSize=DefaultBufferSize)
 Open the IO object. More...
 
void close (bool doFlush=true)
 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 write (const void *buf, size_t nbytes)
 Write data. More...
 
template<typename TYPE >
bool put_le (TYPE value)
 Write little endian data. More...
 
template<typename TYPE >
bool put_be (TYPE value)
 Write little endian data. More...
 
bool put_str (const char *str, size_t length=static_cast< size_t >(-1))
 Write a string. More...
 
bool copy (IO *io, offset_type offset, offset_type length)
 Copy data from an IO object. More...
 
bool copy (IO::Location &location)
 Copy data from an IO object. More...
 
bool copy (StreamReader &stream, offset_type length)
 Copy data from an ReaderStream. More...
 
- Public Member Functions inherited from Stream
IO * getIO ()
 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
IO * m_io
 
size_t m_size
 
offset_type m_pos
 
byte_t * m_head
 
byte_t * m_cur
 
byte_t * m_tail
 

Detailed Description

Definition at line 200 of file Stream.h.

Constructor & Destructor Documentation

◆ ~StreamWriter()

StreamWriter::~StreamWriter ( void  )

◆ StreamWriter()

StreamWriter::StreamWriter ( void  )

Member Function Documentation

◆ close()

void StreamWriter::close ( bool  doFlush = true)

This method flushs any buffered data if doFlush is true and then closes the underlying IO object.

◆ copy() [1/3]

bool StreamWriter::copy ( IO *  io,
offset_type  offset,
offset_type  length 
)

This method copies length bytes for io at offset.

Parameters
iothe source IO object
offsetthe byte offset to source data
lengththe number of bytes to copy
Returns
true for success

◆ copy() [2/3]

bool StreamWriter::copy ( IO::Location &  location)

This method copies the data pointed to by location.

Parameters
locationthe location of the data
Returns
true for success

◆ copy() [3/3]

bool StreamWriter::copy ( StreamReader &  stream,
offset_type  length 
)

This method copies the next length bytes from stream

Parameters
streamthe source stream
lengththe number of bytes to copy
Returns
true for success

◆ flush()

void StreamWriter::flush ( void  )

This method wirtes any buffered data to the IO object.

◆ init()

void StreamWriter::init ( IO *  io,
bool  open,
size_t  bufferSize = DefaultBufferSize 
)

This method binds the stream to a IO object.

Parameters
iothe destination IO object
openif true init() will call open()
bufferSizethe buffer size that is passed to open()

◆ open()

void StreamWriter::open ( size_t  bufferSize = DefaultBufferSize)

This method opens the underlying IO object,

Parameters
bufferSizethe size of buffered writes

◆ put_be()

template<typename TYPE >
bool StreamWriter::put_be ( TYPE  value)
inline

This method writes sizeof(TYPE) bytes in big endian format.

Parameters
valuethe source value
Returns
true for success

Definition at line 294 of file Stream.h.

References HOST_IS_LITTLE_ENDIAN, and write().

◆ put_le()

template<typename TYPE >
bool StreamWriter::put_le ( TYPE  value)
inline

This method writes sizeof(TYPE) bytes in little endian format.

Parameters
valuethe source value
Returns
true for success

Definition at line 279 of file Stream.h.

References HOST_IS_BIG_ENDIAN, and write().

◆ put_str()

bool StreamWriter::put_str ( const char *  str,
size_t  length = static_cast< size_t >(-1) 
)

This method writes the string with given length.

Parameters
strthe source string
lengththe number of bytes to write if length is -1 put_str() uses the null terminator length.
Returns
true for success

◆ seek()

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

This method flushs any beffered data then sets the file offset. See Mode for offset origin.

Parameters
offsetnumber bytes to move
whencethe origin of movement

◆ tell()

offset_type StreamWriter::tell ( void  )

This method get the current file offset.

◆ write()

size_t StreamWriter::write ( const void *  buf,
size_t  nbytes 
)

This method writes nbytes from the given buffer.

Parameters
bufthe source buffer
nbytesthe number of bytes to write
Returns
the number bytes actually written

Referenced by put_be(), and put_le().


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

Extensis