Row.h 1.3 KB

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