#include <vendor/nlohmann/json.hpp>
#include <algorithm>
+#include <utility>
namespace lsc = lttng::sessiond::ctf2;
namespace lst = lttng::sessiond::trace;
namespace ctf2 {
class trace_environment_visitor : public lst::trace_class_environment_visitor {
public:
- trace_environment_visitor()
- {
- }
+ trace_environment_visitor() = default; /* NOLINT clang-tidy 14 identifies this as a move
+ constructor. */
- virtual void visit(const lst::environment_field<int64_t>& field) override
+ void visit(const lst::environment_field<int64_t>& field) override
{
_visit(field);
}
- virtual void visit(const lst::environment_field<const char *>& field) override
+ void visit(const lst::environment_field<const char *>& field) override
{
_visit(field);
}
class field_visitor : public lttng::sessiond::trace::field_visitor,
public lttng::sessiond::trace::type_visitor {
public:
- field_visitor()
- {
- }
+ field_visitor() = default; /* NOLINT clang-tidy 14 identifies this as a move constructor. */
/* Only call once. */
json::json move_fragment()
}
private:
- virtual void visit(const lst::field& field) override final
+ void visit(const lst::field& field) final
{
field_visitor field_type_visitor;
field.get_type().accept(field_type_visitor);
_fragment["field-class"] = field_type_visitor.move_fragment();
}
- virtual void visit(const lst::integer_type& type) override final
+ void visit(const lst::integer_type& type) final
{
_fragment["type"] = type.signedness_ == lst::integer_type::signedness::SIGNED ?
"fixed-length-signed-integer" :
_fragment["alignment"] = type.alignment;
_fragment["preferred-display-base"] = (unsigned int) type.base_;
- if (type.roles_.size() > 0) {
+ if (!type.roles_.empty()) {
json::json role_array = json::json::array();
for (const auto role : type.roles_) {
}
}
- virtual void visit(const lst::floating_point_type& type) override final
+ void visit(const lst::floating_point_type& type) final
{
_fragment["type"] = "fixed-length-floating-point-number";
_fragment["length"] = type.exponent_digits + type.mantissa_digits;
_fragment["alignment"] = type.alignment;
_fragment["preferred-display-base"] = (unsigned int) type.base_;
- if (type.roles_.size() > 0) {
+ if (!type.roles_.empty()) {
if (std::is_signed<typename EnumerationType::mapping::range_t::
range_integer_t>::value) {
LTTNG_THROW_ERROR(
- fmt::format("Failed to serialize {}: unexpected role",
- _fragment["type"]));
+ lttng::format("Failed to serialize {}: unexpected role",
+ _fragment["type"]));
}
auto role_array = json::json::array();
}
if (type.mappings_->size() < 1) {
- LTTNG_THROW_ERROR(fmt::format(
+ LTTNG_THROW_ERROR(lttng::format(
"Failed to serialize {}: enumeration must have at least one mapping",
_fragment["type"]));
}
_fragment["mappings"] = std::move(mappings_value);
}
- virtual void visit(const lst::signed_enumeration_type& type) override final
+ void visit(const lst::signed_enumeration_type& type) final
{
visit_enumeration(type);
}
- virtual void visit(const lst::unsigned_enumeration_type& type) override final
+ void visit(const lst::unsigned_enumeration_type& type) final
{
visit_enumeration(type);
}
- virtual void visit(const lst::static_length_array_type& type) override final
+ void visit(const lst::static_length_array_type& type) final
{
_fragment["type"] = "static-length-array";
_fragment["length"] = type.length;
}
- virtual void visit(const lst::dynamic_length_array_type& type) override final
+ void visit(const lst::dynamic_length_array_type& type) final
{
_fragment["type"] = "dynamic-length-array";
_fragment["length-field-location"] = to_json(type.length_field_location);
}
- virtual void visit(const lst::static_length_blob_type& type) override final
+ void visit(const lst::static_length_blob_type& type) final
{
_fragment["type"] = "static-length-blob";
_fragment["length"] = type.length_bytes;
- if (type.roles_.size() > 0) {
+ if (!type.roles_.empty()) {
auto role_array = json::json::array();
for (const auto role : type.roles_) {
}
}
- virtual void visit(const lst::dynamic_length_blob_type& type) override final
+ void visit(const lst::dynamic_length_blob_type& type) final
{
_fragment["type"] = "dynamic-length-blob";
_fragment["length-field-location"] = to_json(type.length_field_location);
}
- virtual void visit(const lst::null_terminated_string_type& type
- __attribute__((unused))) override final
+ void visit(const lst::null_terminated_string_type& type __attribute__((unused))) final
{
_fragment["type"] = "null-terminated-string";
}
- virtual void visit(const lst::structure_type& type) override final
+ void visit(const lst::structure_type& type) final
{
_fragment["type"] = "structure";
_fragment["options"] = std::move(options_value);
}
- virtual void visit(const lst::variant_type<int64_t>& type) override final
+ void visit(const lst::variant_type<int64_t>& type) final
{
visit_variant(type);
}
- virtual void visit(const lst::variant_type<uint64_t>& type) override final
+ void visit(const lst::variant_type<uint64_t>& type) final
{
visit_variant(type);
}
- virtual void visit(const lst::static_length_string_type& type) override final
+ void visit(const lst::static_length_string_type& type) final
{
_fragment["type"] = "static-length-string";
_fragment["length"] = type.length;
}
- virtual void visit(const lst::dynamic_length_string_type& type) override final
+ void visit(const lst::dynamic_length_string_type& type) final
{
_fragment["type"] = "dynamic-length-string";
_fragment["length-field-location"] = to_json(type.length_field_location);
lsc::trace_class_visitor::trace_class_visitor(
lsc::append_metadata_fragment_function append_metadata_fragment) :
- _append_metadata_fragment(append_metadata_fragment)
+ _append_metadata_fragment(std::move(append_metadata_fragment))
{
}