/* * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #include #include #include #include using namespace Swift; boost::shared_ptr ByteArrayReadBytestream::read(size_t size) { size_t readSize = size; if (position + readSize > data.size()) { readSize = data.size() - position; } boost::shared_ptr result = boost::make_shared( data.begin() + boost::numeric_cast(position), data.begin() + boost::numeric_cast(position) + boost::numeric_cast(readSize)); onRead(*result); position += readSize; return result; } void ByteArrayReadBytestream::addData(const std::vector& moreData) { append(data, moreData); onDataAvailable(); }