1#include "duckdb/parser/parsed_data/attach_info.hpp"
2#include "duckdb/common/field_writer.hpp"
3
4namespace duckdb {
5
6unique_ptr<AttachInfo> AttachInfo::Copy() const {
7 auto result = make_uniq<AttachInfo>();
8 result->name = name;
9 result->path = path;
10 result->options = options;
11 return result;
12}
13
14void AttachInfo::Serialize(Serializer &main_serializer) const {
15 FieldWriter writer(main_serializer);
16 writer.WriteString(val: name);
17 writer.WriteString(val: path);
18 writer.WriteField<uint32_t>(element: options.size());
19 auto &serializer = writer.GetSerializer();
20 for (auto &kv : options) {
21 serializer.WriteString(val: kv.first);
22 kv.second.Serialize(serializer);
23 }
24 writer.Finalize();
25}
26
27unique_ptr<ParseInfo> AttachInfo::Deserialize(Deserializer &deserializer) {
28 FieldReader reader(deserializer);
29 auto attach_info = make_uniq<AttachInfo>();
30 attach_info->name = reader.ReadRequired<string>();
31 attach_info->path = reader.ReadRequired<string>();
32 auto default_attach_count = reader.ReadRequired<uint32_t>();
33 auto &source = reader.GetSource();
34 for (idx_t i = 0; i < default_attach_count; i++) {
35 auto name = source.Read<string>();
36 attach_info->options[name] = Value::Deserialize(source);
37 }
38 reader.Finalize();
39 return std::move(attach_info);
40}
41
42} // namespace duckdb
43