TupleDescriptor.h 755 B

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