fb-cpp
0.0.2
A modern C++ wrapper for the Firebird database API
Loading...
Searching...
No Matches
Request.h
1
/*
2
* MIT License
3
*
4
* Copyright (c) 2026 Adriano dos Santos Fernandes
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to deal
8
* in the Software without restriction, including without limitation the rights
9
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
* copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in all
14
* copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
* SOFTWARE.
23
*/
24
25
#ifndef FBCPP_REQUEST_H
26
#define FBCPP_REQUEST_H
27
28
#include "fb-cpp-export.h"
29
#include "../fb-api.h"
30
#include "../Exception.h"
31
#include "RequestMessage.h"
32
#include "RequestMessageFormat.h"
33
#include "../SmartPtrs.h"
34
#include <cstddef>
35
#include <cstdint>
36
#include <utility>
37
#include <vector>
38
39
43
namespace
fbcpp
44
{
45
class
Attachment;
46
class
Transaction;
47
}
// namespace fbcpp
48
49
53
namespace
fbcpp::request
54
{
67
class
FB_CPP_EXPORT
Request
final
68
{
69
public
:
73
struct
MessageEntry
final
74
{
78
unsigned
messageNumber
;
79
83
RequestMessageFormat
format
;
84
};
85
86
public
:
90
explicit
Request
(
91
Attachment
& attachment, std::span<const std::byte> blr,
const
std::vector<MessageEntry>& messages = {});
92
97
Request
(
Request
&& o)
noexcept
;
98
103
Request
& operator=(
Request
&& o)
noexcept
;
104
105
Request
(
const
Request
&) =
delete
;
106
Request
& operator=(
const
Request
&) =
delete
;
107
111
~Request
() noexcept
112
{
113
if
(isValid())
114
{
115
try
116
{
117
free();
118
}
119
catch
(...)
120
{
121
// swallow
122
}
123
}
124
}
125
126
public
:
130
bool
isValid
() noexcept
131
{
132
return
handle !=
nullptr
;
133
}
134
138
Attachment
&
getAttachment
() noexcept
139
{
140
return
*attachment;
141
}
142
146
FbRef<fb::IRequest>
getHandle
() noexcept
147
{
148
return
handle;
149
}
150
154
RequestMessage
& getMessage(
unsigned
messageNumber);
155
159
void
free();
160
164
void
start(
Transaction
& transaction,
unsigned
level = 0);
165
169
void
startAndSend(
Transaction
& transaction,
unsigned
messageNumber,
unsigned
level = 0);
170
174
void
send(
unsigned
messageNumber,
unsigned
level = 0);
175
180
bool
receive(
unsigned
messageNumber,
unsigned
level = 0);
181
185
void
unwind(
unsigned
level = 0);
186
187
private
:
188
RequestMessage
* findMessage(
unsigned
messageNumber)
const
noexcept
;
189
190
private
:
191
Attachment
* attachment;
192
std::vector<std::pair<unsigned, RequestMessage>> messages;
193
impl::StatusWrapper statusWrapper;
194
FbRef<fb::IRequest>
handle;
195
};
196
}
// namespace fbcpp::request
197
198
199
#endif
// FBCPP_REQUEST_H
fbcpp::Attachment
Represents a connection to a Firebird database.
Definition
Attachment.h:220
fbcpp::FbRef
Reference-counted smart pointer for Firebird objects using addRef/release semantics.
Definition
SmartPtrs.h:70
fbcpp::Transaction
Represents a transaction in one or more Firebird databases.
Definition
Transaction.h:353
fbcpp::request::RequestMessageFormat
Describes the fields of a Firebird request message.
Definition
RequestMessageFormat.h:62
fbcpp::request::RequestMessage
A message buffer of a Firebird request with typed accessors.
Definition
RequestMessage.h:78
fbcpp::request::Request
Represents a Firebird request: a precompiled BLR (Binary Language Representation) program.
Definition
Request.h:68
fbcpp::request::Request::getAttachment
Attachment & getAttachment() noexcept
Returns the Attachment object reference used to create this Request.
Definition
Request.h:138
fbcpp::request::Request::isValid
bool isValid() noexcept
Returns whether the Request object is valid.
Definition
Request.h:130
fbcpp::request::Request::getHandle
FbRef< fb::IRequest > getHandle() noexcept
Returns the internal Firebird IRequest handle.
Definition
Request.h:146
fbcpp::request::Request::~Request
~Request() noexcept
Releases resources; ignores failures to keep destructor noexcept.
Definition
Request.h:111
fbcpp::request
fb-cpp request namespace.
Definition
Request.cpp:32
fbcpp
fb-cpp namespace.
Definition
Array.h:43
fbcpp::request::Request::MessageEntry
Associates a message number declared in the BLR with its format.
Definition
Request.h:74
fbcpp::request::Request::MessageEntry::format
RequestMessageFormat format
The message format.
Definition
Request.h:83
fbcpp::request::Request::MessageEntry::messageNumber
unsigned messageNumber
The message number, between 0 and 255.
Definition
Request.h:78
src
fb-cpp
request
Request.h
Generated by
1.9.8