| // WARNING: This file is machine generated by fidlgen. |
| |
| #pragma once |
| |
| #include <lib/fidl/llcpp/array.h> |
| #include <lib/fidl/llcpp/coding.h> |
| #include <lib/fidl/llcpp/envelope.h> |
| #include <lib/fidl/llcpp/message.h> |
| #include <lib/fidl/llcpp/message_storage.h> |
| #include <lib/fidl/llcpp/object_view.h> |
| #include <lib/fidl/llcpp/string_view.h> |
| #include <lib/fidl/llcpp/traits.h> |
| #include <lib/fidl/llcpp/wire_types.h> |
| #include <lib/stdcompat/optional.h> |
| |
| #include <cinttypes> |
| #ifdef __Fuchsia__ |
| #include <lib/zx/channel.h> |
| |
| #endif // __Fuchsia__ |
| |
| #include <fidl/test.error/cpp/common_types.h> |
| #include <fidl/test.error/cpp/markers.h> |
| |
| namespace test_error { |
| namespace wire { |
| struct ExampleFooResponse; |
| |
| struct ExampleFooTopResponse; |
| |
| struct ExampleFooRequest; |
| |
| class ExampleFooResult; |
| |
| extern "C" const fidl_type_t test_error_Example_foo_ResultTable; |
| |
| class ExampleFooResult { |
| public: |
| using Response = test_error::wire::ExampleFooResponse; |
| |
| ExampleFooResult() |
| : ordinal_(::test_error::wire::ExampleFooResult::Ordinal::Invalid), |
| envelope_{} {} |
| |
| ExampleFooResult(const ExampleFooResult&) = default; |
| ExampleFooResult& operator=(const ExampleFooResult&) = default; |
| ExampleFooResult(ExampleFooResult&&) = default; |
| ExampleFooResult& operator=(ExampleFooResult&&) = default; |
| |
| enum class Tag : fidl_xunion_tag_t { |
| kResponse = 1, // 0x1 |
| kErr = 2, // 0x2 |
| }; |
| |
| bool has_invalid_tag() const { |
| return ordinal_ == ::test_error::wire::ExampleFooResult::Ordinal::Invalid; |
| } |
| |
| bool is_response() const { |
| return ordinal_ == ::test_error::wire::ExampleFooResult::Ordinal::kResponse; |
| } |
| |
| static ExampleFooResult WithResponse( |
| ::fidl::ObjectView<::test_error::wire::ExampleFooResponse> val) { |
| ExampleFooResult result; |
| result.ordinal_ = ::test_error::wire::ExampleFooResult::Ordinal::kResponse; |
| result.envelope_.As<::test_error::wire::ExampleFooResponse>().set_data( |
| std::move(val)); |
| return result; |
| } |
| |
| template <typename... Args> |
| static ExampleFooResult WithResponse(::fidl::AnyArena& allocator, |
| Args&&... args) { |
| return WithResponse( |
| ::fidl::ObjectView<::test_error::wire::ExampleFooResponse>( |
| allocator, std::forward<Args>(args)...)); |
| } |
| |
| ::test_error::wire::ExampleFooResponse& response() { |
| ZX_ASSERT(ordinal_ == |
| ::test_error::wire::ExampleFooResult::Ordinal::kResponse); |
| return envelope_.As<::test_error::wire::ExampleFooResponse>().get_data(); |
| } |
| const ::test_error::wire::ExampleFooResponse& response() const { |
| ZX_ASSERT(ordinal_ == |
| ::test_error::wire::ExampleFooResult::Ordinal::kResponse); |
| return envelope_.As<::test_error::wire::ExampleFooResponse>().get_data(); |
| } |
| |
| bool is_err() const { |
| return ordinal_ == ::test_error::wire::ExampleFooResult::Ordinal::kErr; |
| } |
| |
| static ExampleFooResult WithErr(uint32_t val) { |
| ExampleFooResult result; |
| result.ordinal_ = ::test_error::wire::ExampleFooResult::Ordinal::kErr; |
| result.envelope_.As<uint32_t>().set_data(std::move(val)); |
| return result; |
| } |
| |
| uint32_t& err() { |
| ZX_ASSERT(ordinal_ == ::test_error::wire::ExampleFooResult::Ordinal::kErr); |
| return envelope_.As<uint32_t>().get_data(); |
| } |
| const uint32_t& err() const { |
| ZX_ASSERT(ordinal_ == ::test_error::wire::ExampleFooResult::Ordinal::kErr); |
| return envelope_.As<uint32_t>().get_data(); |
| } |
| ::test_error::wire::ExampleFooResult::Tag Which() const { |
| ZX_ASSERT(!has_invalid_tag()); |
| return static_cast<::test_error::wire::ExampleFooResult::Tag>(ordinal_); |
| } |
| |
| private: |
| enum class Ordinal : fidl_xunion_tag_t { |
| Invalid = 0, |
| kResponse = 1, // 0x1 |
| kErr = 2, // 0x2 |
| }; |
| |
| static void SizeAndOffsetAssertionHelper(); |
| ::test_error::wire::ExampleFooResult::Ordinal ordinal_; |
| FIDL_ALIGNDECL |
| ::fidl::UntypedEnvelope envelope_; |
| }; |
| |
| extern "C" const fidl_type_t test_error_Example_foo_ResponseTable; |
| |
| struct ExampleFooResponse { |
| int64_t y = {}; |
| }; |
| |
| extern "C" const fidl_type_t test_error_ExampleFooTopResponseTable; |
| |
| struct ExampleFooTopResponse { |
| using Result = test_error::wire::ExampleFooResult; |
| |
| ::test_error::wire::ExampleFooResult result = {}; |
| }; |
| |
| extern "C" const fidl_type_t test_error_ExampleFooRequestTable; |
| |
| struct ExampleFooRequest { |
| ::fidl::StringView s = {}; |
| }; |
| |
| } // namespace wire |
| } // namespace test_error |
| namespace fidl { |
| |
| template <> |
| struct TypeTraits<::test_error::wire::ExampleFooResponse> { |
| static constexpr const fidl_type_t* kType = |
| &::test_error::wire::test_error_Example_foo_ResponseTable; |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kPrimarySize = 8; |
| static constexpr uint32_t kPrimarySizeV1 = 8; |
| [[maybe_unused]] static constexpr uint32_t kMaxOutOfLine = 0; |
| static constexpr uint32_t kMaxOutOfLineV1 = 0; |
| static constexpr bool kHasPointer = false; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_error::wire::ExampleFooResponse> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct<::test_error::wire::ExampleFooResponse> |
| : public std::true_type {}; |
| static_assert( |
| std::is_standard_layout_v<::test_error::wire::ExampleFooResponse>); |
| static_assert(offsetof(::test_error::wire::ExampleFooResponse, y) == 0); |
| static_assert(sizeof(::test_error::wire::ExampleFooResponse) == |
| TypeTraits<::test_error::wire::ExampleFooResponse>::kPrimarySize); |
| |
| template <> |
| struct TypeTraits<::test_error::wire::ExampleFooTopResponse> { |
| static constexpr const fidl_type_t* kType = |
| &::test_error::wire::test_error_ExampleFooTopResponseTable; |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kPrimarySize = 16; |
| static constexpr uint32_t kPrimarySizeV1 = 24; |
| [[maybe_unused]] static constexpr uint32_t kMaxOutOfLine = 8; |
| static constexpr uint32_t kMaxOutOfLineV1 = 8; |
| static constexpr bool kHasPointer = true; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_error::wire::ExampleFooTopResponse> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct<::test_error::wire::ExampleFooTopResponse> |
| : public std::true_type {}; |
| static_assert( |
| std::is_standard_layout_v<::test_error::wire::ExampleFooTopResponse>); |
| static_assert(offsetof(::test_error::wire::ExampleFooTopResponse, result) == 0); |
| static_assert( |
| sizeof(::test_error::wire::ExampleFooTopResponse) == |
| TypeTraits<::test_error::wire::ExampleFooTopResponse>::kPrimarySize); |
| |
| template <> |
| struct TypeTraits<::test_error::wire::ExampleFooRequest> { |
| static constexpr const fidl_type_t* kType = |
| &::test_error::wire::test_error_ExampleFooRequestTable; |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kPrimarySize = 16; |
| static constexpr uint32_t kPrimarySizeV1 = 16; |
| [[maybe_unused]] static constexpr uint32_t kMaxOutOfLine = 4294967295; |
| static constexpr uint32_t kMaxOutOfLineV1 = 4294967295; |
| static constexpr bool kHasPointer = true; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_error::wire::ExampleFooRequest> |
| : public std::true_type {}; |
| template <> |
| struct IsStruct<::test_error::wire::ExampleFooRequest> : public std::true_type { |
| }; |
| static_assert(std::is_standard_layout_v<::test_error::wire::ExampleFooRequest>); |
| static_assert(offsetof(::test_error::wire::ExampleFooRequest, s) == 0); |
| static_assert(sizeof(::test_error::wire::ExampleFooRequest) == |
| TypeTraits<::test_error::wire::ExampleFooRequest>::kPrimarySize); |
| |
| template <> |
| struct TypeTraits<::test_error::wire::ExampleFooResult> { |
| static constexpr const fidl_type_t* kType = |
| &::test_error::wire::test_error_Example_foo_ResultTable; |
| static constexpr uint32_t kMaxNumHandles = 0; |
| static constexpr uint32_t kPrimarySize = 16; |
| static constexpr uint32_t kPrimarySizeV1 = 24; |
| [[maybe_unused]] static constexpr uint32_t kMaxOutOfLine = 8; |
| static constexpr uint32_t kMaxOutOfLineV1 = 8; |
| static constexpr bool kHasPointer = true; |
| }; |
| |
| template <> |
| struct IsFidlType<::test_error::wire::ExampleFooResult> |
| : public std::true_type {}; |
| template <> |
| struct IsUnion<::test_error::wire::ExampleFooResult> : public std::true_type {}; |
| static_assert(std::is_standard_layout_v<::test_error::wire::ExampleFooResult>); |
| |
| } // namespace fidl |