mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 07:07:23 +00:00
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
47 lines
1.2 KiB
C++
47 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/DeprecatedString.h>
|
|
#include <AK/NonnullRefPtr.h>
|
|
#include <LibCore/Object.h>
|
|
#include <LibSQL/AST/AST.h>
|
|
#include <LibSQL/Result.h>
|
|
#include <LibSQL/ResultSet.h>
|
|
#include <SQLServer/DatabaseConnection.h>
|
|
#include <SQLServer/Forward.h>
|
|
|
|
namespace SQLServer {
|
|
|
|
class SQLStatement final : public Core::Object {
|
|
C_OBJECT(SQLStatement)
|
|
|
|
public:
|
|
~SQLStatement() override = default;
|
|
|
|
static RefPtr<SQLStatement> statement_for(int statement_id);
|
|
int statement_id() const { return m_statement_id; }
|
|
DeprecatedString const& sql() const { return m_sql; }
|
|
DatabaseConnection* connection() { return dynamic_cast<DatabaseConnection*>(parent()); }
|
|
void execute();
|
|
|
|
private:
|
|
SQLStatement(DatabaseConnection&, DeprecatedString sql);
|
|
SQL::ResultOr<void> parse();
|
|
bool should_send_result_rows() const;
|
|
void next();
|
|
void report_error(SQL::Result);
|
|
|
|
int m_statement_id;
|
|
DeprecatedString m_sql;
|
|
size_t m_index { 0 };
|
|
RefPtr<SQL::AST::Statement> m_statement { nullptr };
|
|
Optional<SQL::ResultSet> m_result {};
|
|
};
|
|
|
|
}
|