/src/serenity/Userland/Libraries/LibSQL/Row.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2021, Jan de Visser <jan@de-visser.net> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <AK/NonnullRefPtr.h> |
10 | | #include <LibSQL/Forward.h> |
11 | | #include <LibSQL/Meta.h> |
12 | | #include <LibSQL/Tuple.h> |
13 | | #include <LibSQL/Value.h> |
14 | | |
15 | | namespace SQL { |
16 | | |
17 | | /** |
18 | | * A Tuple is an element of a sequential-access persistence data structure |
19 | | * like a flat table. Like a key it has a definition for all its parts, |
20 | | * but unlike a key this definition is not optional. |
21 | | * |
22 | | * FIXME Tuples should logically belong to a TupleStore object, but right now |
23 | | * they stand by themselves; they contain a row's worth of data and a pointer |
24 | | * to the next Tuple. |
25 | | */ |
26 | | class Row : public Tuple { |
27 | | public: |
28 | | explicit Row(NonnullRefPtr<TableDef>, Block::Index block_index = 0); |
29 | 0 | virtual ~Row() override = default; |
30 | | |
31 | 0 | [[nodiscard]] Block::Index next_block_index() const { return m_next_block_index; } |
32 | 0 | void set_next_block_index(Block::Index index) { m_next_block_index = index; } |
33 | | |
34 | 0 | TableDef const& table() const { return *m_table; } |
35 | 0 | TableDef& table() { return *m_table; } |
36 | | |
37 | 0 | [[nodiscard]] virtual size_t length() const override { return Tuple::length() + sizeof(Block::Index); } |
38 | | virtual void serialize(Serializer&) const override; |
39 | | virtual void deserialize(Serializer&) override; |
40 | | |
41 | | private: |
42 | | NonnullRefPtr<TableDef> m_table; |
43 | | Block::Index m_next_block_index { 0 }; |
44 | | }; |
45 | | |
46 | | } |