AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
ASqlDatabase.h
    1/*
    2 * AUI Framework - Declarative UI toolkit for modern C++20
    3 * Copyright (C) 2020-2025 Alex2772 and Contributors
    4 *
    5 * SPDX-License-Identifier: MPL-2.0
    6 *
    7 * This Source Code Form is subject to the terms of the Mozilla Public
    8 * License, v. 2.0. If a copy of the MPL was not distributed with this
    9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
   10 */
   11
   12#pragma once
   13
   14#include <AUI/Data.h>
   15#include "AUI/Common/SharedPtrTypes.h"
   16#include "AUI/Common/AMap.h"
   17#include "ISqlDriver.h"
   18#include "AUI/Common/AVector.h"
   19#include "AUI/Common/AVariant.h"
   20#include "ASqlQueryResult.h"
   21#include "ASqlDriverType.h"
   22
   23class AString;
   24
   25class API_AUI_DATA ASqlDatabase
   26{
   27private:
   28    static AMap<AString, _<ISqlDriver>>& getDrivers();
   29
   30    _<ISqlDatabase> mDriverInterface;
   31
   32    explicit ASqlDatabase(const _<ISqlDatabase>& driver_interface, const AString& driverName)
   33        : mDriverInterface(driver_interface)
   34    {
   35    }
   36
   37public:
   38    ~ASqlDatabase();
   39
   48    _<ASqlQueryResult> query(const AString& query, const AVector<AVariant>& params = {});
   49
   58    int execute(const AString& query, const AVector<AVariant>& params = {});
   59
   60
   75    static _<ASqlDatabase> connect(const AString& driverName, const AString& address, uint16_t port = 0,
   76                                   const AString& databaseName = {}, const AString& username = {},
   77                                   const AString& password = {});
   78
   83    SqlDriverType getDriverType();
   84
   85    static void registerDriver(_<ISqlDriver> driver);
   86};
A std::map with AUI extensions.
Definition AMap.h:218
int execute(const AString &query, const AVector< AVariant > &params={})
Execute a query with no result (UPDATE, INSERT, DELETE, etc.)
static _< ASqlDatabase > connect(const AString &driverName, const AString &address, uint16_t port=0, const AString &databaseName={}, const AString &username={}, const AString &password={})
Connect to the database using the specified details and driver.
_< ASqlQueryResult > query(const AString &query, const AVector< AVariant > &params={})
Execute a query with the result (SELECT).
SqlDriverType getDriverType()
the type of the driver. Required to correct queries in the database due to driver differences.
Represents a Unicode character string.
Definition AString.h:38
A std::vector with AUI extensions.
Definition AVector.h:39
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:179