fb-cpp 0.0.2
A modern C++ wrapper for the Firebird database API
Loading...
Searching...
No Matches
fbcpp::request::Request Class Referencefinal

Represents a Firebird request: a precompiled BLR (Binary Language Representation) program. More...

#include <Request.h>

Classes

struct  MessageEntry
 Associates a message number declared in the BLR with its format. More...
 

Public Member Functions

 Request (Attachment &attachment, std::span< const std::byte > blr, const std::vector< MessageEntry > &messages={})
 Compiles a request from the given BLR for the attachment's database.
 
 Request (Request &&o) noexcept
 Move constructor.
 
Request & operator= (Request &&o) noexcept
 Move assignment.
 
 Request (const Request &)=delete
 
Request & operator= (const Request &)=delete
 
 ~Request () noexcept
 Releases resources; ignores failures to keep destructor noexcept.
 
bool isValid () noexcept
 Returns whether the Request object is valid.
 
Attachment & getAttachment () noexcept
 Returns the Attachment object reference used to create this Request.
 
FbRef< fb::IRequest > getHandle () noexcept
 Returns the internal Firebird IRequest handle.
 
RequestMessage & getMessage (unsigned messageNumber)
 Returns the message associated with a message number declared at construction time.
 
void free ()
 Releases the compiled request.
 
void start (Transaction &transaction, unsigned level=0)
 Starts the execution of the request.
 
void startAndSend (Transaction &transaction, unsigned messageNumber, unsigned level=0)
 Starts the execution of the request, sending it an input message.
 
void send (unsigned messageNumber, unsigned level=0)
 Sends an input message to the running request.
 
bool receive (unsigned messageNumber, unsigned level=0)
 Receives a record from the running request into the associated message.
 
void unwind (unsigned level=0)
 Unwinds the running request.
 

Detailed Description

Represents a Firebird request: a precompiled BLR (Binary Language Representation) program.

Requests bypass SQL entirely. The BLR is supplied by the caller - typically produced by gpre or hand-written - and declares its own messages with blr_message clauses. Describe each message you intend to access with a RequestMessageFormat (preferably generating its clause with buildBlrMessageClause) and pass both to the constructor; values are then read and written through typed accessors instead of raw buffers.

A request is executed with start or startAndSend. Records produced by the BLR body (blr_send nodes) are consumed with receive, which returns false when the request is finished. Input messages declared by the BLR body (blr_receive nodes) are delivered with send.

Definition at line 67 of file Request.h.

Constructor & Destructor Documentation

◆ Request() [1/2]

fbcpp::request::Request::Request ( Attachment &  attachment,
std::span< const std::byte >  blr,
const std::vector< MessageEntry > &  messages = {} 
)
explicit

Compiles a request from the given BLR for the attachment's database.

Definition at line 33 of file Request.cpp.

◆ Request() [2/2]

fbcpp::request::Request::Request ( Request &&  o)
noexcept

Move constructor.

A moved Request object becomes invalid.

Definition at line 57 of file Request.cpp.

◆ ~Request()

fbcpp::request::Request::~Request ( )
inlinenoexcept

Releases resources; ignores failures to keep destructor noexcept.

Definition at line 111 of file Request.h.

Member Function Documentation

◆ free()

void fbcpp::request::Request::free ( )

Releases the compiled request.

Definition at line 91 of file Request.cpp.

◆ getAttachment()

Attachment & fbcpp::request::Request::getAttachment ( )
inlinenoexcept

Returns the Attachment object reference used to create this Request.

Definition at line 138 of file Request.h.

◆ getHandle()

FbRef< fb::IRequest > fbcpp::request::Request::getHandle ( )
inlinenoexcept

Returns the internal Firebird IRequest handle.

Definition at line 146 of file Request.h.

◆ getMessage()

RequestMessage & fbcpp::request::Request::getMessage ( unsigned  messageNumber)

Returns the message associated with a message number declared at construction time.

Definition at line 78 of file Request.cpp.

◆ isValid()

bool fbcpp::request::Request::isValid ( )
inlinenoexcept

Returns whether the Request object is valid.

Definition at line 130 of file Request.h.

◆ operator=()

Request & fbcpp::request::Request::operator= ( Request &&  o)
noexcept

Move assignment.

A moved Request object becomes invalid.

Definition at line 65 of file Request.cpp.

◆ receive()

bool fbcpp::request::Request::receive ( unsigned  messageNumber,
unsigned  level = 0 
)

Receives a record from the running request into the associated message.

Returns false when the request has no more records.

Definition at line 140 of file Request.cpp.

◆ send()

void fbcpp::request::Request::send ( unsigned  messageNumber,
unsigned  level = 0 
)

Sends an input message to the running request.

Definition at line 124 of file Request.cpp.

◆ start()

void fbcpp::request::Request::start ( Transaction &  transaction,
unsigned  level = 0 
)

Starts the execution of the request.

Definition at line 99 of file Request.cpp.

◆ startAndSend()

void fbcpp::request::Request::startAndSend ( Transaction &  transaction,
unsigned  messageNumber,
unsigned  level = 0 
)

Starts the execution of the request, sending it an input message.

Definition at line 107 of file Request.cpp.

◆ unwind()

void fbcpp::request::Request::unwind ( unsigned  level = 0)

Unwinds the running request.

Definition at line 168 of file Request.cpp.


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