| 1 | /* |
| 2 | * Copyright (C) 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0-only |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef LTTNG_FIELD_H |
| 9 | #define LTTNG_FIELD_H |
| 10 | |
| 11 | #include <common/format.hpp> |
| 12 | #include <common/make-unique.hpp> |
| 13 | |
| 14 | #include <vendor/optional.hpp> |
| 15 | |
| 16 | #include <algorithm> |
| 17 | #include <memory> |
| 18 | #include <string> |
| 19 | #include <type_traits> |
| 20 | #include <vector> |
| 21 | |
| 22 | namespace lttng { |
| 23 | namespace sessiond { |
| 24 | namespace trace { |
| 25 | |
| 26 | class field_visitor; |
| 27 | class type_visitor; |
| 28 | |
| 29 | enum class byte_order { |
| 30 | BIG_ENDIAN_, |
| 31 | LITTLE_ENDIAN_, |
| 32 | }; |
| 33 | |
| 34 | class field_location { |
| 35 | public: |
| 36 | enum class root { |
| 37 | PACKET_HEADER, |
| 38 | PACKET_CONTEXT, |
| 39 | EVENT_RECORD_HEADER, |
| 40 | EVENT_RECORD_COMMON_CONTEXT, |
| 41 | EVENT_RECORD_SPECIFIC_CONTEXT, |
| 42 | EVENT_RECORD_PAYLOAD, |
| 43 | }; |
| 44 | |
| 45 | using elements = std::vector<std::string>; |
| 46 | |
| 47 | field_location(root lookup_root, elements elements); |
| 48 | bool operator==(const field_location& other) const noexcept; |
| 49 | |
| 50 | const root root_; |
| 51 | const elements elements_; |
| 52 | }; |
| 53 | |
| 54 | /* |
| 55 | * Field, and the various field types, represents fields as exposed by the |
| 56 | * LTTng tracers. These classes do not attempt to describe the complete spectrum of the CTF |
| 57 | * specification. |
| 58 | */ |
| 59 | |
| 60 | class type { |
| 61 | public: |
| 62 | using cuptr = std::unique_ptr<const type>; |
| 63 | |
| 64 | static byte_order reverse_byte_order(byte_order byte_order) noexcept; |
| 65 | |
| 66 | bool operator==(const type& other) const noexcept; |
| 67 | bool operator!=(const type& other) const noexcept; |
| 68 | virtual ~type(); |
| 69 | |
| 70 | /* Obtain an independent copy of `type`. */ |
| 71 | virtual type::cuptr copy() const = 0; |
| 72 | |
| 73 | virtual void accept(type_visitor& visitor) const = 0; |
| 74 | |
| 75 | const unsigned int alignment; |
| 76 | |
| 77 | protected: |
| 78 | explicit type(unsigned int alignment); |
| 79 | |
| 80 | private: |
| 81 | virtual bool _is_equal(const type& rhs) const noexcept = 0; |
| 82 | }; |
| 83 | |
| 84 | class field { |
| 85 | public: |
| 86 | using uptr = std::unique_ptr<field>; |
| 87 | using cuptr = std::unique_ptr<const field>; |
| 88 | |
| 89 | field(std::string name, type::cuptr type); |
| 90 | void accept(field_visitor& visitor) const; |
| 91 | bool operator==(const field& other) const noexcept; |
| 92 | |
| 93 | const type& get_type() const; |
| 94 | type::cuptr move_type() noexcept; |
| 95 | |
| 96 | const std::string name; |
| 97 | |
| 98 | private: |
| 99 | type::cuptr _type; |
| 100 | }; |
| 101 | |
| 102 | class integer_type : public type { |
| 103 | public: |
| 104 | enum class signedness { |
| 105 | SIGNED, |
| 106 | UNSIGNED, |
| 107 | }; |
| 108 | |
| 109 | enum class base { |
| 110 | BINARY = 2, |
| 111 | OCTAL = 8, |
| 112 | DECIMAL = 10, |
| 113 | HEXADECIMAL = 16, |
| 114 | }; |
| 115 | |
| 116 | enum class role { |
| 117 | DEFAULT_CLOCK_TIMESTAMP, |
| 118 | /* Packet header field class specific roles. */ |
| 119 | DATA_STREAM_CLASS_ID, |
| 120 | DATA_STREAM_ID, |
| 121 | PACKET_MAGIC_NUMBER, |
| 122 | /* Packet context field class specific roles. */ |
| 123 | DISCARDED_EVENT_RECORD_COUNTER_SNAPSHOT, |
| 124 | PACKET_CONTENT_LENGTH, |
| 125 | PACKET_END_DEFAULT_CLOCK_TIMESTAMP, |
| 126 | PACKET_SEQUENCE_NUMBER, |
| 127 | PACKET_TOTAL_LENGTH, |
| 128 | /* Event record field class roles. */ |
| 129 | EVENT_RECORD_CLASS_ID, |
| 130 | }; |
| 131 | |
| 132 | using roles = std::vector<role>; |
| 133 | |
| 134 | integer_type(unsigned int alignment, |
| 135 | byte_order byte_order, |
| 136 | unsigned int size, |
| 137 | signedness signedness, |
| 138 | base base, |
| 139 | roles roles = {}); |
| 140 | |
| 141 | type::cuptr copy() const override; |
| 142 | |
| 143 | void accept(type_visitor& visitor) const override; |
| 144 | |
| 145 | const enum byte_order byte_order; |
| 146 | const unsigned int size; |
| 147 | /* |
| 148 | * signedness and base are suffixed with '_' to work-around a bug in older |
| 149 | * GCCs (before 6) that do not recognize hidden/shadowed enumeration as valid |
| 150 | * nested-name-specifiers. |
| 151 | */ |
| 152 | const signedness signedness_; |
| 153 | const base base_; |
| 154 | const roles roles_; |
| 155 | |
| 156 | protected: |
| 157 | bool _is_equal(const type& other) const noexcept override; |
| 158 | }; |
| 159 | |
| 160 | class floating_point_type : public type { |
| 161 | public: |
| 162 | floating_point_type(unsigned int alignment, |
| 163 | byte_order byte_order, |
| 164 | unsigned int exponent_digits, |
| 165 | unsigned int mantissa_digits); |
| 166 | |
| 167 | type::cuptr copy() const final; |
| 168 | |
| 169 | void accept(type_visitor& visitor) const final; |
| 170 | |
| 171 | const enum byte_order byte_order; |
| 172 | const unsigned int exponent_digits; |
| 173 | const unsigned int mantissa_digits; |
| 174 | |
| 175 | private: |
| 176 | bool _is_equal(const type& other) const noexcept final; |
| 177 | }; |
| 178 | |
| 179 | class enumeration_type : public integer_type { |
| 180 | protected: |
| 181 | enumeration_type(unsigned int alignment, |
| 182 | enum byte_order byte_order, |
| 183 | unsigned int size, |
| 184 | enum signedness signedness, |
| 185 | enum base base, |
| 186 | integer_type::roles roles = {}); |
| 187 | |
| 188 | void accept(type_visitor& visitor) const override = 0; |
| 189 | }; |
| 190 | |
| 191 | namespace details { |
| 192 | template <class MappingIntegerType> |
| 193 | class enumeration_mapping_range { |
| 194 | public: |
| 195 | using range_integer_t = MappingIntegerType; |
| 196 | |
| 197 | enumeration_mapping_range(MappingIntegerType in_begin, MappingIntegerType in_end) : |
| 198 | begin{in_begin}, end{in_end} |
| 199 | { |
| 200 | } |
| 201 | |
| 202 | const range_integer_t begin, end; |
| 203 | }; |
| 204 | |
| 205 | template <class MappingIntegerType> |
| 206 | bool operator==(const enumeration_mapping_range<MappingIntegerType>& lhs, |
| 207 | const enumeration_mapping_range<MappingIntegerType>& rhs) noexcept |
| 208 | { |
| 209 | return lhs.begin == rhs.begin && lhs.end == rhs.end; |
| 210 | } |
| 211 | |
| 212 | template <class MappingIntegerType> |
| 213 | class enumeration_mapping { |
| 214 | public: |
| 215 | using range_t = enumeration_mapping_range<MappingIntegerType>; |
| 216 | |
| 217 | enumeration_mapping(const enumeration_mapping<MappingIntegerType>& other) = default; |
| 218 | enumeration_mapping(const enumeration_mapping<MappingIntegerType>&& other) noexcept : |
| 219 | name{ std::move(other.name) }, range{ other.range } |
| 220 | { |
| 221 | } |
| 222 | |
| 223 | enumeration_mapping(std::string in_name, MappingIntegerType value) : name{std::move(in_name)}, range{value, value} |
| 224 | { |
| 225 | } |
| 226 | |
| 227 | enumeration_mapping(std::string in_name, range_t in_range) : name{std::move(in_name)}, range{in_range} |
| 228 | { |
| 229 | } |
| 230 | |
| 231 | const std::string name; |
| 232 | /* |
| 233 | * Only one range per mapping is supported for the moment as |
| 234 | * the tracers (and CTF 1.8) can't express multiple ranges per |
| 235 | * mapping, which is allowed by CTF 2. |
| 236 | */ |
| 237 | const range_t range; |
| 238 | }; |
| 239 | |
| 240 | template <class MappingIntegerType> |
| 241 | bool operator==(const enumeration_mapping<MappingIntegerType>& lhs, |
| 242 | const enumeration_mapping<MappingIntegerType>& rhs) noexcept |
| 243 | { |
| 244 | return lhs.name == rhs.name && lhs.range == rhs.range; |
| 245 | } |
| 246 | } /* namespace details */ |
| 247 | |
| 248 | template <typename MappingIntegerType> |
| 249 | class typed_enumeration_type : public enumeration_type { |
| 250 | public: |
| 251 | using mapping = details::enumeration_mapping<MappingIntegerType>; |
| 252 | using mappings = std::vector<mapping>; |
| 253 | |
| 254 | static_assert(std::is_integral<MappingIntegerType>::value && |
| 255 | sizeof(MappingIntegerType) == 8, |
| 256 | "MappingIntegerType must be either int64_t or uint64_t"); |
| 257 | |
| 258 | typed_enumeration_type(unsigned int in_alignment, |
| 259 | enum byte_order in_byte_order, |
| 260 | unsigned int in_size, |
| 261 | enum base in_base, |
| 262 | const std::shared_ptr<const mappings>& in_mappings, |
| 263 | integer_type::roles in_roles = {}) : |
| 264 | enumeration_type(in_alignment, |
| 265 | in_byte_order, |
| 266 | in_size, |
| 267 | std::is_signed<MappingIntegerType>::value ? |
| 268 | integer_type::signedness::SIGNED : |
| 269 | integer_type::signedness::UNSIGNED, |
| 270 | in_base, |
| 271 | std::move(in_roles)), |
| 272 | mappings_{std::move(in_mappings)} |
| 273 | { |
| 274 | } |
| 275 | |
| 276 | type::cuptr copy() const override |
| 277 | { |
| 278 | return lttng::make_unique<typed_enumeration_type<MappingIntegerType>>( |
| 279 | alignment, byte_order, size, base_, mappings_, roles_); |
| 280 | } |
| 281 | |
| 282 | void accept(type_visitor& visitor) const final; |
| 283 | |
| 284 | const std::shared_ptr<const mappings> mappings_; |
| 285 | |
| 286 | private: |
| 287 | bool _is_equal(const type& base_other) const noexcept final |
| 288 | { |
| 289 | const auto& other = static_cast<const typed_enumeration_type<MappingIntegerType>&>( |
| 290 | base_other); |
| 291 | |
| 292 | return integer_type::_is_equal(base_other) && *this->mappings_ == *other.mappings_; |
| 293 | } |
| 294 | }; |
| 295 | |
| 296 | /* Aliases for all allowed enumeration mapping types. */ |
| 297 | using signed_enumeration_type = typed_enumeration_type<int64_t>; |
| 298 | using unsigned_enumeration_type = typed_enumeration_type<uint64_t>; |
| 299 | |
| 300 | class array_type : public type { |
| 301 | public: |
| 302 | array_type(unsigned int alignment, type::cuptr element_type); |
| 303 | |
| 304 | const type::cuptr element_type; |
| 305 | |
| 306 | protected: |
| 307 | bool _is_equal(const type& base_other) const noexcept override; |
| 308 | }; |
| 309 | |
| 310 | class static_length_array_type : public array_type { |
| 311 | public: |
| 312 | static_length_array_type(unsigned int alignment, |
| 313 | type::cuptr element_type, |
| 314 | uint64_t in_length); |
| 315 | |
| 316 | type::cuptr copy() const final; |
| 317 | |
| 318 | void accept(type_visitor& visitor) const final; |
| 319 | |
| 320 | const uint64_t length; |
| 321 | |
| 322 | private: |
| 323 | bool _is_equal(const type& base_other) const noexcept final; |
| 324 | }; |
| 325 | |
| 326 | class dynamic_length_array_type : public array_type { |
| 327 | public: |
| 328 | dynamic_length_array_type(unsigned int alignment, |
| 329 | type::cuptr element_type, |
| 330 | field_location length_field_location); |
| 331 | |
| 332 | type::cuptr copy() const final; |
| 333 | |
| 334 | void accept(type_visitor& visitor) const final; |
| 335 | |
| 336 | const field_location length_field_location; |
| 337 | |
| 338 | private: |
| 339 | bool _is_equal(const type& base_other) const noexcept final; |
| 340 | }; |
| 341 | |
| 342 | class static_length_blob_type : public type { |
| 343 | public: |
| 344 | enum class role { |
| 345 | /* Packet header field class specific role. */ |
| 346 | METADATA_STREAM_UUID, |
| 347 | }; |
| 348 | |
| 349 | using roles = std::vector<role>; |
| 350 | |
| 351 | static_length_blob_type(unsigned int alignment, uint64_t in_length_bytes, roles roles = {}); |
| 352 | |
| 353 | type::cuptr copy() const final; |
| 354 | |
| 355 | void accept(type_visitor& visitor) const final; |
| 356 | |
| 357 | const uint64_t length_bytes; |
| 358 | const roles roles_; |
| 359 | |
| 360 | private: |
| 361 | bool _is_equal(const type& base_other) const noexcept final; |
| 362 | }; |
| 363 | |
| 364 | class dynamic_length_blob_type : public type { |
| 365 | public: |
| 366 | dynamic_length_blob_type(unsigned int alignment, field_location length_field_location); |
| 367 | |
| 368 | type::cuptr copy() const final; |
| 369 | |
| 370 | void accept(type_visitor& visitor) const final; |
| 371 | |
| 372 | const field_location length_field_location; |
| 373 | |
| 374 | private: |
| 375 | bool _is_equal(const type& base_other) const noexcept final; |
| 376 | }; |
| 377 | |
| 378 | class string_type : public type { |
| 379 | public: |
| 380 | enum class encoding { |
| 381 | ASCII, |
| 382 | UTF8, |
| 383 | }; |
| 384 | |
| 385 | string_type(unsigned int alignment, enum encoding encoding); |
| 386 | |
| 387 | /* |
| 388 | * encoding is suffixed with '_' to work-around a bug in older |
| 389 | * GCCs (before 6) that do not recognize hidden/shadowed enumeration as valid |
| 390 | * nested-name-specifiers. |
| 391 | */ |
| 392 | const encoding encoding_; |
| 393 | |
| 394 | protected: |
| 395 | bool _is_equal(const type& base_other) const noexcept override; |
| 396 | }; |
| 397 | |
| 398 | class static_length_string_type : public string_type { |
| 399 | public: |
| 400 | static_length_string_type( |
| 401 | unsigned int alignment, enum encoding in_encoding, uint64_t length); |
| 402 | |
| 403 | type::cuptr copy() const final; |
| 404 | |
| 405 | void accept(type_visitor& visitor) const final; |
| 406 | |
| 407 | const uint64_t length; |
| 408 | |
| 409 | private: |
| 410 | bool _is_equal(const type& base_other) const noexcept final; |
| 411 | }; |
| 412 | |
| 413 | class dynamic_length_string_type : public string_type { |
| 414 | public: |
| 415 | dynamic_length_string_type(unsigned int alignment, |
| 416 | enum encoding in_encoding, |
| 417 | field_location length_field_location); |
| 418 | |
| 419 | type::cuptr copy() const final; |
| 420 | |
| 421 | void accept(type_visitor& visitor) const final; |
| 422 | |
| 423 | const field_location length_field_location; |
| 424 | |
| 425 | private: |
| 426 | bool _is_equal(const type& base_other) const noexcept final; |
| 427 | }; |
| 428 | |
| 429 | class null_terminated_string_type : public string_type { |
| 430 | public: |
| 431 | null_terminated_string_type(unsigned int alignment, enum encoding in_encoding); |
| 432 | |
| 433 | type::cuptr copy() const final; |
| 434 | |
| 435 | void accept(type_visitor& visitor) const final; |
| 436 | }; |
| 437 | |
| 438 | class structure_type : public type { |
| 439 | public: |
| 440 | using fields = std::vector<field::cuptr>; |
| 441 | |
| 442 | structure_type(unsigned int alignment, fields in_fields); |
| 443 | |
| 444 | type::cuptr copy() const final; |
| 445 | |
| 446 | void accept(type_visitor& visitor) const final; |
| 447 | |
| 448 | const fields fields_; |
| 449 | |
| 450 | private: |
| 451 | bool _is_equal(const type& base_other) const noexcept final; |
| 452 | }; |
| 453 | |
| 454 | template <typename MappingIntegerType> |
| 455 | class variant_type : public type { |
| 456 | static_assert(std::is_same<MappingIntegerType, |
| 457 | unsigned_enumeration_type::mapping::range_t:: |
| 458 | range_integer_t>::value || |
| 459 | std::is_same<MappingIntegerType, |
| 460 | signed_enumeration_type::mapping::range_t:: |
| 461 | range_integer_t>::value, |
| 462 | "Variant mapping integer type must be one of those allowed by typed_enumeration_type"); |
| 463 | |
| 464 | public: |
| 465 | using choice = std::pair<const details::enumeration_mapping<MappingIntegerType>, type::cuptr>; |
| 466 | using choices = std::vector<choice>; |
| 467 | |
| 468 | variant_type(unsigned int in_alignment, |
| 469 | field_location in_selector_field_location, |
| 470 | choices in_choices) : |
| 471 | type(in_alignment), |
| 472 | selector_field_location{std::move(in_selector_field_location)}, |
| 473 | choices_{std::move(in_choices)} |
| 474 | { |
| 475 | } |
| 476 | |
| 477 | type::cuptr copy() const final |
| 478 | { |
| 479 | choices copy_of_choices; |
| 480 | |
| 481 | copy_of_choices.reserve(choices_.size()); |
| 482 | for (const auto& current_choice : choices_) { |
| 483 | copy_of_choices.emplace_back( |
| 484 | current_choice.first, current_choice.second->copy()); |
| 485 | } |
| 486 | |
| 487 | return lttng::make_unique<variant_type<MappingIntegerType>>( |
| 488 | alignment, selector_field_location, std::move(copy_of_choices)); |
| 489 | } |
| 490 | |
| 491 | void accept(type_visitor& visitor) const final; |
| 492 | |
| 493 | const field_location selector_field_location; |
| 494 | const choices choices_; |
| 495 | |
| 496 | private: |
| 497 | static bool _choices_are_equal(const choices& a, const choices& b) |
| 498 | { |
| 499 | if (a.size() != b.size()) { |
| 500 | return false; |
| 501 | } |
| 502 | |
| 503 | return std::equal(a.cbegin(), a.cend(), b.cbegin(), |
| 504 | [](const choice& choice_a, const choice& choice_b) { |
| 505 | return choice_a.first == choice_b.first && |
| 506 | *choice_a.second == *choice_b.second; |
| 507 | }); |
| 508 | } |
| 509 | |
| 510 | bool _is_equal(const type& base_other) const noexcept final |
| 511 | { |
| 512 | const auto& other = static_cast<decltype(*this)&>(base_other); |
| 513 | |
| 514 | return selector_field_location == other.selector_field_location && |
| 515 | _choices_are_equal(choices_, other.choices_); |
| 516 | } |
| 517 | }; |
| 518 | |
| 519 | class field_visitor { |
| 520 | public: |
| 521 | virtual ~field_visitor() = default; |
| 522 | virtual void visit(const field& field) = 0; |
| 523 | |
| 524 | protected: |
| 525 | field_visitor() = default; |
| 526 | }; |
| 527 | |
| 528 | class type_visitor { |
| 529 | public: |
| 530 | virtual ~type_visitor() = default; |
| 531 | virtual void visit(const integer_type& type) = 0; |
| 532 | virtual void visit(const floating_point_type& type) = 0; |
| 533 | virtual void visit(const signed_enumeration_type& type) = 0; |
| 534 | virtual void visit(const unsigned_enumeration_type& type) = 0; |
| 535 | virtual void visit(const static_length_array_type& type) = 0; |
| 536 | virtual void visit(const dynamic_length_array_type& type) = 0; |
| 537 | virtual void visit(const static_length_blob_type& type) = 0; |
| 538 | virtual void visit(const dynamic_length_blob_type& type) = 0; |
| 539 | virtual void visit(const null_terminated_string_type& type) = 0; |
| 540 | virtual void visit(const static_length_string_type& type) = 0; |
| 541 | virtual void visit(const dynamic_length_string_type& type) = 0; |
| 542 | virtual void visit(const structure_type& type) = 0; |
| 543 | virtual void visit(const variant_type<signed_enumeration_type::mapping::range_t::range_integer_t>& type) = 0; |
| 544 | virtual void visit(const variant_type<unsigned_enumeration_type::mapping::range_t::range_integer_t>& type) = 0; |
| 545 | |
| 546 | protected: |
| 547 | type_visitor() = default; |
| 548 | }; |
| 549 | |
| 550 | } /* namespace trace */ |
| 551 | } /* namespace sessiond */ |
| 552 | } /* namespace lttng */ |
| 553 | |
| 554 | /* |
| 555 | * Field formatters for libfmt. |
| 556 | * |
| 557 | * Due to a bug in g++ < 7.1, this specialization must be enclosed in the fmt namespace, |
| 558 | * see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480. |
| 559 | */ |
| 560 | namespace fmt { |
| 561 | template <> |
| 562 | struct formatter<lttng::sessiond::trace::field_location> : formatter<std::string> { |
| 563 | template <typename FormatContextType> |
| 564 | typename FormatContextType::iterator format( |
| 565 | const lttng::sessiond::trace::field_location& location, FormatContextType& ctx) |
| 566 | { |
| 567 | std::string location_str{"["}; |
| 568 | |
| 569 | switch (location.root_) { |
| 570 | case lttng::sessiond::trace::field_location::root::PACKET_HEADER: |
| 571 | location_str += "\"packet-header\""; |
| 572 | break; |
| 573 | case lttng::sessiond::trace::field_location::root::PACKET_CONTEXT: |
| 574 | location_str += "\"packet-context\""; |
| 575 | break; |
| 576 | case lttng::sessiond::trace::field_location::root::EVENT_RECORD_HEADER: |
| 577 | location_str += "\"event-record-header\""; |
| 578 | break; |
| 579 | case lttng::sessiond::trace::field_location::root::EVENT_RECORD_COMMON_CONTEXT: |
| 580 | location_str += "\"event-record-common-context\""; |
| 581 | break; |
| 582 | case lttng::sessiond::trace::field_location::root::EVENT_RECORD_SPECIFIC_CONTEXT: |
| 583 | location_str += "\"event-record-specific-context\""; |
| 584 | break; |
| 585 | case lttng::sessiond::trace::field_location::root::EVENT_RECORD_PAYLOAD: |
| 586 | location_str += "\"event-record-payload\""; |
| 587 | break; |
| 588 | } |
| 589 | |
| 590 | for (const auto &name : location.elements_) { |
| 591 | location_str += ", \"" + name + "\""; |
| 592 | } |
| 593 | |
| 594 | location_str += "]"; |
| 595 | return format_to(ctx.out(), location_str); |
| 596 | } |
| 597 | }; |
| 598 | |
| 599 | namespace details { |
| 600 | template <typename MappingIntegerType> |
| 601 | ::std::string format_mapping_range(typename lttng::sessiond::trace::typed_enumeration_type< |
| 602 | MappingIntegerType>::mapping::range_t range) |
| 603 | { |
| 604 | if (range.begin == range.end) { |
| 605 | return ::fmt::format("[{}]", range.begin); |
| 606 | } else { |
| 607 | return ::fmt::format("[{}, {}]", range.begin, range.end); |
| 608 | } |
| 609 | } |
| 610 | } /* namespace details */ |
| 611 | |
| 612 | template <> |
| 613 | struct formatter<typename lttng::sessiond::trace::signed_enumeration_type::mapping::range_t> |
| 614 | : formatter<std::string> { |
| 615 | template <typename FormatContextType> |
| 616 | typename FormatContextType::iterator |
| 617 | format(typename lttng::sessiond::trace::signed_enumeration_type::mapping::range_t range, |
| 618 | FormatContextType& ctx) |
| 619 | { |
| 620 | return format_to(ctx.out(), |
| 621 | details::format_mapping_range< |
| 622 | lttng::sessiond::trace::signed_enumeration_type:: |
| 623 | mapping::range_t::range_integer_t>( |
| 624 | range)); |
| 625 | } |
| 626 | }; |
| 627 | |
| 628 | template <> |
| 629 | struct formatter<typename lttng::sessiond::trace::unsigned_enumeration_type::mapping::range_t> |
| 630 | : formatter<std::string> { |
| 631 | template <typename FormatContextType> |
| 632 | typename FormatContextType::iterator |
| 633 | format(typename lttng::sessiond::trace::unsigned_enumeration_type::mapping::range_t range, |
| 634 | FormatContextType& ctx) |
| 635 | { |
| 636 | return format_to(ctx.out(), |
| 637 | details::format_mapping_range< |
| 638 | lttng::sessiond::trace::unsigned_enumeration_type:: |
| 639 | mapping::range_t::range_integer_t>( |
| 640 | range)); |
| 641 | } |
| 642 | }; |
| 643 | |
| 644 | } /* namespace fmt */ |
| 645 | |
| 646 | #endif /* LTTNG_FIELD_H */ |