| // WARNING: This file is machine generated by fidlgen. |
| |
| // fidl_experiment = output_index_json |
| |
| #pragma once |
| |
| #include <fidl/test.versions/cpp/common_types.h> |
| #include <fidl/test.versions/cpp/markers.h> |
| #include <lib/fidl/cpp/natural_coding_traits.h> |
| #include <lib/fidl/cpp/natural_types.h> |
| |
| #include <cinttypes> |
| #include <string> |
| |
| #ifdef __Fuchsia__ |
| |
| #include <lib/zx/channel.h> |
| |
| #endif // __Fuchsia__ |
| |
| #pragma clang diagnostic push |
| #pragma clang diagnostic ignored "-Wshadow" |
| |
| namespace test_versions { |
| |
| class Struct; |
| |
| class Table; |
| |
| class Union; |
| |
| using Alias = ::std::string; |
| |
| constexpr uint32_t kConst = 0u; |
| |
| constexpr bool kAddedAtHead = true; |
| |
| class Struct { |
| private: |
| struct Storage_; |
| |
| public: |
| Struct(Storage_ storage) noexcept; |
| Struct(uint32_t x) noexcept; |
| |
| #pragma clang diagnostic push |
| #pragma clang diagnostic ignored "-Wdefaulted-function-deleted" |
| // Default constructs a |Struct| only if all of its members are default constructible. |
| Struct() = default; |
| #pragma clang diagnostic pop |
| |
| Struct(Struct&&) noexcept = default; |
| Struct& operator=(Struct&&) noexcept = default; |
| Struct(const Struct& other) noexcept; |
| Struct& operator=(const Struct& other) noexcept; |
| |
| bool operator==(const Struct& other) const noexcept { |
| return ::fidl::internal::NaturalStructCodingTraits<::test_versions::Struct, 4>::Equal(this, &other); |
| } |
| bool operator!=(const Struct& other) const noexcept { |
| return !::fidl::internal::NaturalStructCodingTraits<::test_versions::Struct, 4>::Equal(this, &other); |
| } |
| |
| uint32_t |
| x() const { |
| return storage_.x; |
| } |
| |
| uint32_t& x() { |
| return storage_.x; |
| } |
| |
| // Setter for x. |
| // |
| |
| Struct& x(uint32_t value); |
| |
| Struct(::fidl::internal::DefaultConstructPossiblyInvalidObjectTag); |
| |
| private: |
| struct Storage_ final { |
| uint32_t x = {}; |
| }; |
| |
| Storage_ storage_; |
| Storage_ CloneStorage_() const; |
| |
| friend struct ::fidl::internal::NaturalStructCodingTraits<::test_versions::Struct, 4>; |
| friend struct ::fidl::internal::MemberVisitor<::test_versions::Struct>; |
| static constexpr auto kMembers = std::make_tuple(::fidl::internal::NaturalStructMember<Storage_, uint32_t, fidl::internal::NaturalCodingConstraintEmpty>{ |
| &Storage_::x, 0}); |
| static constexpr auto kPadding = std::make_tuple(); |
| }; |
| |
| class Table { |
| private: |
| struct Storage_; |
| |
| public: |
| Table(Storage_ storage) noexcept; |
| Table() noexcept = default; |
| Table(Table&&) noexcept = default; |
| Table& operator=(Table&&) noexcept = default; |
| Table(const Table& other) noexcept; |
| Table& operator=(const Table& other) noexcept; |
| bool operator==(const Table& other) const noexcept { |
| return ::fidl::internal::NaturalTableCodingTraits<::test_versions::Table>::Equal(this, &other); |
| } |
| bool operator!=(const Table& other) const noexcept { |
| return !::fidl::internal::NaturalTableCodingTraits<::test_versions::Table>::Equal(this, &other); |
| } |
| |
| bool IsEmpty() const { |
| return !(storage_.x.has_value()); |
| } |
| |
| const std::optional<uint32_t>& x() const { return storage_.x; } |
| ::std::optional<uint32_t>& x() { return storage_.x; } |
| |
| // Setter for x. |
| // |
| |
| Table& x(std::optional<uint32_t> value); |
| |
| Table(::fidl::internal::DefaultConstructPossiblyInvalidObjectTag); |
| |
| private: |
| struct Storage_ final { |
| ::std::optional<uint32_t> x; |
| }; |
| |
| // TODO(https://fxbug.dev/42172795): Box the storage. |
| Storage_ storage_; |
| Storage_ CloneStorage_() const; |
| friend struct ::fidl::internal::NaturalTableCodingTraits<::test_versions::Table>; |
| friend struct ::fidl::internal::MemberVisitor<::test_versions::Table>; |
| static constexpr auto kMembers = std::make_tuple(::fidl::internal::NaturalTableMember<Storage_, uint32_t, fidl::internal::NaturalCodingConstraintEmpty>{ |
| 1, &Storage_::x}); |
| }; |
| |
| class Union { |
| private: |
| using Storage_ = |
| std::variant< |
| std::monostate, uint32_t>; |
| |
| public: |
| // TODO: share union tag types between wire & natural. |
| enum class Tag : fidl_xunion_tag_t { |
| kX = 1, // 0x1 |
| _do_not_handle_this__write_a_default_case_instead = ::std::numeric_limits<::fidl_union_tag_t>::max(), |
| }; |
| |
| Union(Union&& other) noexcept |
| : Union(::fidl::internal::DefaultConstructPossiblyInvalidObjectTag{}) { |
| *storage_ = std::move(*other.storage_); |
| } |
| Union& operator=(Union&& other) noexcept { |
| if (this != &other) { |
| *storage_ = std::move(*other.storage_); |
| } |
| return *this; |
| } |
| Union(const Union& other) noexcept : Union(other.CloneStorage_()) {} |
| Union& operator=(const Union& other) noexcept { |
| if (this != &other) { |
| storage_ = other.CloneStorage_(); |
| } |
| return *this; |
| } |
| |
| bool operator==(const Union& other) const noexcept { |
| return *storage_ == *other.storage_; |
| } |
| bool operator!=(const Union& other) const noexcept { |
| return *storage_ != *other.storage_; |
| } |
| constexpr bool IsUnknown() const { |
| return Which() == ::test_versions::Union::Tag::_do_not_handle_this__write_a_default_case_instead; |
| } |
| |
| constexpr ::test_versions::Union::Tag Which() const { |
| return Union::IndexToTag(storage_->index()).value(); |
| } |
| static Union WithX(uint32_t val) { |
| return Union(std::make_shared<Storage_>( |
| std::in_place_index_t<1>{}, |
| std::move(val))); |
| } |
| |
| const ::fidl::internal::UnionMemberView<1, Storage_> x() const { |
| return ::fidl::internal::UnionMemberView<1, Storage_>(storage_); |
| } |
| |
| ::fidl::internal::UnionMemberView<1, Storage_> x() { |
| return ::fidl::internal::UnionMemberView<1, Storage_>(storage_); |
| } |
| |
| // Sets the union to hold the x member. |
| // |
| |
| Union& x(uint32_t value) { |
| storage_->emplace<1>(std::move(value)); |
| return *this; |
| } |
| |
| Union(::fidl::internal::DefaultConstructPossiblyInvalidObjectTag) |
| : storage_(std::make_shared<Storage_>()) {} |
| |
| private: |
| std::shared_ptr<Storage_> storage_; |
| std::shared_ptr<Storage_> CloneStorage_() const; |
| friend struct ::fidl::internal::NaturalUnionCodingTraits<::test_versions::Union>; |
| static constexpr auto kMembers = std::make_tuple( |
| ::fidl::internal::NaturalUnionMember<::fidl::internal::NaturalCodingConstraintEmpty>(), ::fidl::internal::NaturalUnionMember<fidl::internal::NaturalCodingConstraintEmpty>()); |
| |
| explicit Union(std::shared_ptr<Storage_> storage) : storage_(std::move(storage)) {} |
| |
| static constexpr size_t TagToIndex(::fidl::internal::NaturalDecoder* decoder, ::test_versions::Union::Tag tag) { |
| switch (tag) { |
| case ::test_versions::Union::Tag::kX: |
| return 1; |
| default: { |
| return 0; |
| } |
| } |
| } |
| |
| static constexpr std::optional<::test_versions::Union::Tag> IndexToTag(size_t index) { |
| switch (index) { |
| case 1: |
| return ::test_versions::Union::Tag::kX; |
| default: |
| return ::test_versions::Union::Tag::_do_not_handle_this__write_a_default_case_instead; |
| } |
| } |
| }; |
| |
| inline Struct::Struct(Storage_ storage) noexcept : storage_(std::move(storage)) {} |
| inline Struct::Struct(uint32_t x) noexcept |
| : storage_({.x = std::move(x)}) {} |
| inline Struct::Struct(const ::test_versions::Struct& other) noexcept : ::test_versions::Struct(other.CloneStorage_()) {} |
| inline Struct& ::test_versions::Struct::operator=(const ::test_versions::Struct & other) noexcept { |
| storage_ = other.CloneStorage_(); |
| return *this; |
| } |
| |
| inline Struct::Struct(::fidl::internal::DefaultConstructPossiblyInvalidObjectTag) : Struct(Storage_{ |
| .x = {}, |
| }) {} |
| inline Struct& Struct::x(uint32_t value) { |
| storage_.x = std::move(value); |
| return *this; |
| } |
| |
| inline Table::Table(Storage_ storage) noexcept : storage_(std::move(storage)) {} |
| inline Table::Table(const ::test_versions::Table& other) noexcept : Table(other.CloneStorage_()) {} |
| inline Table& ::test_versions::Table::operator=(const Table & other) noexcept { |
| storage_ = other.CloneStorage_(); |
| return *this; |
| } |
| |
| inline Table::Table(::fidl::internal::DefaultConstructPossiblyInvalidObjectTag) : Table(Storage_{}) {} |
| inline Table& Table::x(std::optional<uint32_t> value) { |
| storage_.x = std::move(value); |
| return *this; |
| } |
| |
| } // namespace test_versions |
| namespace fidl { |
| |
| template <> |
| struct IsFidlType<::test_versions::Struct> : public std::true_type {}; |
| |
| template <> |
| struct TypeTraits<::test_versions::Struct> { |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kMaxDepth = 0; |
| static constexpr uint32_t kPrimarySize = 4; |
| static constexpr uint32_t kMaxOutOfLine = 0; |
| static constexpr bool kHasPointer = false; |
| }; |
| |
| template <> |
| struct IsStruct<::test_versions::Struct> : public std::true_type {}; |
| |
| template <> |
| struct internal::NaturalCodingTraits<::test_versions::Struct, ::fidl::internal::NaturalCodingConstraintEmpty> final |
| : public ::fidl::internal::NaturalStructCodingTraits<::test_versions::Struct, 4> {}; |
| |
| template <> |
| struct IsFidlType<::test_versions::Table> : public std::true_type {}; |
| |
| template <> |
| struct TypeTraits<::test_versions::Table> { |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kMaxDepth = 2; |
| static constexpr uint32_t kPrimarySize = 16; |
| static constexpr uint32_t kMaxOutOfLine = 8; |
| static constexpr bool kHasPointer = true; |
| }; |
| |
| template <> |
| struct IsTable<::test_versions::Table> : public std::true_type {}; |
| |
| template <> |
| struct internal::NaturalCodingTraits<::test_versions::Table, ::fidl::internal::NaturalCodingConstraintEmpty> : public ::fidl::internal::NaturalTableCodingTraits<::test_versions::Table> {}; |
| |
| template <> |
| struct IsFidlType<::test_versions::Union> : public std::true_type {}; |
| |
| template <> |
| struct TypeTraits<::test_versions::Union> { |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kMaxDepth = 1; |
| static constexpr uint32_t kPrimarySize = 16; |
| static constexpr uint32_t kMaxOutOfLine = 0; |
| static constexpr bool kHasPointer = true; |
| }; |
| |
| template <> |
| struct IsUnion<::test_versions::Union> : public std::true_type {}; |
| |
| template <> |
| struct internal::NaturalCodingTraits<::test_versions::Union, ::fidl::internal::NaturalCodingConstraintEmpty> final |
| : public ::fidl::internal::NaturalUnionCodingTraits<::test_versions::Union> {}; |
| |
| template <> |
| struct internal::NaturalCodingTraits<::test_versions::Bits, ::fidl::internal::NaturalCodingConstraintEmpty> { |
| static constexpr size_t kInlineSize = sizeof(uint32_t); |
| static constexpr bool kIsMemcpyCompatible = true; |
| |
| static void Encode(internal::NaturalEncoder* encoder, ::test_versions::Bits* value, size_t offset, size_t recursion_depth) { |
| *encoder->template GetPtr<::test_versions::Bits>(offset) = *value; |
| } |
| static void Decode(internal::NaturalDecoder* decoder, ::test_versions::Bits* value, size_t offset, size_t recursion_depth) { |
| *value = *decoder->template GetPtr<::test_versions::Bits>(offset); |
| } |
| }; |
| |
| template <> |
| struct internal::NaturalCodingTraits<::test_versions::Enum, ::fidl::internal::NaturalCodingConstraintEmpty> { |
| static constexpr size_t kInlineSize = sizeof(uint32_t); |
| static constexpr bool kIsMemcpyCompatible = true; |
| |
| static void Encode(internal::NaturalEncoder* encoder, ::test_versions::Enum* value, size_t offset, size_t recursion_depth) { |
| *encoder->template GetPtr<::test_versions::Enum>(offset) = *value; |
| } |
| static void Decode(internal::NaturalDecoder* decoder, ::test_versions::Enum* value, size_t offset, size_t recursion_depth) { |
| *value = *decoder->template GetPtr<::test_versions::Enum>(offset); |
| } |
| }; |
| |
| #pragma clang diagnostic pop |
| |
| } // namespace fidl |