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

Represents a connection to a Firebird database. More...

#include <Attachment.h>

Public Member Functions

 Attachment (Client &client, const std::string &uri, const AttachmentOptions &options={})
 Constructs an Attachment object that connects to (or creates) the database specified by the URI using the specified Client object and options.
 
 Attachment (Attachment &&o) noexcept
 Move constructor.
 
Attachmentoperator= (Attachment &&o) noexcept
 Transfers ownership of another Attachment into this one.
 
 Attachment (const Attachment &)=delete
 
Attachmentoperator= (const Attachment &)=delete
 
 ~Attachment () noexcept
 Disconnects from the database.
 
bool isValid () noexcept
 Returns whether the Attachment object is valid.
 
ClientgetClient () noexcept
 Returns the Client object reference used to create this Attachment object.
 
FbRef< fb::IAttachment > getHandle () noexcept
 Returns the internal Firebird IAttachment handle.
 
void disconnect ()
 Disconnects from the database.
 
void dropDatabase ()
 Drops the database.
 
bool execute (Transaction &transaction, std::string_view sql, const StatementOptions &options={})
 Prepares and executes an SQL statement using the supplied transaction.
 
template<typename Params >
bool execute (Transaction &transaction, std::string_view sql, const Params &params)
 Prepares, binds parameters, and executes an SQL statement using the supplied transaction.
 
template<typename Params >
bool execute (Transaction &transaction, std::string_view sql, const StatementOptions &options, const Params &params)
 Prepares, binds parameters, and executes an SQL statement using the supplied transaction and statement options.
 
RowSet queryRowSet (Transaction &transaction, std::string_view sql, unsigned maxRows, const StatementOptions &options={})
 Prepares and executes a query using the supplied transaction and returns up to maxRows rows.
 
template<typename Params >
RowSet queryRowSet (Transaction &transaction, std::string_view sql, unsigned maxRows, const Params &params)
 Prepares, binds parameters, and executes a query using the supplied transaction and returns up to maxRows rows.
 
template<typename Params >
RowSet queryRowSet (Transaction &transaction, std::string_view sql, unsigned maxRows, const StatementOptions &options, const Params &params)
 Prepares, binds parameters, and executes a query using the supplied transaction and statement options and returns up to maxRows rows.
 
template<typename T >
std::optional< T > queryScalar (Transaction &transaction, std::string_view sql, const StatementOptions &options={})
 Prepares and executes a query using the supplied transaction and returns the first column of the first row.
 
template<typename T , typename Params >
std::optional< T > queryScalar (Transaction &transaction, std::string_view sql, const Params &params)
 Prepares, binds parameters, and executes a query using the supplied transaction and returns the first column of the first row.
 
template<typename T , typename Params >
std::optional< T > queryScalar (Transaction &transaction, std::string_view sql, const StatementOptions &options, const Params &params)
 Prepares, binds parameters, and executes a query using the supplied transaction and statement options and returns the first column of the first row.
 
template<typename T >
std::optional< T > queryFirstRowAs (Transaction &transaction, std::string_view sql, const StatementOptions &options={})
 Prepares and executes a query using the supplied transaction and returns the first row mapped as T.
 
template<typename T , typename Params >
std::optional< T > queryFirstRowAs (Transaction &transaction, std::string_view sql, const Params &params)
 Prepares, binds parameters, and executes a query using the supplied transaction and returns the first row mapped as T.
 
template<typename T , typename Params >
std::optional< T > queryFirstRowAs (Transaction &transaction, std::string_view sql, const StatementOptions &options, const Params &params)
 Prepares, binds parameters, and executes a query using the supplied transaction and statement options and returns the first row mapped as T.
 

Detailed Description

Represents a connection to a Firebird database.

The Attachment must exist and remain valid while there are other objects using it, such as Transaction and Statement.

Definition at line 217 of file Attachment.h.

Constructor & Destructor Documentation

◆ Attachment() [1/2]

Attachment::Attachment ( Client client,
const std::string &  uri,
const AttachmentOptions options = {} 
)
explicit

Constructs an Attachment object that connects to (or creates) the database specified by the URI using the specified Client object and options.

Definition at line 36 of file Attachment.cpp.

◆ Attachment() [2/2]

fbcpp::Attachment::Attachment ( Attachment &&  o)
inlinenoexcept

Move constructor.

A moved Attachment object becomes invalid.

Definition at line 230 of file Attachment.h.

◆ ~Attachment()

fbcpp::Attachment::~Attachment ( )
inlinenoexcept

Disconnects from the database.

Definition at line 259 of file Attachment.h.

Member Function Documentation

◆ disconnect()

void Attachment::disconnect ( )

Disconnects from the database.

Definition at line 90 of file Attachment.cpp.

◆ dropDatabase()

void Attachment::dropDatabase ( )

Drops the database.

Definition at line 95 of file Attachment.cpp.

◆ execute() [1/3]

