mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-21 17:10:35 +00:00
In these changes, we describe the purpose of the type and make it reusable for other parts of the code. That includes ditching the existing constructors, leaving the formatting of its fields to the user of the interface. The removed constructors have been replaced by free functions so that existing code can still use them the way it did before.
44 lines
1.0 KiB
C++
44 lines
1.0 KiB
C++
/*
|
|
* Copyright (C) 2024-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#include "cql3/description.hh"
|
|
|
|
#include <seastar/core/on_internal_error.hh>
|
|
|
|
#include "cql3/util.hh"
|
|
#include "log.hh"
|
|
#include "types/types.hh"
|
|
|
|
static logging::logger dlogger{"description"};
|
|
|
|
namespace cql3 {
|
|
|
|
std::vector<bytes_opt> description::serialize(bool serialize_create_statement) const {
|
|
std::vector<bytes_opt> result{};
|
|
result.reserve(serialize_create_statement ? 4 : 3);
|
|
|
|
if (keyspace) {
|
|
result.push_back(to_bytes(cql3::util::maybe_quote(*keyspace)));
|
|
} else {
|
|
result.push_back(data_value::make_null(utf8_type).serialize());
|
|
}
|
|
|
|
result.push_back(to_bytes(type));
|
|
result.push_back(to_bytes(cql3::util::maybe_quote(name)));
|
|
|
|
if (serialize_create_statement && create_statement) {
|
|
result.push_back(to_bytes(*create_statement));
|
|
} else if (serialize_create_statement) {
|
|
on_internal_error(dlogger, "create_statement field is empty");
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
} // namespace cql3
|