patrick
/
plasp
Archived
1
0
Fork 0

Minor refactoring in stream reading.

This commit is contained in:
Patrick Lühne 2017-06-20 18:13:49 +02:00
parent 7162fa76f6
commit 97c6e58355
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
2 changed files with 5 additions and 7 deletions

View File

@ -37,8 +37,8 @@ class Stream
Stream(const Stream &other) = delete;
Stream &operator=(const Stream &other) = delete;
Stream(Stream &&other) = default;
Stream &operator=(Stream &&other) = default;
Stream(Stream &&other) = delete;
Stream &operator=(Stream &&other) = delete;
void read(std::string streamName, std::istream &istream);
void read(const std::experimental::filesystem::path &path);

View File

@ -36,16 +36,14 @@ void Stream::read(std::string streamName, std::istream &istream)
const auto streamSize = istream.tellg();
istream.seekg(0, std::ios::beg);
const auto startPosition = m_stream.size();
m_stream.resize(m_stream.size() + streamSize);
std::copy(std::istreambuf_iterator<char>(istream), std::istreambuf_iterator<char>(), m_stream.begin() + startPosition);
m_stream.reserve(m_stream.size() + streamSize);
}
catch (const std::exception &exception)
{
istream.clear();
std::copy(std::istreambuf_iterator<char>(istream), std::istreambuf_iterator<char>(), std::back_inserter(m_stream));
}
std::copy(std::istreambuf_iterator<char>(istream), std::istreambuf_iterator<char>(), std::back_inserter(m_stream));
}
////////////////////////////////////////////////////////////////////////////////////////////////////