template<typename Params >
bool fbcpp::Attachment::execute ( Transaction transaction,
std::string_view  sql,
const Params &  params 
)

Prepares, binds parameters, and executes an SQL statement using the supplied transaction.

Definition at line 432 of file Attachment.h.

◆ execute() [2/3]

template<typename Params >
bool fbcpp::Attachment::execute ( Transaction transaction,
std::string_view  sql,
const StatementOptions options,
const Params &  params 
)

Prepares, binds parameters, and executes an SQL statement using the supplied transaction and statement options.

Definition at line 438 of file Attachment.h.

◆ execute() [3/3]

bool Attachment::execute ( Transaction transaction,
std::string_view  sql,
const StatementOptions options = {} 
)

Prepares and executes an SQL statement using the supplied transaction.

Definition at line 100 of file Attachment.cpp.

◆ getClient()

Client & fbcpp::Attachment::getClient ( )
inlinenoexcept

Returns the Client object reference used to create this Attachment object.

Definition at line 286 of file Attachment.h.

◆ getHandle()

FbRef< fb::IAttachment > fbcpp::Attachment::getHandle ( )
inlinenoexcept

Returns the internal Firebird IAttachment handle.

Definition at line 294 of file Attachment.h.

◆ isValid()

bool fbcpp::Attachment::isValid ( )
inlinenoexcept

Returns whether the Attachment object is valid.

Definition at line 278 of file Attachment.h.

◆ operator=()

Attachment & fbcpp::Attachment::operator= ( Attachment &&  o)
inlinenoexcept

Transfers ownership of another Attachment into this one.

The old handle is released via FbRef::operator=(FbRef&&). After the assignment, this is valid (with o's handle) and o is invalid.

Definition at line 242 of file Attachment.h.

◆ queryFirstRowAs() [1/3]

template<typename T , typename Params >
std::optional< T > fbcpp::Attachment::queryFirstRowAs ( Transaction transaction,
std::string_view  sql,
const Params &  params 
)

Prepares, binds parameters, and executes a query using the supplied transaction and returns the first row mapped as T.

Definition at line 486 of file Attachment.h.

◆ queryFirstRowAs() [2/3]

template<typename T , typename Params >
std::optional< T > fbcpp::Attachment::queryFirstRowAs ( Transaction transaction,
std::string_view  sql,
const StatementOptions options,
const Params &  params 
)

Prepares, binds parameters, and executes a query using the supplied transaction and statement options and returns the first row mapped as T.

Definition at line 497 of file Attachment.h.

◆ queryFirstRowAs() [3/3]

template<typename T >
std::optional< T > fbcpp::Attachment::queryFirstRowAs ( Transaction transaction,
std::string_view  sql,
const StatementOptions options = {} 
)

Prepares and executes a query using the supplied transaction and returns the first row mapped as T.

Definition at line 415 of file Attachment.h.

◆ queryRowSet() [1/3]

template<typename Params >
RowSet fbcpp::Attachment::queryRowSet ( Transaction transaction,
std::string_view  sql,
unsigned  maxRows,
const Params &  params 
)

Prepares, binds parameters, and executes a query using the supplied transaction and returns up to maxRows rows.

Definition at line 447 of file Attachment.h.

◆ queryRowSet() [2/3]

template<typename Params >
RowSet fbcpp::Attachment::queryRowSet ( Transaction transaction,
std::string_view  sql,
unsigned  maxRows,
const StatementOptions options,
const Params &  params 
)

Prepares, binds parameters, and executes a query using the supplied transaction and statement options and returns up to maxRows rows.

Definition at line 454 of file Attachment.h.

◆ queryRowSet() [3/3]

RowSet Attachment::queryRowSet ( Transaction transaction,
std::string_view  sql,
unsigned  maxRows,
const StatementOptions options = {} 
)

Prepares and executes a query using the supplied transaction and returns up to maxRows rows.

Definition at line 106 of file Attachment.cpp.

◆ queryScalar() [1/3]

template<typename T , typename Params >
std::optional< T > fbcpp::Attachment::queryScalar ( Transaction transaction,
std::string_view  sql,
const Params &  params 
)

Prepares, binds parameters, and executes a query using the supplied transaction and returns the first column of the first row.

Definition at line 463 of file Attachment.h.

◆ queryScalar() [2/3]

template<typename T , typename Params >
std::optional< T > fbcpp::Attachment::queryScalar ( Transaction transaction,
std::string_view  sql,
const StatementOptions options,
const Params &  params 
)

Prepares, binds parameters, and executes a query using the supplied transaction and statement options and returns the first column of the first row.

Definition at line 474 of file Attachment.h.

◆ queryScalar() [3/3]

template<typename T >
std::optional< T > fbcpp::Attachment::queryScalar ( Transaction transaction,
std::string_view  sql,
const StatementOptions options = {} 
)

Prepares and executes a query using the supplied transaction and returns the first column of the first row.

Definition at line 403 of file Attachment.h.


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