# Barry::DBPacket Class Reference

`#include <packet.h>`

Inheritance diagram for Barry::DBPacket:

[legend]
Collaboration diagram for Barry::DBPacket:

[legend]

List of all members.

## Detailed Description

Provides an API for building and analyzing raw DB protocol packets.

This class relies on 3 external objects: a Mode::Desktop object, a send Data buffer, and a receive data buffer. Socket and connection details are retrieved on a readonly basis from the Mode::Desktop object, but both send and receive buffers can be modified.

Note that the receive buffer may be modified during a packet send, and this DBPacket class provides API helpers to analyze the results.

Definition at line 133 of file packet.h.

## Public Member Functions

void | ClearDatabase (unsigned int dbId)
| Builds a command packet for the CLEAR_DATABASE command code, placing the data in the send buffer.
void | GetDBDB ()
| Builds a command packet for the GET_DBDB command code, placing the data in m_send.
void | GetRecordStateTable (unsigned int dbId)
| Builds a command packet in the send buffer for the GET_RECORD_STATE_TABLE command.
void | SetRecordFlags (unsigned int dbId, unsigned int stateTableIndex, uint8_t flag1)
| Builds a command packet in the send buffer for the SET_RECORD_FLAGS command code.
void | DeleteRecordByIndex (unsigned int dbId, unsigned int stateTableIndex)
| Builds a command packet in the send buffer for the DELETE_RECORD_BY_INDEX command code.
void | GetRecordByIndex (unsigned int dbId, unsigned int stateTableIndex)
| Builds a command packet in the send buffer for the GET_RECORD_BY_INDEX command code.
bool | SetRecordByIndex (unsigned int dbId, unsigned int stateTableIndex, Builder &build, const IConverter *ic)
| Builds a command packet in the m_send buffer for the SET_RECORD_BY_INDEX command code.
void | GetRecords (unsigned int dbId)
| Builds a command packet in the send buffer for the GET_RECORDS command code.
bool | SetRecord (unsigned int dbId, Builder &build, const IConverter *ic)
| Builds a command packet in the m_send buffer for the SET_RECORD command code.
unsigned int | DBOperation () const
| Returns the database operation code from the receive packet, assuming that receive contains a response packet.
bool | Parse (Parser &parser, const std::string &dbname, const IConverter *ic)
| Parses the data in the receive buffer, and attempts to be smart about it, using the last send command as guidance for what to expect in the response.
bool | ParseMeta (DBData &data)
| Fills DBData's meta data based on its data block, and the last dbop.

## Member Function Documentation

void Barry::DBPacket::ClearDatabase | ( | unsigned int | dbId | ) |

Builds a command packet for the CLEAR_DATABASE command code, placing the data in the send buffer.

Definition at line 205 of file packet.cc.

References Barry::Mode::Desktop::GetDBCommand().

Here is the call graph for this function:

void Barry::DBPacket::GetDBDB | ( |  | ) |

Builds a command packet for the GET_DBDB command code, placing the data in m_send.

Definition at line 228 of file packet.cc.

References Barry::Mode::Desktop::GetDBCommand().

Here is the call graph for this function:

void Barry::DBPacket::GetRecordStateTable | ( | unsigned int | dbId | ) |

Builds a command packet in the send buffer for the GET_RECORD_STATE_TABLE command.

Definition at line 251 of file packet.cc.

References Barry::Mode::Desktop::GetDBCommand().

Referenced by Barry::Mode::Desktop::GetRecordStateTable().

Here is the call graph for this function:

Here is the caller graph for this function:

void Barry::DBPacket::SetRecordFlags | ( | unsigned int | dbId,
|  | unsigned int | stateTableIndex,
|  | uint8_t | flag1 |
| ) |  |  |

Builds a command packet in the send buffer for the SET_RECORD_FLAGS command code.

FIXME - this API call is incomplete, since there are unknown flags in the SetRecordFlags protocol packet. Currently it is only used to set all flags to zero.

Definition at line 278 of file packet.cc.

References Barry::Mode::Desktop::GetDBCommand().

Referenced by Barry::Mode::Desktop::ClearDirty().

Here is the call graph for this function:

Here is the caller graph for this function:

void Barry::DBPacket::DeleteRecordByIndex | ( | unsigned int | dbId,
|  | unsigned int | stateTableIndex |
| ) |  |  |

Builds a command packet in the send buffer for the DELETE_RECORD_BY_INDEX command code.

Definition at line 306 of file packet.cc.

References Barry::Mode::Desktop::GetDBCommand().

Referenced by Barry::Mode::Desktop::DeleteRecord().

Here is the call graph for this function:

Here is the caller graph for this function:

void Barry::DBPacket::GetRecordByIndex | ( | unsigned int | dbId,
|  | unsigned int | stateTableIndex |
| ) |  |  |

Builds a command packet in the send buffer for the GET_RECORD_BY_INDEX command code.

Definition at line 331 of file packet.cc.

References Barry::Mode::Desktop::GetDBCommand().

Referenced by Barry::Mode::Desktop::GetRecord().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Barry::DBPacket::SetRecordByIndex | ( | unsigned int | dbId,
|  | unsigned int | stateTableIndex,
|  | Builder & | build,
|  | const IConverter * | ic |
| ) |  |  |

Builds a command packet in the m_send buffer for the SET_RECORD_BY_INDEX command code.

Returns:
  bool
  - true means success
  - false means no data available from Builder object

Definition at line 359 of file packet.cc.

References Barry::Builder::BuildRecord(), and Barry::Mode::Desktop::GetDBCommand().

Referenced by Barry::Mode::Desktop::SetRecord().

Here is the call graph for this function:

Here is the caller graph for this function:

void Barry::DBPacket::GetRecords | ( | unsigned int | dbId | ) |

Builds a command packet in the send buffer for the GET_RECORDS command code.

Definition at line 396 of file packet.cc.

References Barry::Mode::Desktop::GetDBCommand().

Here is the call graph for this function:

bool Barry::DBPacket::SetRecord | ( | unsigned int | dbId,
|  | Builder & | build,
|  | const IConverter * | ic |
| ) |  |  |

Builds a command packet in the m_send buffer for the SET_RECORD command code.

Returns:
  bool
  - true means success
  - false means no data available from Builder object

Definition at line 423 of file packet.cc.

References Barry::Builder::BuildRecord(), Barry::Mode::Desktop::GetDBCommand(), Barry::DBData::GetRecType(), and Barry::DBData::GetUniqueId().

Referenced by Barry::Mode::Desktop::AddRecord().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int Barry::DBPacket::DBOperation | ( |  | ) | const

Returns the database operation code from the receive packet, assuming that receive contains a response packet.

If receive isn't large enough, throws Error.

Definition at line 475 of file packet.cc.

bool Barry::DBPacket::Parse | ( | Parser & | parser,
|  | const std::string & | dbname,
|  | const IConverter * | ic |
| ) |  |  |

Parses the data in the receive buffer, and attempts to be smart about it, using the last send command as guidance for what to expect in the response.

Returns:
  bool true - packet was recognized and parse was attempted false - packet was not recognized

Definition at line 492 of file packet.cc.

References Barry::Parser::ParseRecord().

Referenced by Barry::Mode::Desktop::GetRecord().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Barry::DBPacket::ParseMeta | ( | DBData & | data | ) |

Fills DBData's meta data based on its data block, and the last dbop.

Definition at line 526 of file packet.cc.

References Barry::DBData::GetData(), Barry::DBData::SetIds(), Barry::DBData::SetOffset(), and Barry::DBData::SetVersion().

Here is the call graph for this function:

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

- packet.h
- packet.cc