TupleDescriptor.h 793 B

123456789101112131415161718192021222324252627282930313233343536373839
  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/Vector.h>
  8. #include <LibSQL/AST/AST.h>
  9. #include <LibSQL/Type.h>
  10. namespace SQL {
  11. struct TupleElement {
  12. String name { "" };
  13. SQLType type { SQLType::Text };
  14. AST::Order order { AST::Order::Ascending };
  15. bool operator==(TupleElement const&) const = default;
  16. };
  17. class TupleDescriptor : public Vector<TupleElement> {
  18. public:
  19. TupleDescriptor() = default;
  20. TupleDescriptor(TupleDescriptor const&) = default;
  21. ~TupleDescriptor() = default;
  22. [[nodiscard]] size_t data_length() const
  23. {
  24. size_t sz = sizeof(u32);
  25. for (auto& part : *this) {
  26. sz += size_of(part.type);
  27. }
  28. return sz;
  29. }
  30. };
  31. }