Urn.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "Qt.h"
00024 #include "Urn.h"
00025 #include "ExtensionBlock.h"
00026
00027 using namespace Gnutella::Packets::Extensions;
00028
00029 Urn::Urn()
00030 {
00031 }
00032
00033 Urn * Urn::copy() const
00034 {
00035 return new Urn (*this);
00036 }
00037
00038 Urn::~Urn()
00039 {
00040 }
00041
00042 int Urn::prepareRead (const QByteArray &rawData)
00043 {
00044
00045 int endPos = rawData.indexOf (ExtensionBlock::ExtensionSeparator);
00046 if (endPos == -1)
00047 endPos = rawData.length();
00048
00049 urn_.resize (endPos);
00050 return endPos;
00051 }
00052
00053 void Urn::read (QDataStream &stream)
00054 {
00055 stream.readRawData (urn_.data(), urn_.size());
00056 }
00057
00058 int Urn::prepareWrite() const
00059 {
00060 return urn_.length();
00061 }
00062
00063 void Urn::write (QDataStream &stream) const
00064 {
00065 stream.writeRawData (urn_.data(), urn_.length());
00066 }