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

#include <parser.h>

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

Barry::Parser List of all members.

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 111 of file parser.h.

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.
 ~RecordParser ()
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)
 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.


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 119 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 126 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.

Reimplemented from Barry::Parser.

Definition at line 135 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.

Reimplemented from Barry::Parser.

Definition at line 140 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.

Reimplemented from Barry::Parser.

Definition at line 145 of file parser.h.

template<class RecordT, class StorageT>
virtual void Barry::RecordParser< RecordT, StorageT >::ParseFields ( const Data data,
size_t &  offset 
) [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.

Reimplemented from Barry::Parser.

Definition at line 150 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.

Reimplemented from Barry::Parser.

Definition at line 155 of file parser.h.


The documentation for this class was generated from the following file:
Generated on Wed Sep 24 21:27:33 2008 for Barry by  doxygen 1.5.1