mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:34:59 +00:00

This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2021, Jan de Visser <jan@de-visser.net>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/NonnullRefPtr.h>
|
|
#include <AK/RefCounted.h>
|
|
#include <LibSQL/Database.h>
|
|
#include <LibSQL/Result.h>
|
|
#include <LibSQL/Type.h>
|
|
#include <SQLServer/Forward.h>
|
|
|
|
namespace SQLServer {
|
|
|
|
class DatabaseConnection final : public RefCounted<DatabaseConnection> {
|
|
public:
|
|
static ErrorOr<NonnullRefPtr<DatabaseConnection>> create(StringView database_path, ByteString database_name, int client_id);
|
|
|
|
static RefPtr<DatabaseConnection> connection_for(SQL::ConnectionID connection_id);
|
|
SQL::ConnectionID connection_id() const { return m_connection_id; }
|
|
int client_id() const { return m_client_id; }
|
|
NonnullRefPtr<SQL::Database> database() { return m_database; }
|
|
StringView database_name() const { return m_database_name; }
|
|
void disconnect();
|
|
SQL::ResultOr<SQL::StatementID> prepare_statement(StringView sql);
|
|
|
|
private:
|
|
DatabaseConnection(NonnullRefPtr<SQL::Database> database, ByteString database_name, int client_id);
|
|
|
|
NonnullRefPtr<SQL::Database> m_database;
|
|
ByteString m_database_name;
|
|
SQL::ConnectionID m_connection_id { 0 };
|
|
int m_client_id { 0 };
|
|
};
|
|
|
|
}
|