Serenity Operating System
1/*
2 * Copyright (c) 2021, Jan de Visser <jan@de-visser.net>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#include <LibSQL/Serializer.h>
8
9namespace SQL {
10
11void Serializer::serialize(DeprecatedString const& text)
12{
13 serialize<u32>((u32)text.length());
14 if (!text.is_empty())
15 write((u8 const*)text.characters(), text.length());
16}
17
18void Serializer::deserialize_to(DeprecatedString& text)
19{
20 auto length = deserialize<u32>();
21 if (length > 0) {
22 text = DeprecatedString(reinterpret_cast<char const*>(read(length)), length);
23 } else {
24 text = "";
25 }
26}
27
28}