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

`#include <parser.h>`

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

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

[legend]

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:

- RecordT: One of the record parser classes in record.h
- StorageT: A custom storage functor class. An object of this type will be called as a function with parsed Record as an argument. This happens on the fly as the data is retrieved from the device over USB, so it should not block forever.

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

## Public Member Functions

| RecordParser (StorageT &storage)
| Constructor that references an externally managed storage object.
| RecordParser (StorageT *storage=0)
| Constructor that references a locally managed storage object.
virtual void | ParseRecord (const DBData &data, const IConverter *ic)
| Called to parse sub fields in the raw data packet.

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

template<class RecordT, class StorageT>

Barry::RecordParser< RecordT, StorageT >::RecordParser | ( | StorageT * | storage = `0` | ) | `[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 287 of file parser.h.

## Member Function Documentation

template<class RecordT, class StorageT>

virtual void Barry::RecordParser< RecordT, StorageT >::ParseRecord | ( | const DBData & | data,
|  | const IConverter * | ic |
| ) |  |  | `[inline, virtual]`

Called to parse sub fields in the raw data packet.

Implements Barry::Parser.

Definition at line 310 of file parser.h.

References Barry::ParseDBData().

Here is the call graph for this function:

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

- parser.h