Skip to content

Commit

Permalink
libdeng2: Added an operator+= for Block with IByteArray argument
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Apr 16, 2013
1 parent 7b2c5f6 commit 573e336
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doomsday/libdeng2/include/de/data/block.h
Expand Up @@ -87,6 +87,9 @@ class DENG2_PUBLIC Block : public QByteArray, public IByteArray, public IBlock
/// Appends a block after this one.
Block &operator += (Block const &other);

/// Appends a byte array after this one.
Block &operator += (IByteArray const &byteArray);

/// Copies the contents of another block.
Block &operator = (Block const &other);

Expand Down
8 changes: 8 additions & 0 deletions doomsday/libdeng2/src/data/block.cpp
Expand Up @@ -118,6 +118,14 @@ Block &Block::operator += (Block const &other)
return *this;
}

Block &Block::operator += (IByteArray const &byteArray)
{
Offset pos = size();
resize(size() + byteArray.size());
byteArray.get(0, data() + pos, byteArray.size());
return *this;
}

Block &Block::operator = (Block const &other)
{
*static_cast<QByteArray *>(this) = static_cast<QByteArray const &>(other);
Expand Down

0 comments on commit 573e336

Please sign in to comment.