Barry::RecordParser< RecordT, StorageT > Class Template Reference

Template class for easy creation of specific parser objects. More...

#include <parser.h>

Inheritance diagram for Barry::RecordParser< RecordT, StorageT >:

Inheritance graph
[legend]
Collaboration diagram for Barry::RecordParser< RecordT, StorageT >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 RecordParser (StorageT &storage)
 Constructor that references an externally managed storage object.
 RecordParser (StorageT *storage)
 Constructor that references a locally managed storage object.
virtual void Clear ()
 Reset and prepare for a new raw data packet.
virtual void SetIds (uint8_t RecType, uint32_t UniqueId)
 Stores the IDs.
virtual void ParseHeader (const Data &data, size_t &offset)
 Called to parse the header portion of the raw data packet.
virtual void ParseFields (const Data &data, size_t &offset, const IConverter *ic)
 Called to parse sub fields in the raw data packet.
virtual void Store ()
 Called at the very end of record parsing, and used to store the final packet somewhere, either in memory, disk, etc.


Detailed Description

template<class RecordT, class StorageT>
class Barry::RecordParser< RecordT, StorageT >

Template class for easy creation of specific parser objects.

This template takes the following template arguments:

Example LoadDatabase() call:

    struct StoreContact
    {
        std::vector<Contact> &array;
        StoreContact(std::vector<Contact> &a) : array(a) {}
        void operator() (const Contact &c)
        {
            array.push_back(c);
        }
    };

    Controller con(probeResult);
    con.OpenMode(Controller::Desktop);
    std::vector<Contact> contactList;
    StoreContact storage(contactList);
    RecordParser<Contact, StoreContact> parser(storage);
    con.LoadDatabase(con.GetDBID("Address Book"), parser);
    

Definition at line 158 of file parser.h.


Constructor & Destructor Documentation

template<class RecordT, class StorageT>
Barry::RecordParser< RecordT, StorageT >::RecordParser ( StorageT &  storage  )  [inline]

Constructor that references an externally managed storage object.

Definition at line 166 of file parser.h.

template<class RecordT, class StorageT>
Barry::RecordParser< RecordT, StorageT >::RecordParser ( StorageT *  storage  )  [inline]

Constructor that references a locally managed storage object.

The pointer passed in will be stored, and freed when this class is destroyed. It is safe to call this constructor with a 'new'ly created storage object.

Definition at line 173 of file parser.h.


Member Function Documentation

template<class RecordT, class StorageT>
virtual void Barry::RecordParser< RecordT, StorageT >::Clear (  )  [inline, virtual]

Reset and prepare for a new raw data packet.

Implements Barry::Parser.

Definition at line 182 of file parser.h.

template<class RecordT, class StorageT>
virtual void Barry::RecordParser< RecordT, StorageT >::ParseFields ( const Data &  data,
size_t &  offset,
const IConverter ic 
) [inline, virtual]

Called to parse sub fields in the raw data packet.

The same data is passed as was passed in ParseHeader, only the offset will be updated if it was advanced during the header parsing.

Implements Barry::Parser.

Definition at line 197 of file parser.h.

template<class RecordT, class StorageT>
virtual void Barry::RecordParser< RecordT, StorageT >::ParseHeader ( const Data &  data,
size_t &  offset 
) [inline, virtual]

Called to parse the header portion of the raw data packet.

data contains the entire packet, and offset contains the location at which to start parsing.

Implements Barry::Parser.

Definition at line 192 of file parser.h.

template<class RecordT, class StorageT>
virtual void Barry::RecordParser< RecordT, StorageT >::SetIds ( uint8_t  RecType,
uint32_t  UniqueId 
) [inline, virtual]

Stores the IDs.

Implements Barry::Parser.

Definition at line 187 of file parser.h.

template<class RecordT, class StorageT>
virtual void Barry::RecordParser< RecordT, StorageT >::Store (  )  [inline, virtual]

Called at the very end of record parsing, and used to store the final packet somewhere, either in memory, disk, etc.

Implements Barry::Parser.

Definition at line 203 of file parser.h.


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

Generated on Tue Jun 30 16:08:56 2009 for Barry by  doxygen 1.5.8