/* * Copyright (c) 2021, Jan de Visser * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include namespace SQLServer { class SQLStatement final : public Core::Object { C_OBJECT(SQLStatement) public: ~SQLStatement() override = default; static RefPtr statement_for(int statement_id); int statement_id() const { return m_statement_id; } String const& sql() const { return m_sql; } DatabaseConnection* connection() { return dynamic_cast(parent()); } void execute(); private: SQLStatement(DatabaseConnection&, String sql); SQL::ResultOr parse(); bool should_send_result_rows() const; void next(); void report_error(SQL::Result); int m_statement_id; String m_sql; size_t m_index { 0 }; RefPtr m_statement { nullptr }; Optional m_result {}; }; }