Serenity Operating System
at master 46 lines 1.3 kB view raw
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 15namespace 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 */ 26class Row : public Tuple { 27public: 28 explicit Row(NonnullRefPtr<TableDef>, u32 pointer = 0); 29 virtual ~Row() override = default; 30 31 [[nodiscard]] u32 next_pointer() const { return m_next_pointer; } 32 void set_next_pointer(u32 ptr) { m_next_pointer = ptr; } 33 34 TableDef const& table() const { return *m_table; } 35 TableDef& table() { return *m_table; } 36 37 [[nodiscard]] virtual size_t length() const override { return Tuple::length() + sizeof(u32); } 38 virtual void serialize(Serializer&) const override; 39 virtual void deserialize(Serializer&) override; 40 41private: 42 NonnullRefPtr<TableDef> m_table; 43 u32 m_next_pointer { 0 }; 44}; 45 46}