PxFileBuf#

Defined in include/filebuf/PxFileBuf.h

class PxFileBuf#

Callback class for data serialization.

The user needs to supply an PxFileBuf implementation to a number of methods to allow the SDK to read or write chunks of binary data. This allows flexibility for the source/destination of the data. For example the PxFileBuf could store data in a file, memory buffer or custom file format.

Note

It is the users responsibility to ensure that the data is written to the appropriate offset.

Public Types

enum EndianMode#

Values:

enumerator ENDIAN_NONE#
enumerator ENDIAN_BIG#
enumerator ENDIAN_LITTLE#
enum OpenMode#

Values:

enumerator OPEN_FILE_NOT_FOUND#
enumerator OPEN_READ_ONLY#
enumerator OPEN_WRITE_ONLY#
enumerator OPEN_READ_WRITE_NEW#
enumerator OPEN_READ_WRITE_EXISTING#
enum SeekType#

Values:

enumerator SEEKABLE_NO#
enumerator SEEKABLE_READ#
enumerator SEEKABLE_WRITE#
enumerator SEEKABLE_READWRITE#

Public Functions

inline PxFileBuf(EndianMode mode = ENDIAN_LITTLE)#
inline virtual ~PxFileBuf()#
virtual OpenMode getOpenMode() const = 0#
inline bool isOpen() const#
virtual SeekType isSeekable() const = 0#
inline void setEndianMode(EndianMode e)#
inline EndianMode getEndianMode() const#
virtual uint32_t getFileLength() const = 0#
virtual uint32_t seekRead(uint32_t loc) = 0#

Seeks the stream to a particular location for reading.

If the location passed exceeds the length of the stream, then it will seek to the end. Returns the location it ended up at (useful if you seek to the end) to get the file position

virtual uint32_t seekWrite(uint32_t loc) = 0#

Seeks the stream to a particular location for writing.

If the location passed exceeds the length of the stream, then it will seek to the end. Returns the location it ended up at (useful if you seek to the end) to get the file position

virtual uint32_t read(void *mem, uint32_t len) = 0#

Reads from the stream into a buffer.

Parameters:
  • mem[out] The buffer to read the stream into.

  • len[in] The number of bytes to stream into the buffer

Returns:

Returns the actual number of bytes read. If not equal to the length requested, then reached end of stream.

virtual uint32_t peek(void *mem, uint32_t len) = 0#

Reads from the stream into a buffer but does not advance the read location.

Parameters:
  • mem[out] The buffer to read the stream into.

  • len[in] The number of bytes to stream into the buffer

Returns:

Returns the actual number of bytes read. If not equal to the length requested, then reached end of stream.

virtual uint32_t write(const void *mem, uint32_t len) = 0#

Writes a buffer of memory to the stream.

Parameters:
  • mem[in] The address of a buffer of memory to send to the stream.

  • len[in] The number of bytes to send to the stream.

Returns:

Returns the actual number of bytes sent to the stream. If not equal to the length specific, then the stream is full or unable to write for some reason.

virtual uint32_t tellRead() const = 0#

Reports the current stream location read aqccess.

Returns:

Returns the current stream read location.

virtual uint32_t tellWrite() const = 0#

Reports the current stream location for write access.

Returns:

Returns the current stream write location.

virtual void flush() = 0#

Causes any temporarily cached data to be flushed to the stream.

inline virtual void close()#

Close the stream.

inline void release()#
inline void swap2Bytes(void *_data) const#
inline void swap4Bytes(void *_data) const#
inline void swap8Bytes(void *_data) const#
inline void storeDword(uint32_t v)#
inline void storeFloat(float v)#
inline void storeDouble(double v)#
inline void storeByte(uint8_t b)#
inline void storeWord(uint16_t w)#
inline uint8_t readByte()#
inline uint16_t readWord()#
inline uint32_t readDword()#
inline float readFloat()#
inline double readDouble()#

Public Static Functions

static inline bool isBigEndian()#

Public Static Attributes

static const uint32_t STREAM_SEEK_END = 0xFFFFFFFF#

Declares a constant to seek to the end of the stream.

Does not support streams longer than 32 bits