12 #ifndef __LIDAR_STREAM_H__
13 #define __LIDAR_STREAM_H__
18 LT_BEGIN_LIDAR_NAMESPACE
153 size_t read(
void *buf,
size_t nbytes);
163 template<
typename TYPE>
bool get_le(TYPE &value)
165 size_t nbytes =
read(&value,
sizeof(TYPE));
167 Endian::swap<sizeof(TYPE)>(&value);
168 return nbytes ==
sizeof(TYPE);
179 template<
typename TYPE>
bool get_be(TYPE &value)
181 size_t nbytes =
read(&value,
sizeof(TYPE));
183 Endian::swap<sizeof(TYPE)>(&value);
184 return nbytes ==
sizeof(TYPE);
198 bool get_str(
char *&line,
size_t &length);
237 void close(
bool doFlush =
true);
273 size_t write(
const void *buf,
size_t nbytes);
283 template<
typename TYPE>
bool put_le(TYPE value)
286 Endian::swap<sizeof(TYPE)>(&value);
287 return write(&value,
sizeof(TYPE)) ==
sizeof(TYPE);
298 template<
typename TYPE>
bool put_be(TYPE value)
301 Endian::swap<sizeof(TYPE)>(&value);
302 return write(&value,
sizeof(TYPE)) ==
sizeof(TYPE);
315 bool put_str(
const char *str,
size_t length = static_cast<size_t>(-1));
351 LT_END_LIDAR_NAMESPACE
352 #endif // __LIDAR_STREAM_H__
IO::offset_type offset_type
Integer data type for seek() and tell() offsets.
void close(bool doFlush=true)
Close the IO object.
void seek(offset_type offset, Mode whence)
Set the file offset.
void open(size_t bufferSize=DefaultBufferSize)
Open the IO object.
bool get_le(TYPE &value)
Read little endian data.
Stream is the base class for buffered input and output for IO objects.
#define HOST_IS_BIG_ENDIAN
Use this macro when you need to know the host is big endian.
size_t write(const void *buf, size_t nbytes)
Write data.
seek from the begining of the file
bool get_be(TYPE &value)
Read big endian data.
#define HOST_IS_LITTLE_ENDIAN
Use this macro when you need to know the host is little endian.
void init(IO *io, bool open, size_t bufferSize=DefaultBufferSize)
Initalize the writer.
size_t read(void *buf, size_t nbytes)
Read data.
bool put_be(TYPE value)
Write little endian data.
bool copy(IO *io, offset_type offset, offset_type length)
Copy data from an IO object.
Location is a helper structure for holding the location of data in a IO object.
StreamWriter implements buffered writes to IO objects.
void seek(offset_type offset, Mode whence)
Set the file offset.
void open(size_t bufferSize=DefaultBufferSize)
Open the IO object.
bool get_str(char *&line, size_t &length)
Read the next line of text.
bool put_le(TYPE value)
Write little endian data.
seek from the current location in the file
offset_type tell(void)
Get the current file offset.
seek from the end of the file
IO is the base class for binary input and output.
void flush(void)
Flush the memory buffer.
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.
void close(void)
Close the IO object.
void flush(void)
Flush the memory buffer.
StreamReader implements buffered reads from IO objects.
void init(IO *io, bool open, size_t bufferSize=DefaultBufferSize)
Initalize the reader.
IO * getIO()
Get the underlying IO object.
lt_int64 offset_type
Integer data type for file offsets and sizes.