1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:17:44 +00:00

LibSQL: Store a NonnullRefPtr to the table definition in SQL::Row

Also return a direct reference to the table from its getter.
This commit is contained in:
Timothy Flynn 2022-11-29 08:52:09 -05:00 committed by Linus Groh
parent 5336f23c7e
commit 6d3f68cc11
3 changed files with 13 additions and 12 deletions

View file

@ -6,8 +6,7 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/RefPtr.h>
#include <AK/NonnullRefPtr.h>
#include <LibSQL/Forward.h>
#include <LibSQL/Meta.h>
#include <LibSQL/Tuple.h>
@ -26,19 +25,21 @@ namespace SQL {
*/
class Row : public Tuple {
public:
explicit Row(RefPtr<TableDef>, u32 pointer = 0);
explicit Row(NonnullRefPtr<TableDef>, u32 pointer = 0);
virtual ~Row() override = default;
[[nodiscard]] u32 next_pointer() const { return m_next_pointer; }
void set_next_pointer(u32 ptr) { m_next_pointer = ptr; }
RefPtr<TableDef> table() const { return m_table; }
TableDef const& table() const { return *m_table; }
TableDef& table() { return *m_table; }
[[nodiscard]] virtual size_t length() const override { return Tuple::length() + sizeof(u32); }
virtual void serialize(Serializer&) const override;
virtual void deserialize(Serializer&) override;
private:
RefPtr<TableDef> m_table;
NonnullRefPtr<TableDef> m_table;
u32 m_next_pointer { 0 };
};