sf::ByteArrayPtr BoshTransport::read (long maxSize) { ByteArrayPtr result = sf::createByteArrayPtr(); if (maxSize < 0 || maxSize >= (long) mInputBuffer.size()) { result->swap (mInputBuffer); } else { result->append (mInputBuffer.const_c_array(), maxSize); mInputBuffer.l_truncate(maxSize); } return result; }
/// Eat something what was written ByteArrayPtr consume (long maxSize = -1) { if (mIngoingBuffer.empty()) return ByteArrayPtr(); ByteArrayPtr result = createByteArrayPtr(); if (maxSize < 0 || maxSize >= (int64_t) mIngoingBuffer.size()){ result->swap (mIngoingBuffer); return result; } result->assign (mIngoingBuffer.begin(), mIngoingBuffer.begin() + maxSize); mIngoingBuffer.l_truncate (maxSize); notifyAsync (mChanged); return result; }