8#ifndef __LIDAR_STREAM_H__
9#define __LIDAR_STREAM_H__
14LT_BEGIN_LIDAR_NAMESPACE
149 size_t read(
void *buf,
size_t nbytes);
159 template<
typename TYPE>
bool get_le(TYPE &value)
161 size_t nbytes =
read(&value,
sizeof(TYPE));
163 Endian::swap<sizeof(TYPE)>(&value);
164 return nbytes ==
sizeof(TYPE);
175 template<
typename TYPE>
bool get_be(TYPE &value)
177 size_t nbytes =
read(&value,
sizeof(TYPE));
179 Endian::swap<sizeof(TYPE)>(&value);
180 return nbytes ==
sizeof(TYPE);
269 size_t write(
const void *buf,
size_t nbytes);
279 template<
typename TYPE>
bool put_le(TYPE value)
282 Endian::swap<sizeof(TYPE)>(&value);
283 return write(&value,
sizeof(TYPE)) ==
sizeof(TYPE);
294 template<
typename TYPE>
bool put_be(TYPE value)
297 Endian::swap<sizeof(TYPE)>(&value);
298 return write(&value,
sizeof(TYPE)) ==
sizeof(TYPE);
311 bool put_str(
const char *str,
size_t length =
static_cast<size_t>(-1));
347LT_END_LIDAR_NAMESPACE
#define HOST_IS_LITTLE_ENDIAN
Use this macro when you need to know the host is little endian.
#define HOST_IS_BIG_ENDIAN
Use this macro when you need to know the host is big endian.
IO is the base class for binary input and output.
lt_int64 offset_type
Integer data type for file offsets and sizes.
Location is a helper structure for holding the location of data in a IO object.
Stream is the base class for buffered input and output for IO objects.
IO * getIO()
Get the underlying IO object.
@ MODE_SET
seek from the begining of the file
@ MODE_END
seek from the end of the file
@ MODE_CUR
seek from the current location in the file
IO::offset_type offset_type
Integer data type for seek() and tell() offsets.
StreamReader implements buffered reads from IO objects.
size_t read(void *buf, size_t nbytes)
Read data.
void init(IO *io, bool open, size_t bufferSize=DefaultBufferSize)
Initalize the reader.
void close(void)
Close the IO object.
bool get_str(char *&line, size_t &length)
Read the next line of text.
void open(size_t bufferSize=DefaultBufferSize)
Open the IO object.
bool get_le(TYPE &value)
Read little endian data.
void flush(void)
Flush the memory buffer.
void seek(offset_type offset, Mode whence)
Set the file offset.
bool get_be(TYPE &value)
Read big endian data.
void init(const IO::Location &location, size_t bufferSize=DefaultBufferSize)
Initalize the reader.
offset_type tell(void)
Get the current file offset.
StreamWriter implements buffered writes to IO objects.
bool copy(IO *io, offset_type offset, offset_type length)
Copy data from an IO object.
void close(bool doFlush=true)
Close the IO object.
void flush(void)
Flush the memory buffer.
void seek(offset_type offset, Mode whence)
Set the file offset.
bool put_be(TYPE value)
Write little endian data.
void init(IO *io, bool open, size_t bufferSize=DefaultBufferSize)
Initalize the writer.
bool copy(StreamReader &stream, offset_type length)
Copy data from an ReaderStream.
bool put_str(const char *str, size_t length=static_cast< size_t >(-1))
Write a string.
offset_type tell(void)
Get the current file offset.
size_t write(const void *buf, size_t nbytes)
Write data.
bool copy(IO::Location &location)
Copy data from an IO object.
bool put_le(TYPE value)
Write little endian data.
void open(size_t bufferSize=DefaultBufferSize)
Open the IO object.