Skip to content

Commit

Permalink
libdeng2|Reader: Added a method to read a specific number of bytes
Browse files Browse the repository at this point in the history
Added a method that is more convenient to use than reading a
FixedByteArray.
  • Loading branch information
skyjake committed Mar 27, 2014
1 parent c8fb356 commit 2768a93
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions doomsday/libdeng2/include/de/data/reader.h
Expand Up @@ -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);

Expand Down
6 changes: 6 additions & 0 deletions doomsday/libdeng2/src/data/reader.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 2768a93

Please sign in to comment.