A modern C++ wrapper for the Firebird database API.
Documentation | Repository
Overview
fb-cpp provides a clean, modern C++ interface to the Firebird database engine. It wraps the Firebird C++ API with RAII principles, smart pointers, and modern C++ features.
Features
- Modern C++: Uses C++20 features for type safety and performance
- RAII: Automatic resource management with smart pointers
- Type Safety: Strong typing for database operations
- Exception Safety: Proper error handling with exceptions
- Boost Integration: Optional Boost.DLL for loading fbclient and Boost.Multiprecision support for large numbers
Quick Start
#include "fb-cpp/fb-cpp.h"
Attachment attachment{client,
"localhost:database.fdb", attachmentOptions};
Transaction transaction{attachment, transactionOptions};
Statement statement{attachment, transaction,
"select id, name from users where id = ?"};
if (statement.execute(transaction))
{
do
{
const std::optional<std::int32_t> id = statement.getInt32(0);
const std::optional<std::string> name = statement.getString(1);
} while (statement.fetchNext());
}
transaction.commit();
Represents options used when creating an Attachment object.
AttachmentOptions & setConnectionCharSet(const std::string &value)
Sets the character set which will be used for the connection.
Represents a connection to a Firebird database.
Represents a Firebird client library instance.
Prepares, executes, and fetches SQL statements against a Firebird attachment.
void setInt32(unsigned index, std::optional< std::int32_t > optValue)
Binds a 32-bit signed integer value or null.
Represents options used when creating a Transaction object.
TransactionOptions & setIsolationLevel(TransactionIsolationLevel value)
Sets the transaction isolation level.
Represents a transaction in a Firebird database.
Using with vcpkg
This library is present in firebird-vcpkg-registry.
To install, add the registry or overlay to your vcpkg configuration and install the fb-cpp package:
Or add it to your vcpkg.json manifest:
{
...
"dependencies": [
{
"name": "fb-cpp",
"default-features": true
}
]
}
The default features are:
boost-dll: Enable Boost.DLL support for runtime dynamic loading of Firebird client library
boost-multiprecision: Enable Boost.Multiprecision support for INT128 and DECFLOAT types
Building
This project uses CMake presets (CMakePresets.json) and vcpkg for dependency management.
Copy the appropriate CMakeUserPresets.json.<platform>.template file to CMakeUserPresets.json to set environment variables for tests and define the default preset.
# Configure
cmake --preset default
# Build
cmake --build --preset default
# Run tests
ctest --preset default
# Build docs
cmake --build --preset default --target docs
Documentation
The complete API documentation is available in the build doc/docs/ directory after building with the docs target.
License
MIT License - see LICENSE.md for details.
Donation
If this project help you reduce time to develop, you can show your appreciation with a donation.