PxFileBuf Class Referenceabstract

Callback class for data serialization. More...

#include <PxFileBuf.h>

Public Types

enum  EndianMode { ENDIAN_NONE = 0, ENDIAN_BIG = 1, ENDIAN_LITTLE = 2 }
 
enum  OpenMode {
  OPEN_FILE_NOT_FOUND, OPEN_READ_ONLY, OPEN_WRITE_ONLY, OPEN_READ_WRITE_NEW,
  OPEN_READ_WRITE_EXISTING
}
 
enum  SeekType { SEEKABLE_NO = 0, SEEKABLE_READ = 0x1, SEEKABLE_WRITE = 0x2, SEEKABLE_READWRITE = 0x3 }
 

Public Member Functions

 PxFileBuf (EndianMode mode=ENDIAN_LITTLE)
 
virtual ~PxFileBuf (void)
 
virtual OpenMode getOpenMode (void) const =0
 
bool isOpen (void) const
 
virtual SeekType isSeekable (void) const =0
 
void setEndianMode (EndianMode e)
 
EndianMode getEndianMode (void) const
 
virtual uint32_t getFileLength (void) const =0
 
virtual uint32_t seekRead (uint32_t loc)=0
 Seeks the stream to a particular location for reading. More...
 
virtual uint32_t seekWrite (uint32_t loc)=0
 Seeks the stream to a particular location for writing. More...
 
virtual uint32_t read (void *mem, uint32_t len)=0
 Reads from the stream into a buffer. More...
 
virtual uint32_t peek (void *mem, uint32_t len)=0
 Reads from the stream into a buffer but does not advance the read location. More...
 
virtual uint32_t write (const void *mem, uint32_t len)=0
 Writes a buffer of memory to the stream. More...
 
virtual uint32_t tellRead (void) const =0
 Reports the current stream location read aqccess. More...
 
virtual uint32_t tellWrite (void) const =0
 Reports the current stream location for write access. More...
 
virtual void flush (void)=0
 Causes any temporarily cached data to be flushed to the stream. More...
 
virtual void close (void)
 Close the stream. More...
 
void release (void)
 
PX_INLINE void swap2Bytes (void *_data) const
 
PX_INLINE void swap4Bytes (void *_data) const
 
PX_INLINE void swap8Bytes (void *_data) const
 
PX_INLINE void storeDword (uint32_t v)
 
PX_INLINE void storeFloat (float v)
 
PX_INLINE void storeDouble (double v)
 
PX_INLINE void storeByte (uint8_t b)
 
PX_INLINE void storeWord (uint16_t w)
 
uint8_t readByte (void)
 
uint16_t readWord (void)
 
uint32_t readDword (void)
 
float readFloat (void)
 
double readDouble (void)
 

Static Public Member Functions

static PX_INLINE bool isBigEndian ()
 

Static Public Attributes

static const uint32_t STREAM_SEEK_END =0xFFFFFFFF
 Declares a constant to seek to the end of the stream. More...
 

Private Attributes

bool mEndianSwap
 
EndianMode mEndianMode
 

Detailed Description

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.

Member Enumeration Documentation

◆ EndianMode

Enumerator
ENDIAN_NONE 
ENDIAN_BIG 
ENDIAN_LITTLE 

◆ OpenMode

Enumerator
OPEN_FILE_NOT_FOUND 
OPEN_READ_ONLY 
OPEN_WRITE_ONLY 
OPEN_READ_WRITE_NEW 
OPEN_READ_WRITE_EXISTING 

◆ SeekType

Enumerator
SEEKABLE_NO 
SEEKABLE_READ 
SEEKABLE_WRITE 
SEEKABLE_READWRITE 

Constructor & Destructor Documentation

◆ PxFileBuf()

PxFileBuf::PxFileBuf ( EndianMode  mode = ENDIAN_LITTLE)
inline

◆ ~PxFileBuf()

virtual PxFileBuf::~PxFileBuf ( void  )
inlinevirtual

Member Function Documentation

◆ close()

