Serenity Operating System
1/*
2 * Copyright (c) 2022, Jan de Visser <jan@de-visser.net>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#pragma once
8
9#include <AK/Vector.h>
10#include <LibSQL/Result.h>
11#include <LibSQL/Tuple.h>
12#include <LibSQL/Type.h>
13
14namespace SQL {
15
16struct ResultRow {
17 Tuple row;
18 Tuple sort_key;
19};
20
21class ResultSet : public Vector<ResultRow> {
22public:
23 ALWAYS_INLINE ResultSet(SQLCommand command)
24 : m_command(command)
25 {
26 }
27
28 ALWAYS_INLINE ResultSet(SQLCommand command, Vector<DeprecatedString> column_names)
29 : m_command(command)
30 , m_column_names(move(column_names))
31 {
32 }
33
34 SQLCommand command() const { return m_command; }
35 Vector<DeprecatedString> const& column_names() const { return m_column_names; }
36
37 void insert_row(Tuple const& row, Tuple const& sort_key);
38 void limit(size_t offset, size_t limit);
39
40private:
41 size_t binary_search(Tuple const& sort_key, size_t low, size_t high);
42
43 SQLCommand m_command { SQLCommand::Unknown };
44 Vector<DeprecatedString> m_column_names;
45};
46
47}