fb-cpp 0.0.1
A modern C++ wrapper for the Firebird database API
Loading...
Searching...
No Matches
fb-cpp

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"
using namespace fbcpp;
// Create a client
Client client{"fbclient"};
// Connect to a database
const auto attachmentOptions = AttachmentOptions()
Attachment attachment{client, "localhost:database.fdb", attachmentOptions};
// Start a transaction
const auto transactionOptions = TransactionOptions()
.setIsolationLevel(TransactionIsolationLevel::READ_COMMITTED);
Transaction transaction{attachment, transactionOptions};
// Prepare a statement
Statement statement{attachment, transaction, "select id, name from users where id = ?"};
// Set parameters
statement.setInt32(0, 42);
/* Or
statement.set(0, 42);
*/
// Execute and get results
statement.execute(transaction);
// Process results...
do
{
const std::optional<std::int32_t> id = statement.getInt32(0);
const std::optional<std::string> name = statement.getString(1);
/* Or
const auto id = statement.get<std::int32_t>(0);
const auto name = statement.get<std::string>(1);
*/
} while (statement.fetchNext());
// Commit transaction
transaction.commit();
Represents options used when creating an Attachment object.
Definition Attachment.h:49
AttachmentOptions & setConnectionCharSet(const std::string &value)
Sets the character set which will be used for the connection.
Definition Attachment.h:62
Represents a connection to a Firebird database.
Definition Attachment.h:177
Represents a Firebird client library instance.
Definition Client.h:53
Prepares, executes, and fetches SQL statements against a Firebird attachment.
Definition Statement.h:183
void setInt32(unsigned index, std::optional< std::int32_t > optValue)
Binds a 32-bit signed integer value or null.
Definition Statement.h:480
Represents options used when creating a Transaction object.
Definition Transaction.h:87
TransactionOptions & setIsolationLevel(TransactionIsolationLevel value)
Sets the transaction isolation level.
Represents a transaction in a Firebird database.
fb-cpp namespace.
Definition Attachment.h:42

Building

This project uses CMake with vcpkg for dependency management.

# Clone the repository
git clone --recursive-submodules https://github.com/asfernandes/fb-cpp.git
# Configure
cmake -S . -B build/Release -DCMAKE_BUILD_TYPE=Release
# Build
cmake --build build/Release
# Install
cmake --install build/Release
# Generate documentation
cmake --build build/Release --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.