virtual void PxFileBuf::close ( void  )
inlinevirtual

Close the stream.

◆ flush()

virtual void PxFileBuf::flush ( void  )
pure virtual

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

◆ getEndianMode()

EndianMode PxFileBuf::getEndianMode ( void  ) const
inline

◆ getFileLength()

virtual uint32_t PxFileBuf::getFileLength ( void  ) const
pure virtual

◆ getOpenMode()

virtual OpenMode PxFileBuf::getOpenMode ( void  ) const
pure virtual

◆ isBigEndian()

static PX_INLINE bool PxFileBuf::isBigEndian ( )
inlinestatic

◆ isOpen()

bool PxFileBuf::isOpen ( void  ) const
inline

◆ isSeekable()

virtual SeekType PxFileBuf::isSeekable ( void  ) const
pure virtual

◆ peek()

virtual uint32_t PxFileBuf::peek ( void *  mem,
uint32_t  len 
)
pure virtual

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

Parameters
[out]memThe buffer to read the stream into.
[in]lenThe 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.

◆ read()

virtual uint32_t PxFileBuf::read ( void *  mem,
uint32_t  len 
)
pure virtual

Reads from the stream into a buffer.

Parameters
[out]memThe buffer to read the stream into.
[in]lenThe 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.

◆ readByte()

uint8_t PxFileBuf::readByte ( void  )
inline

◆ readDouble()

double PxFileBuf::readDouble ( void  )
inline

◆ readDword()

uint32_t PxFileBuf::readDword ( void  )
inline

◆ readFloat()

float PxFileBuf::readFloat ( void  )
inline

◆ readWord()

uint16_t PxFileBuf::readWord ( void  )
inline

◆ release()

void PxFileBuf::release ( void  )
inline

◆ seekRead()

virtual uint32_t PxFileBuf::seekRead ( uint32_t  loc)
pure virtual

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

◆ seekWrite()

virtual uint32_t PxFileBuf::seekWrite ( uint32_t  loc)
pure virtual

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

◆ setEndianMode()

void PxFileBuf::setEndianMode ( EndianMode  e)
inline

◆ storeByte()

PX_INLINE void PxFileBuf::storeByte ( uint8_t  b)
inline

◆ storeDouble()

PX_INLINE void PxFileBuf::storeDouble ( double  v)
inline

◆ storeDword()

PX_INLINE void PxFileBuf::storeDword ( uint32_t  v)
inline

◆ storeFloat()

PX_INLINE void PxFileBuf::storeFloat ( float  v)
inline

◆ storeWord()

PX_INLINE void PxFileBuf::storeWord ( uint16_t  w)
inline

◆ swap2Bytes()

PX_INLINE void PxFileBuf::swap2Bytes ( void *  _data) const
inline

◆ swap4Bytes()

PX_INLINE void PxFileBuf::swap4Bytes ( void *  _data) const
inline

◆ swap8Bytes()

PX_INLINE void PxFileBuf::swap8Bytes ( void *  _data) const
inline

◆ tellRead()

virtual uint32_t PxFileBuf::tellRead ( void  ) const
pure virtual

Reports the current stream location read aqccess.

Returns
Returns the current stream read location.

◆ tellWrite()

virtual uint32_t PxFileBuf::tellWrite ( void  ) const
pure virtual

Reports the current stream location for write access.

Returns
Returns the current stream write location.

◆ write()

virtual uint32_t PxFileBuf::write ( const void *  mem,
uint32_t  len 
)
pure virtual

Writes a buffer of memory to the stream.

Parameters
[in]memThe address of a buffer of memory to send to the stream.
[in]lenThe 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.

Member Data Documentation

◆ mEndianMode

EndianMode PxFileBuf::mEndianMode
private

◆ mEndianSwap

bool PxFileBuf::mEndianSwap
private

◆ STREAM_SEEK_END

const uint32_t PxFileBuf::STREAM_SEEK_END =0xFFFFFFFF
static

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

Does not support streams longer than 32 bits


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