ResultSet.h 745 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2022, Jan de Visser <jan@de-visser.net>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Vector.h>
  8. #include <LibSQL/Result.h>
  9. #include <LibSQL/Tuple.h>
  10. #include <LibSQL/Type.h>
  11. namespace SQL {
  12. struct ResultRow {
  13. Tuple row;
  14. Tuple sort_key;
  15. };
  16. class ResultSet : public Vector<ResultRow> {
  17. public:
  18. ALWAYS_INLINE ResultSet(SQLCommand command)
  19. : m_command(command)
  20. {
  21. }
  22. SQLCommand command() const { return m_command; }
  23. void insert_row(Tuple const& row, Tuple const& sort_key);
  24. void limit(size_t offset, size_t limit);
  25. private:
  26. size_t binary_search(Tuple const& sort_key, size_t low, size_t high);
  27. SQLCommand m_command { SQLCommand::Unknown };
  28. };
  29. }