| // WARNING: This file is machine generated by fidlgen. |
| |
| // fidl_experiment = output_index_json |
| |
| #pragma once |
| |
| #include <fidl/test.error/cpp/common_types.h> |
| #include <fidl/test.error/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_error { |
| |
| class ExampleFooRequest; |
| |
| class ExampleFooResponse; |
| |
| class ExampleFooResult; |
| |
| class ExampleFooRequest { |
| private: |
| struct Storage_; |
| |
| public: |
| ExampleFooRequest(Storage_ storage) noexcept; |
| ExampleFooRequest(::std::string s) noexcept; |
| |
| #pragma clang diagnostic push |
| #pragma clang diagnostic ignored "-Wdefaulted-function-deleted" |
| // Default constructs a |ExampleFooRequest| only if all of its members are default constructible. |
| ExampleFooRequest() = default; |
| #pragma clang diagnostic pop |
| |
| ExampleFooRequest(ExampleFooRequest&&) noexcept = default; |
| ExampleFooRequest& operator=(ExampleFooRequest&&) noexcept = default; |
| ExampleFooRequest(const ExampleFooRequest& other) noexcept; |
| ExampleFooRequest& operator=(const ExampleFooRequest& other) noexcept; |
| |
| bool operator==(const ExampleFooRequest& other) const noexcept { |
| return ::fidl::internal::NaturalStructCodingTraits<::test_error::ExampleFooRequest, 16>::Equal(this, &other); |
| } |
| bool operator!=(const ExampleFooRequest& other) const noexcept { |
| return !::fidl::internal::NaturalStructCodingTraits<::test_error::ExampleFooRequest, 16>::Equal(this, &other); |
| } |
| |
| const ::std::string& |
| s() const { |
| return storage_.s; |
| } |
| |
| ::std::string& s() { |
| return storage_.s; |
| } |
| |
| // Setter for s. |
| // |
| |
| ExampleFooRequest& s(::std::string value); |
| |
| ExampleFooRequest(::fidl::internal::DefaultConstructPossiblyInvalidObjectTag); |
| |
| private: |
| struct Storage_ final { |
| ::std::string s; |
| }; |
| |
| Storage_ storage_; |
| Storage_ CloneStorage_() const; |
| |
| friend struct ::fidl::internal::NaturalStructCodingTraits<::test_error::ExampleFooRequest, 16>; |
| friend struct ::fidl::internal::MemberVisitor<::test_error::ExampleFooRequest>; |
| static constexpr auto kMembers = std::make_tuple(::fidl::internal::NaturalStructMember<Storage_, ::std::string, fidl::internal::NaturalCodingConstraintString<>>{ |
| &Storage_::s, 0}); |
| static constexpr auto kPadding = std::make_tuple(); |
| }; |
| |
| class ExampleFooResponse { |
| private: |
| struct Storage_; |
| |
| public: |
| ExampleFooResponse(Storage_ storage) noexcept; |
| ExampleFooResponse(int64_t y) noexcept; |
| |
| #pragma clang diagnostic push |
| #pragma clang diagnostic ignored "-Wdefaulted-function-deleted" |
| // Default constructs a |ExampleFooResponse| only if all of its members are default constructible. |
| ExampleFooResponse() = default; |
| #pragma clang diagnostic pop |
| |
| ExampleFooResponse(ExampleFooResponse&&) noexcept = default; |
| ExampleFooResponse& operator=(ExampleFooResponse&&) noexcept = default; |
| ExampleFooResponse(const ExampleFooResponse& other) noexcept; |
| ExampleFooResponse& operator=(const ExampleFooResponse& other) noexcept; |
| |
| bool operator==(const ExampleFooResponse& other) const noexcept { |
| return ::fidl::internal::NaturalStructCodingTraits<::test_error::ExampleFooResponse, 8>::Equal(this, &other); |
| } |
| bool operator!=(const ExampleFooResponse& other) const noexcept { |
| return !::fidl::internal::NaturalStructCodingTraits<::test_error::ExampleFooResponse, 8>::Equal(this, &other); |
| } |
| |
| int64_t |
| y() const { |
| return storage_.y; |
| } |
| |
| int64_t& y() { |
| return storage_.y; |
| } |
| |
| // Setter for y. |
| // |
| |
| ExampleFooResponse& y(int64_t value); |
| |
| ExampleFooResponse(::fidl::internal::DefaultConstructPossiblyInvalidObjectTag); |
| |
| private: |
| struct Storage_ final { |
| int64_t y = {}; |
| }; |
| |
| Storage_ storage_; |
| Storage_ CloneStorage_() const; |
| |
| friend struct ::fidl::internal::NaturalStructCodingTraits<::test_error::ExampleFooResponse, 8>; |
| friend struct ::fidl::internal::MemberVisitor<::test_error::ExampleFooResponse>; |
| static constexpr auto kMembers = std::make_tuple(::fidl::internal::NaturalStructMember<Storage_, int64_t, fidl::internal::NaturalCodingConstraintEmpty>{ |
| &Storage_::y, 0}); |
| static constexpr auto kPadding = std::make_tuple(); |
| }; |
| |
| class ExampleFooResult { |
| private: |
| using Storage_ = |
| std::variant< |
| std::monostate, ::test_error::ExampleFooResponse, uint32_t>; |
| |
| public: |
| // TODO: share union tag types between wire & natural. |
| enum class Tag : fidl_xunion_tag_t { |
| kResponse = 1, // 0x1 |
| kErr = 2, // 0x2 |
| }; |
| |
| ExampleFooResult(ExampleFooResult&& other) noexcept |
| : ExampleFooResult(::fidl::internal::DefaultConstructPossiblyInvalidObjectTag{}) { |
| *storage_ = std::move(*other.storage_); |
| } |
| ExampleFooResult& operator=(ExampleFooResult&& other) noexcept { |
| if (this != &other) { |
| *storage_ = std::move(*other.storage_); |
| } |
| return *this; |
| } |
| ExampleFooResult(const ExampleFooResult& other) noexcept : ExampleFooResult(other.CloneStorage_()) {} |
| ExampleFooResult& operator=(const ExampleFooResult& other) noexcept { |
| if (this != &other) { |
| storage_ = other.CloneStorage_(); |
| } |
| return *this; |
| } |
| |
| bool operator==(const ExampleFooResult& other) const noexcept { |
| return *storage_ == *other.storage_; |
| } |
| bool operator!=(const ExampleFooResult& other) const noexcept { |
| return *storage_ != *other.storage_; |
| } |
| |
| constexpr ::test_error::ExampleFooResult::Tag Which() const { |
| return ExampleFooResult::IndexToTag(storage_->index()).value(); |
| } |
| static ExampleFooResult WithResponse(::test_error::ExampleFooResponse val) { |
| return ExampleFooResult(std::make_shared<Storage_>( |
| std::in_place_index_t<1>{}, |
| std::move(val))); |
| } |
| |
| const ::fidl::internal::UnionMemberView<1, Storage_> response() const { |
| return ::fidl::internal::UnionMemberView<1, Storage_>(storage_); |
| } |
| |
| ::fidl::internal::UnionMemberView<1, Storage_> response() { |
| return ::fidl::internal::UnionMemberView<1, Storage_>(storage_); |
| } |
| |
| // Sets the union to hold the response member. |
| // |
| |
| ExampleFooResult& response(::test_error::ExampleFooResponse value) { |
| storage_->emplace<1>(std::move(value)); |
| return *this; |
| } |
| static ExampleFooResult WithErr(uint32_t val) { |
| return ExampleFooResult(std::make_shared<Storage_>( |
| std::in_place_index_t<2>{}, |
| std::move(val))); |
| } |
| |
| const ::fidl::internal::UnionMemberView<2, Storage_> err() const { |
| return ::fidl::internal::UnionMemberView<2, Storage_>(storage_); |
| } |
| |
| ::fidl::internal::UnionMemberView<2, Storage_> err() { |
| return ::fidl::internal::UnionMemberView<2, Storage_>(storage_); |
| } |
| |
| // Sets the union to hold the err member. |
| // |
| |
| ExampleFooResult& err(uint32_t value) { |
| storage_->emplace<2>(std::move(value)); |
| return *this; |
| } |
| |
| ExampleFooResult(::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_error::ExampleFooResult>; |
| static constexpr auto kMembers = std::make_tuple( |
| ::fidl::internal::NaturalUnionMember<::fidl::internal::NaturalCodingConstraintEmpty>(), ::fidl::internal::NaturalUnionMember<fidl::internal::NaturalCodingConstraintEmpty>(), ::fidl::internal::NaturalUnionMember<fidl::internal::NaturalCodingConstraintEmpty>()); |
| |
| explicit ExampleFooResult(std::shared_ptr<Storage_> storage) : storage_(std::move(storage)) {} |
| |
| static constexpr size_t TagToIndex(::fidl::internal::NaturalDecoder* decoder, ::test_error::ExampleFooResult::Tag tag) { |
| switch (tag) { |
| case ::test_error::ExampleFooResult::Tag::kResponse: |
| return 1; |
| case ::test_error::ExampleFooResult::Tag::kErr: |
| return 2; |
| default: { |
| decoder->SetError(::fidl::internal::kCodingErrorUnknownUnionTag); |
| return 0; |
| } |
| } |
| } |
| |
| static constexpr std::optional<::test_error::ExampleFooResult::Tag> IndexToTag(size_t index) { |
| switch (index) { |
| case 1: |
| return ::test_error::ExampleFooResult::Tag::kResponse; |
| case 2: |
| return ::test_error::ExampleFooResult::Tag::kErr; |
| default: |
| return std::nullopt; |
| } |
| } |
| }; |
| |
| inline ExampleFooRequest::ExampleFooRequest(Storage_ storage) noexcept : storage_(std::move(storage)) {} |
| inline ExampleFooRequest::ExampleFooRequest(::std::string s) noexcept |
| : storage_({.s = std::move(s)}) {} |
| inline ExampleFooRequest::ExampleFooRequest(const ::test_error::ExampleFooRequest& other) noexcept : ::test_error::ExampleFooRequest(other.CloneStorage_()) {} |
| inline ExampleFooRequest& ::test_error::ExampleFooRequest::operator=(const ::test_error::ExampleFooRequest & other) noexcept { |
| storage_ = other.CloneStorage_(); |
| return *this; |
| } |
| |
| inline ExampleFooRequest::ExampleFooRequest(::fidl::internal::DefaultConstructPossiblyInvalidObjectTag) : ExampleFooRequest(Storage_{ |
| .s = {}, |
| }) {} |
| inline ExampleFooRequest& ExampleFooRequest::s(::std::string value) { |
| storage_.s = std::move(value); |
| return *this; |
| } |
| |
| inline ExampleFooResponse::ExampleFooResponse(Storage_ storage) noexcept : storage_(std::move(storage)) {} |
| inline ExampleFooResponse::ExampleFooResponse(int64_t y) noexcept |
| : storage_({.y = std::move(y)}) {} |
| inline ExampleFooResponse::ExampleFooResponse(const ::test_error::ExampleFooResponse& other) noexcept : ::test_error::ExampleFooResponse(other.CloneStorage_()) {} |
| inline ExampleFooResponse& ::test_error::ExampleFooResponse::operator=(const ::test_error::ExampleFooResponse & other) noexcept { |
| storage_ = other.CloneStorage_(); |
| return *this; |
| } |
| |
| inline ExampleFooResponse::ExampleFooResponse(::fidl::internal::DefaultConstructPossiblyInvalidObjectTag) : ExampleFooResponse(Storage_{ |
| .y = {}, |
| }) {} |
| inline ExampleFooResponse& ExampleFooResponse::y(int64_t value) { |
| storage_.y = std::move(value); |
| return *this; |
| } |
| |
| } // namespace test_error |
| namespace fidl { |
| |
| template <> |
| struct IsFidlType<::test_error::ExampleFooRequest> : public std::true_type {}; |
| |
| template <> |
| struct TypeTraits<::test_error::ExampleFooRequest> { |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kMaxDepth = 1; |
| static constexpr uint32_t kPrimarySize = 16; |
| static constexpr uint32_t kMaxOutOfLine = 4294967295; |
| static constexpr bool kHasPointer = true; |
| }; |
| |
| template <> |
| struct IsStruct<::test_error::ExampleFooRequest> : public std::true_type {}; |
| |
| template <> |
| struct internal::NaturalCodingTraits<::test_error::ExampleFooRequest, ::fidl::internal::NaturalCodingConstraintEmpty> final |
| : public ::fidl::internal::NaturalStructCodingTraits<::test_error::ExampleFooRequest, 16> {}; |
| |
| template <> |
| struct IsFidlType<::test_error::ExampleFooResponse> : public std::true_type {}; |
| |
| template <> |
| struct TypeTraits<::test_error::ExampleFooResponse> { |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kMaxDepth = 0; |
| static constexpr uint32_t kPrimarySize = 8; |
| static constexpr uint32_t kMaxOutOfLine = 0; |
| static constexpr bool kHasPointer = false; |
| }; |
| |
| template <> |
| struct IsStruct<::test_error::ExampleFooResponse> : public std::true_type {}; |
| |
| template <> |
| struct internal::NaturalCodingTraits<::test_error::ExampleFooResponse, ::fidl::internal::NaturalCodingConstraintEmpty> final |
| : public ::fidl::internal::NaturalStructCodingTraits<::test_error::ExampleFooResponse, 8> {}; |
| |
| template <> |
| struct IsFidlType<::test_error::ExampleFooResult> : public std::true_type {}; |
| |
| template <> |
| struct TypeTraits<::test_error::ExampleFooResult> { |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kMaxDepth = 1; |
| static constexpr uint32_t kPrimarySize = 16; |
| static constexpr uint32_t kMaxOutOfLine = 8; |
| static constexpr bool kHasPointer = true; |
| }; |
| |
| template <> |
| struct IsUnion<::test_error::ExampleFooResult> : public std::true_type {}; |
| |
| template <> |
| struct internal::NaturalCodingTraits<::test_error::ExampleFooResult, ::fidl::internal::NaturalCodingConstraintEmpty> final |
| : public ::fidl::internal::NaturalUnionCodingTraits<::test_error::ExampleFooResult> {}; |
| |
| #pragma clang diagnostic pop |
| |
| } // namespace fidl |