Key.h 750 B

123456789101112131415161718192021222324252627282930
  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/RefPtr.h>
  8. #include <LibSQL/Forward.h>
  9. #include <LibSQL/Tuple.h>
  10. namespace SQL {
  11. class Key : public Tuple {
  12. public:
  13. Key();
  14. explicit Key(NonnullRefPtr<TupleDescriptor> const&);
  15. explicit Key(NonnullRefPtr<IndexDef>);
  16. Key(NonnullRefPtr<TupleDescriptor> const&, ByteBuffer&, size_t& offset);
  17. Key(RefPtr<IndexDef>, ByteBuffer&, size_t& offset);
  18. Key(Key const&) = default;
  19. RefPtr<IndexDef> index() const { return m_index; }
  20. [[nodiscard]] virtual size_t data_length() const override { return Tuple::data_length() + sizeof(u32); }
  21. private:
  22. RefPtr<IndexDef> m_index { nullptr };
  23. };
  24. }