summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibSQL/Row.cpp
blob: bf3b549513c5b45d3fbb3cb504bce6112d56d7b0 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * Copyright (c) 2021, Jan de Visser <jan@de-visser.net>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <LibSQL/Meta.h>
#include <LibSQL/Row.h>
#include <LibSQL/Serializer.h>
#include <LibSQL/Tuple.h>

namespace SQL {

Row::Row()
    : Tuple()
{
}

Row::Row(TupleDescriptor const& descriptor)
    : Tuple(descriptor)
{
}

Row::Row(RefPtr<TableDef> table, u32 pointer)
    : Tuple(table->to_tuple_descriptor())
    , m_table(table)
{
    set_pointer(pointer);
}

Row::Row(RefPtr<TableDef> table, u32 pointer, Serializer& serializer)
    : Row(move(table), pointer)
{
    Row::deserialize(serializer);
}

void Row::deserialize(Serializer& serializer)
{
    Tuple::deserialize(serializer);
    m_next_pointer = serializer.deserialize<u32>();
}

void Row::serialize(Serializer& serializer) const
{
    Tuple::serialize(serializer);
    serializer.serialize<u32>(next_pointer());
}

void Row::copy_from(Row const& other)
{
    Tuple::copy_from(other);
    m_next_pointer = other.next_pointer();
}

}