Class PgServerMessage.

Inherits Garbage. Inherited by PgAuthRequest, PgBindComplete, PgCommandComplete, PgCopyInResponse, PgDataRow, PgEmptyQueryResponse, PgKeyData, PgMessage, PgNoData, PgNotificationResponse, PgParameterDescription, PgParameterStatus, PgParseComplete, PgReady and PgRowDescription.

This is an abstract base class for PostgreSQL backend messages.

PostgreSQL messages consist of a one-byte type code, a 32-bit number representing the size of the message, and a type-specific collection of n-bit integers in network byte order, NUL-terminated strings, and arbitrary sequences of bytes.

Each message type is handled by a subclass of PgServerMessage, which provides the decodeByte/decodeInt32 and other functions to parse the message from an input buffer. The base class constructor removes the type and length specifications, leaving the subclass constructors to parse the rest of the message, and to throw a PgServerMessage::Error exception if they can't.

PgServerMessage::PgServerMessage( Buffer * b )

This function creates a new PgServerMessage, and decodes the type() and size() of the message from the Buffer b. It assumes that the Buffer contains a complete message, and leaves the rest of the data for a subclass constructor to deal with.

char PgServerMessage::decodeByte()

Returns one byte removed from the beginning of the input buffer. Throws a syntax error if it can't read a byte without exceeding either the buffer or message size.

EString PgServerMessage::decodeByten( uint x )

Returns x bytes removed from the beginning of the input buffer. Throws a syntax error if it can't read x bytes without exceeding either the buffer or the message size.

int16 PgServerMessage::decodeInt16()

Returns a 16-bit integer in network byte order read and removed from the beginning of the input buffer. Throws a syntax error if it can't read two bytes without exceeding either the buffer or message size.

int PgServerMessage::decodeInt32()

Returns a 32-bit integer in network byte order read and removed from the beginning of the input buffer. Throws a syntax error if it can't read four bytes without exceeding either the buffer of message size.

EString PgServerMessage::decodeString()

Removes a NUL-terminated string from the beginning of the input buffer, and returns it with the trailing NUL removed. Throws a syntax error if it doesn't find a NUL before the end of either the input buffer or the message.

void PgServerMessage::end()

This function is used by subclasses to assert that they have decoded the entire contents of the message. If the size of the decoded data does not match the declared size of this message, end() throws an exception.

uint PgServerMessage::size() const

Returns the size of the contents of this PgServerMessage. (This does not include the size of the length field.)

char PgServerMessage::type() const

Returns the type of this PgServerMessage.

PgServerMessage::~PgServerMessage()

This virtual destructor exists only for safe subclassing.

This web page based on source code belonging to The Archiveopteryx Developers. All rights reserved.