summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibSQL/TupleDescriptor.h
blob: c95dcfcb074a5577630bce2e6a4a46b9c2fe05a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * Copyright (c) 2021, Jan de Visser <jan@de-visser.net>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Vector.h>
#include <LibSQL/AST/AST.h>
#include <LibSQL/Type.h>

namespace SQL {

struct TupleElement {
    String name { "" };
    SQLType type { SQLType::Text };
    AST::Order order { AST::Order::Ascending };

    bool operator==(TupleElement const&) const = default;
};

class TupleDescriptor : public Vector<TupleElement> {
public:
    TupleDescriptor() = default;
    TupleDescriptor(TupleDescriptor const&) = default;
    ~TupleDescriptor() = default;

    [[nodiscard]] size_t data_length() const
    {
        size_t sz = sizeof(u32);
        for (auto& part : *this) {
            sz += size_of(part.type);
        }
        return sz;
    }
};

}