ladybird/Userland/Libraries/LibSQL/Row.h
Ben Wiederhake 9d89b64d59 LibSQL: Resolve cyclic dependency
Previously, class SQL::Key
depends on def class SQL::IndexDef (because inline def index())
depends on def class SQL::KeyPartDef (inline def key_definition())
depends on def class SQL::ColumnDef (because base class)
depends on def class SQL::Relation (because base class)
depends on def class SQL::Key (because inline def hash()).

This hasn't caused any problems so far because Meta.h happened to be
always included after Key.h (in part due to alphabetical ordering).

However, a compilation that for example only contains
    #include <Userland/Libraries/LibSQL/Key.h>
would fail to compile.

This patch resolves this issue by pushing the inline definition of
SQL::Relation::hash() into a different file. Yes, this might reduce
performance marginally, but this gets it to compile again.
2021-10-06 23:52:40 +01:00

51 lines
1.4 KiB
C++

/*
* Copyright (c) 2021, Jan de Visser <jan@de-visser.net>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/RefPtr.h>
#include <LibSQL/Forward.h>
#include <LibSQL/Meta.h>
#include <LibSQL/Tuple.h>
#include <LibSQL/Value.h>
namespace SQL {
/**
* A Tuple is an element of a sequential-access persistence data structure
* like a flat table. Like a key it has a definition for all its parts,
* but unlike a key this definition is not optional.
*
* FIXME Tuples should logically belong to a TupleStore object, but right now
* they stand by themselves; they contain a row's worth of data and a pointer
* to the next Tuple.
*/
class Row : public Tuple {
public:
Row();
explicit Row(TupleDescriptor const&);
explicit Row(RefPtr<TableDef>, u32 pointer = 0);
Row(RefPtr<TableDef>, u32, Serializer&);
Row(Row const&) = default;
virtual ~Row() override = default;
[[nodiscard]] u32 next_pointer() const { return m_next_pointer; }
void next_pointer(u32 ptr) { m_next_pointer = ptr; }
RefPtr<TableDef> table() const { 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;
protected:
void copy_from(Row const&);
private:
RefPtr<TableDef> m_table;
u32 m_next_pointer { 0 };
};
}