From 2768a93c52ad689e29594ed545dc26967986f002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Thu, 27 Mar 2014 15:04:53 +0200 Subject: [PATCH] libdeng2|Reader: Added a method to read a specific number of bytes Added a method that is more convenient to use than reading a FixedByteArray. --- doomsday/libdeng2/include/de/data/reader.h | 11 +++++++++++ doomsday/libdeng2/src/data/reader.cpp | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/doomsday/libdeng2/include/de/data/reader.h b/doomsday/libdeng2/include/de/data/reader.h index 79984ebe82..1653bf4649 100644 --- a/doomsday/libdeng2/include/de/data/reader.h +++ b/doomsday/libdeng2/include/de/data/reader.h @@ -157,6 +157,17 @@ class DENG2_PUBLIC Reader */ Reader &operator >> (FixedByteArray &fixedByteArray); + /** + * Reads a specific number of bytes and puts it to a destination + * byte array. + * + * @param count Number of bytes to read. + * @param destination Destination array. + * + * @return Reference to the Reader. + */ + Reader &readBytes(dsize count, IByteArray &destination); + /// Reads a Block from the source buffer. Reader &operator >> (Block &block); diff --git a/doomsday/libdeng2/src/data/reader.cpp b/doomsday/libdeng2/src/data/reader.cpp index a2131caed1..0de305edbc 100644 --- a/doomsday/libdeng2/src/data/reader.cpp +++ b/doomsday/libdeng2/src/data/reader.cpp @@ -347,6 +347,12 @@ Reader &Reader::operator >> (FixedByteArray &fixedByteArray) return *this; } +Reader &Reader::readBytes(dsize count, IByteArray &destination) +{ + FixedByteArray dest(destination, 0, count); + return *this >> dest; +} + Reader &Reader::operator >> (Block &block) { duint size = 0;