Mercurial > hg > orthanc
changeset 3385:f5467ab24aa4
ChunkedBuffer::AddChunkDestructive()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 03 Jun 2019 10:30:14 +0200 |
parents | 2b645caab9ee |
children | af9432e46c07 |
files | Core/ChunkedBuffer.cpp Core/ChunkedBuffer.h |
diffstat | 2 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/ChunkedBuffer.cpp Wed May 29 18:12:28 2019 +0200 +++ b/Core/ChunkedBuffer.cpp Mon Jun 03 10:30:14 2019 +0200 @@ -77,6 +77,19 @@ } + void ChunkedBuffer::AddChunkDestructive(std::string& chunk) + { + size_t chunkSize = chunk.size(); + + if (chunkSize > 0) + { + chunks_.push_back(new std::string); + chunks_.back()->swap(chunk); + numBytes_ += chunkSize; + } + } + + void ChunkedBuffer::Flatten(std::string& result) { result.resize(numBytes_);
--- a/Core/ChunkedBuffer.h Wed May 29 18:12:28 2019 +0200 +++ b/Core/ChunkedBuffer.h Mon Jun 03 10:30:14 2019 +0200 @@ -67,6 +67,9 @@ void AddChunk(const std::string& chunk); + // The source content will be emptied + void AddChunkDestructive(std::string& chunk); + void Flatten(std::string& result); }; }