Skip to content

Commit

Permalink
COMMON: Add template ctor to MemoryWriteStream for arrays
Browse files Browse the repository at this point in the history
Creating a MemoryWriteStream around an array buffer.
  • Loading branch information
DrMcCoy committed Dec 24, 2016
1 parent 54c5ddf commit 6efce26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 0 additions & 6 deletions src/common/memwritestream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@

namespace Common {

MemoryWriteStream::MemoryWriteStream(byte *buf, size_t len) : _ptr(buf), _bufSize(len), _pos(0) {
}

MemoryWriteStream::~MemoryWriteStream() {
}

size_t MemoryWriteStream::write(const void *dataPtr, size_t dataSize) {
assert(dataPtr);

Expand Down
8 changes: 6 additions & 2 deletions src/common/memwritestream.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ namespace Common {
*/
class MemoryWriteStream : boost::noncopyable, public WriteStream {
public:
MemoryWriteStream(byte *buf, size_t len);
~MemoryWriteStream();
MemoryWriteStream(byte *buf, size_t len) : _ptr(buf), _bufSize(len), _pos(0) { }
~MemoryWriteStream() { }

/** Template constructor to create a MemoryWriteStream around an array buffer. */
template<size_t N>
MemoryWriteStream(byte (&array)[N]) : _ptr(array), _bufSize(N), _pos(0) { }

size_t write(const void *dataPtr, size_t dataSize);

Expand Down

0 comments on commit 6efce26

Please sign in to comment.