lots of new streaming interface additions

This commit is contained in:
Jack Andersen
2015-04-10 14:04:13 -10:00
parent e4f5c09534
commit e4f8c2959f
9 changed files with 50 additions and 7 deletions

View File

@@ -40,6 +40,7 @@ public:
bool isOpen() const;
bool save();
void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current);
inline void seekAlign32() {seek(ROUND_UP_32(position()), SeekOrigin::Begin);}
bool atEnd() const;
atUint64 position() const;
atUint64 length() const;
@@ -51,6 +52,8 @@ public:
atInt8 readByte();
atUint8* readUBytes(atUint64 len);
atInt8* readBytes(atUint64 len);
atUint64 readBytesToBuf(void* buf, atUint64 len) {return readUBytesToBuf(buf, len);}
atUint64 readUBytesToBuf(void* buf, atUint64 len);
atUint16 readUint16();
atInt16 readInt16();
atUint32 readUint32();

View File

@@ -37,6 +37,7 @@ public:
bool isOpen() const;
bool save();
void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current);
inline void seekAlign32() {seek(ROUND_UP_32(position()), SeekOrigin::Begin);}
bool atEnd() const;
atUint64 position() const;
atUint64 length() const;

View File

@@ -59,6 +59,9 @@
#define BLOCKSZ 512
#endif
#define ROUND_UP_32(val) (((val) + 31) & ~31)
#define ROUND_UP_16(val) (((val) + 15) & ~15)
namespace Athena
{
enum class SeekOrigin

View File

@@ -17,6 +17,7 @@ public:
virtual bool isLittleEndian()const= 0;
virtual bool isOpen() const= 0;
virtual void seek(atInt64, SeekOrigin)=0;
virtual void seekAlign32()=0;
virtual bool atEnd() const= 0;
virtual atUint64 position() const= 0;
virtual atUint64 length() const= 0;
@@ -26,6 +27,8 @@ public:
virtual atInt8 readByte()=0;
virtual atUint8* readUBytes(atUint64)=0;
virtual atInt8* readBytes(atUint64)=0;
virtual atUint64 readUBytesToBuf(void*, atUint64)=0;
virtual atUint64 readBytesToBuf(void*, atUint64)=0;
virtual atUint16 readUint16()=0;
virtual atInt16 readInt16()=0;
virtual atUint32 readUint32()=0;

View File

@@ -17,6 +17,7 @@ public:
virtual bool isLittleEndian()const= 0;
virtual bool isOpen() const= 0;
virtual void seek(atInt64, SeekOrigin)=0;
virtual void seekAlign32()=0;
virtual bool atEnd() const= 0;
virtual atUint64 position() const= 0;
virtual atUint64 length() const= 0;

View File

@@ -87,6 +87,9 @@ public:
*/
void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current);
/*! \brief Sets the buffers position relative to the next 32-byte aligned position.<br />
*/
inline void seekAlign32() {seek(ROUND_UP_32(m_position), SeekOrigin::Begin);}
/*! \brief Returns whether or not the stream is at the end.
*
@@ -167,13 +170,16 @@ public:
*
* \return Uint8* The buffer at the current position from the given length.
*/
atInt8* readBytes(atUint64 length);
inline atInt8* readBytes(atUint64 length) {return (atInt8*)readUBytes(length);}
/*! \brief Reads a byte at the current position and advances the current position.
*
* \return Int8* The buffer at the current position from the given length.
*/
atUint8* readUBytes(atUint64 length);
atUint64 readBytesToBuf(void* buf, atUint64 len) {return readUBytesToBuf(buf, len);}
atUint64 readUBytesToBuf(void* buf, atUint64 len);
/*! \brief Reads a Int16 and swaps to proper endianness depending on platform
* and Stream settings, and advances the current position

View File

@@ -87,6 +87,10 @@ public:
* \param origin The Origin to seek \sa SeekOrigin
*/
void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current);
/*! \brief Sets the buffers position relative to the next 32-byte aligned position.<br />
*/
inline void seekAlign32() {seek(ROUND_UP_32(m_position), SeekOrigin::Begin);}
/*! \brief Returns whether or not the stream is at the end.