add segment calls to PacketList

This commit is contained in:
Stephen Birarda 2015-07-06 15:53:26 -07:00
parent 2ab2888260
commit 3ae8ba2922
2 changed files with 5 additions and 1 deletions

View file

@ -77,6 +77,8 @@ qint64 writeData(const char* data, qint64 maxSize) {
// set our current packet to the new packet
_currentPacket = newPacket;
// return the number of bytes written to the new packet
return maxSize;
} else {
// we're an ordered PacketList - let's fit what we can into the current packet and then put the leftover
// into a new packet
@ -89,7 +91,7 @@ qint64 writeData(const char* data, qint64 maxSize) {
_packets.insert(std::move(_currentPacket));
// recursively call our writeData method for the remaining data to write to a new packet
writeData(data + numBytesToEnd, maxSize - numBytesToEnd);
return numBytesToEnd + writeData(data + numBytesToEnd, maxSize - numBytesToEnd);
}
}
}

View file

@ -20,6 +20,8 @@ public:
virtual bool isSequential() const { return true; }
void startSegment() { _segmentStartIndex = currentPacket->payload().pos(); }
void endSegment() { _segmentStartIndex = -1; }
protected:
qint64 writeData(const char* data, qint64 maxSize);
qint64 readData(const char* data, qint64 maxSize) { return 0 };