Gnutella::Packets::Extensions::ExtensionBlock Class Reference

#include <ExtensionBlock.h> [code]

List of all members.


Detailed Description

Todo:
This class was NEVER tested!!!

Definition at line 38 of file ExtensionBlock.h.

Public Types

typedef QList< const Extension * > Extensions

Public Member Functions

 ExtensionBlock ()
 ExtensionBlock (const ExtensionBlock &)
ExtensionBlockoperator= (const ExtensionBlock &)
 ~ExtensionBlock ()
bool prepareRead (const QByteArray &rawData)
 Gets ready to read all known extensions from rawData.
void read (QDataStream &stream)
int prepareWrite () const
void write (QDataStream &stream) const
void addExtension (const Extension &extension)
Extensions extensions () const

Static Public Attributes

static const char ExtensionSeparator = 0x1C

Private Member Functions

void deleteExtensions ()

Private Attributes

Extensions extensions_


Member Typedef Documentation

typedef QList<const Extension *> Gnutella::Packets::Extensions::ExtensionBlock::Extensions
 

Definition at line 41 of file ExtensionBlock.h.


Constructor & Destructor Documentation

ExtensionBlock::ExtensionBlock  ) 
 

Definition at line 33 of file ExtensionBlock.cpp.

ExtensionBlock::ExtensionBlock const ExtensionBlock  ) 
 

Definition at line 37 of file ExtensionBlock.cpp.

ExtensionBlock::~ExtensionBlock  ) 
 

Definition at line 58 of file ExtensionBlock.cpp.


Member Function Documentation

void ExtensionBlock::addExtension const Extension extension  ) 
 

Definition at line 70 of file ExtensionBlock.cpp.

void ExtensionBlock::deleteExtensions  )  [private]
 

Definition at line 63 of file ExtensionBlock.cpp.

ExtensionBlock::Extensions ExtensionBlock::extensions  )  const
 

Definition at line 75 of file ExtensionBlock.cpp.

ExtensionBlock & ExtensionBlock::operator= const ExtensionBlock  ) 
 

Definition at line 43 of file ExtensionBlock.cpp.

bool ExtensionBlock::prepareRead const QByteArray &  rawData  ) 
 

Gets ready to read all known extensions from rawData.

The extension block consists of a number of extensions, which are separated by FS (0x1C). Some of the extensions (like GGEP) may contain the FS, but they provide another means to calculate the extension's length.

The function inspects the first byte of an extension in order to determine the type of extension. An object of the corresponding type is created.

Note:
The extension's data it is NOT read from the rawData argument. The read() function should be called afterwards. Normally, you would call prepareRead() in your Packet::prepareReadPayload() to allocate memory for the extensions and you would then call read() from Packet::readPayload().
Possible extensions are: XML metadata (Query, QueryHits). Starts with ASCII '&lt' (0x3C) and may be terminated by FS (0x1C), if other extensions follow it. URN (Query, QueryHits). Starts with ASCII 'u' (0x75) and terminated with FS (0x1C), if followed by another extension. GGEP (all packets). Starts with a magic byte (0xC3). No byte of the GGEP extension block is allowed to be NUL (0x00) in a QueryHits' Result Data. The extension block is terminated with a FS (0x1C), if followed by other extensions.

See also:
read(), Packet::prepareReadPayload(), Packet::readPayload()

Definition at line 106 of file ExtensionBlock.cpp.

int ExtensionBlock::prepareWrite  )  const
 

Definition at line 166 of file ExtensionBlock.cpp.

void ExtensionBlock::read QDataStream &  stream  ) 
 

Definition at line 153 of file ExtensionBlock.cpp.

void ExtensionBlock::write QDataStream &  stream  )  const
 

Definition at line 179 of file ExtensionBlock.cpp.


Member Data Documentation

Extensions Gnutella::Packets::Extensions::ExtensionBlock::extensions_ [private]
 

Definition at line 61 of file ExtensionBlock.h.

const char Gnutella::Packets::Extensions::ExtensionBlock::ExtensionSeparator = 0x1C [static]
 

Definition at line 43 of file ExtensionBlock.h.


The documentation for this class was generated from the following files: