From 9c38e964033bf22feac2dac9cb9cc13060962f43 Mon Sep 17 00:00:00 2001 From: Antidote Date: Wed, 12 Feb 2014 18:55:38 -0800 Subject: [PATCH] * Add missing readUByte to stream --- include/Stream.hpp | 8 ++++++++ src/Stream.cpp | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/Stream.hpp b/include/Stream.hpp index 2d6e36e..d7c23ec 100644 --- a/include/Stream.hpp +++ b/include/Stream.hpp @@ -122,6 +122,14 @@ public: * \throw IOException */ virtual Int8 readByte(); + + /*! \brief Reads a byte at the current position and advances the current position + * + * \return Uint8 The value at the current position + * \throw IOException + */ + virtual Uint8 readUByte(); + /*! \brief Reads a byte at the current position and advances the current position. * * \return Uint8* The buffer at the current position from the given length. diff --git a/src/Stream.cpp b/src/Stream.cpp index 4bca8e6..c420e4e 100644 --- a/src/Stream.cpp +++ b/src/Stream.cpp @@ -198,6 +198,19 @@ Int8 Stream::readByte() return *(Int8*)(m_data + m_position++); } +Uint8 Stream::readUByte() +{ + if (m_bitPosition > 0) + { + m_bitPosition = 0; + m_position += sizeof(Uint8); + } + if (m_position + 1 > m_length) + throw error::IOException("Stream::readUByte -> Position passed stream bounds"); + + return *(Uint8*)(m_data + m_position++); +} + Uint8 *Stream::readUBytes(Int64 length) { return (Uint8*)readBytes(length);