Files
@ 90ef6e3128f2
Branch filter:
Location: libtransport.git/src/memoryreadbytestream.cpp - annotation
90ef6e3128f2
2.2 KiB
text/x-c++hdr
Fix HAVE_SWIFTEN_3 definition to work also in gcc. Fix the tests to work with swiften3 and also with swiften2.
03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 b55ba07e93d3 03c7d96eab83 03c7d96eab83 b55ba07e93d3 b55ba07e93d3 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 b55ba07e93d3 03c7d96eab83 b55ba07e93d3 b55ba07e93d3 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 b55ba07e93d3 b55ba07e93d3 b55ba07e93d3 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 193a7987466c 03c7d96eab83 03c7d96eab83 03c7d96eab83 03c7d96eab83 | /**
* libtransport -- C++ library for easy XMPP Transports development
*
* Copyright (C) 2011, Jan Kaluza <hanzz.k@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#include "transport/memoryreadbytestream.h"
#include <boost/foreach.hpp>
namespace Transport {
MemoryReadBytestream::MemoryReadBytestream(unsigned long size) {
neededData = false;
m_finished = false;
m_sent = 0;
m_size = size;
}
MemoryReadBytestream::~MemoryReadBytestream() {
}
unsigned long MemoryReadBytestream::appendData(const std::string &data) {
m_data += data;
onDataAvailable();
neededData = false;
return m_data.size();
}
boost::shared_ptr<std::vector<unsigned char> > MemoryReadBytestream::read(size_t size) {
if (m_data.empty()) {
onDataNeeded();
return boost::shared_ptr<std::vector<unsigned char> >(new std::vector<unsigned char>());
}
if (m_data.size() < size) {
boost::shared_ptr<std::vector<unsigned char> > ptr(new std::vector<unsigned char>(m_data.begin(), m_data.end()));
m_sent += m_data.size();
m_data.clear();
if (m_sent == m_size)
m_finished = true;
onDataNeeded();
return ptr;
}
boost::shared_ptr<std::vector<unsigned char> > ptr(new std::vector<unsigned char>(m_data.begin(), m_data.begin() + size));
m_data.erase(m_data.begin(), m_data.begin() + size);
m_sent += size;
if (m_sent == m_size)
m_finished = true;
if (m_data.size() < 500000 && !neededData) {
neededData = true;
onDataNeeded();
}
return ptr;
}
bool MemoryReadBytestream::isFinished() const {
// std::cout << "finished? " << m_finished << "\n";
return m_finished;
}
}
|