Protocols::BitTorrent::Bencoding::BDecoder Class Reference

#include <BDecoder.h> [code]

List of all members.


Detailed Description

Reads bencoded items from a raw buffer (QByteArray).

This class encapsulates some functions, which would make it easier to read bencoded data out of raw data buffers.

It is safe to read pass the end of the underlying raw data. Use hasReadPastEnd() to check whether such event occurred. Use hasReadAll() to check whether all underlying data has been read.

If you want to change the binary format used by some function or add support for further user types, derive a new class from this one.

Definition at line 52 of file BDecoder.h.

Public Member Functions

 BDecoder (const QByteArray &rawData)
 Constructs a BDecoder object for rawData.
 ~BDecoder ()
 Destructor of BDecoder.
auto_ptr< BItemreadNext ()
 Reads the next BItem form the underlying raw data.
bool hasReadPassEnd () const
 Tells whether a read would have read past the end of the data buffer.
bool hasReadAll () const
 Tells whether all data from the underlying data buffer has been read.
bool hasReadAllCorrectly () const
 Tells whether everything has been read correctly.

Private Member Functions

 BDecoder (const BDecoder &)
BDecoderoperator= (const BDecoder &)

Private Attributes

auto_ptr< BinaryReaderbinaryReader


Constructor & Destructor Documentation

Protocols::BitTorrent::Bencoding::BDecoder::BDecoder const BDecoder  )  [private]
 

BDecoder::BDecoder const QByteArray &  rawData  ) 
 

Constructs a BDecoder object for rawData.

Creates a BinaryReader object. Initializes the underlying raw data buffer of the BinaryReader object using rawData and sets the byte order to little endean.

Definition at line 39 of file BDecoder.cpp.

BDecoder::~BDecoder  ) 
 

Destructor of BDecoder.

Deletes the created BinaryReader object.

Definition at line 48 of file BDecoder.cpp.


Member Function Documentation

bool BDecoder::hasReadAll  )  const
 

Tells whether all data from the underlying data buffer has been read.

Definition at line 74 of file BDecoder.cpp.

bool BDecoder::hasReadAllCorrectly  )  const
 

Tells whether everything has been read correctly.

Definition at line 82 of file BDecoder.cpp.

bool BDecoder::hasReadPassEnd  )  const
 

Tells whether a read would have read past the end of the data buffer.

Definition at line 66 of file BDecoder.cpp.

BDecoder& Protocols::BitTorrent::Bencoding::BDecoder::operator= const BDecoder  )  [private]
 

auto_ptr< BItem > BDecoder::readNext  ) 
 

Reads the next BItem form the underlying raw data.

Reads the next item or returns an invalid object if the data is invalid. It will not read beyond the end of the buffer and if it would have done so, then hasReadPastEnd() would return true.

Definition at line 58 of file BDecoder.cpp.


Member Data Documentation

auto_ptr<BinaryReader> Protocols::BitTorrent::Bencoding::BDecoder::binaryReader [private]
 

Definition at line 66 of file BDecoder.h.


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