| // WARNING: This file is machine generated by fidlgen. |
| |
| #pragma once |
| |
| #include "lib/fidl/cpp/internal/natural_types_header.h" |
| |
| // |
| // Domain objects declarations (i.e. "natural types" in unified bindings). |
| // |
| namespace fidl { |
| namespace test { |
| namespace requestflexibleenvelope { |
| class StrictFoo; |
| |
| class FlexibleFoo; |
| |
| #ifdef __Fuchsia__ |
| |
| class Protocol; |
| using ProtocolHandle = ::fidl::InterfaceHandle<Protocol>; |
| #endif // __Fuchsia__ |
| |
| class StrictFoo final { |
| public: |
| static const fidl_type_t* FidlType; |
| |
| StrictFoo(); |
| ~StrictFoo(); |
| |
| StrictFoo(StrictFoo&&); |
| StrictFoo& operator=(StrictFoo&&); |
| |
| static StrictFoo WithS(::std::string&&); |
| static StrictFoo WithI(int32_t&&); |
| |
| enum __attribute__((enum_extensibility(closed))) Tag : fidl_xunion_tag_t { |
| |
| kS = 1, // 0x1 |
| kI = 2, // 0x2 |
| Invalid = ::std::numeric_limits<::fidl_union_tag_t>::max(), |
| }; |
| |
| static inline ::std::unique_ptr<StrictFoo> New() { |
| return ::std::make_unique<StrictFoo>(); |
| } |
| |
| void Encode(::fidl::Encoder* encoder, size_t offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info = |
| cpp17::nullopt); |
| static void Decode(::fidl::Decoder* decoder, StrictFoo* value, size_t offset); |
| zx_status_t Clone(StrictFoo* result) const; |
| |
| bool has_invalid_tag() const { return tag_ == Invalid; } |
| |
| bool is_s() const { |
| return tag_ == ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kS; |
| } |
| |
| ::std::string& s() { |
| EnsureStorageInitialized( |
| ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kS); |
| return s_; |
| } |
| |
| const ::std::string& s() const { |
| ZX_ASSERT(is_s()); |
| return s_; |
| } |
| StrictFoo& set_s(::std::string value); |
| |
| bool is_i() const { |
| return tag_ == ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kI; |
| } |
| |
| int32_t& i() { |
| EnsureStorageInitialized( |
| ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kI); |
| return i_; |
| } |
| |
| const int32_t& i() const { |
| ZX_ASSERT(is_i()); |
| return i_; |
| } |
| StrictFoo& set_i(int32_t value); |
| |
| ::fidl::test::requestflexibleenvelope::StrictFoo::Tag Which() const { |
| return ::fidl::test::requestflexibleenvelope::StrictFoo::Tag(tag_); |
| } |
| |
| // You probably want to use Which() method instead of Ordinal(). Use Ordinal() |
| // only when you need access to the raw integral ordinal value. |
| fidl_xunion_tag_t Ordinal() const { return tag_; } |
| |
| friend ::fidl::Equality<::fidl::test::requestflexibleenvelope::StrictFoo>; |
| |
| private: |
| void Destroy(); |
| void EnsureStorageInitialized(::fidl_xunion_tag_t tag); |
| |
| ::fidl_xunion_tag_t tag_ = static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::Invalid); |
| union { |
| ::std::string s_; |
| int32_t i_; |
| }; |
| }; |
| |
| inline zx_status_t Clone( |
| const ::fidl::test::requestflexibleenvelope::StrictFoo& value, |
| ::fidl::test::requestflexibleenvelope::StrictFoo* result) { |
| return value.Clone(result); |
| } |
| |
| using StrictFooPtr = ::std::unique_ptr<StrictFoo>; |
| |
| class FlexibleFoo final { |
| public: |
| static const fidl_type_t* FidlType; |
| |
| FlexibleFoo(); |
| ~FlexibleFoo(); |
| |
| FlexibleFoo(FlexibleFoo&&); |
| FlexibleFoo& operator=(FlexibleFoo&&); |
| |
| static FlexibleFoo WithS(::std::string&&); |
| static FlexibleFoo WithI(int32_t&&); |
| |
| enum __attribute__((enum_extensibility(closed))) Tag : fidl_xunion_tag_t { |
| kUnknown = 0, |
| Empty = kUnknown, // DEPRECATED: use kUnknown instead. |
| |
| kS = 1, // 0x1 |
| kI = 2, // 0x2 |
| Invalid = ::std::numeric_limits<::fidl_union_tag_t>::max(), |
| }; |
| |
| static inline ::std::unique_ptr<FlexibleFoo> New() { |
| return ::std::make_unique<FlexibleFoo>(); |
| } |
| |
| void Encode(::fidl::Encoder* encoder, size_t offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info = |
| cpp17::nullopt); |
| static void Decode(::fidl::Decoder* decoder, FlexibleFoo* value, |
| size_t offset); |
| zx_status_t Clone(FlexibleFoo* result) const; |
| |
| bool has_invalid_tag() const { return tag_ == Invalid; } |
| |
| bool is_s() const { |
| return tag_ == ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kS; |
| } |
| |
| ::std::string& s() { |
| EnsureStorageInitialized( |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kS); |
| return s_; |
| } |
| |
| const ::std::string& s() const { |
| ZX_ASSERT(is_s()); |
| return s_; |
| } |
| FlexibleFoo& set_s(::std::string value); |
| |
| bool is_i() const { |
| return tag_ == ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kI; |
| } |
| |
| int32_t& i() { |
| EnsureStorageInitialized( |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kI); |
| return i_; |
| } |
| |
| const int32_t& i() const { |
| ZX_ASSERT(is_i()); |
| return i_; |
| } |
| FlexibleFoo& set_i(int32_t value); |
| FlexibleFoo& SetUnknownData(fidl_xunion_tag_t ordinal, |
| std::vector<uint8_t> bytes); |
| |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag Which() const { |
| switch (tag_) { |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::Invalid: |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kS: |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kI: |
| return ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag(tag_); |
| default: |
| return ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag:: |
| kUnknown; |
| } |
| } |
| |
| // You probably want to use Which() method instead of Ordinal(). Use Ordinal() |
| // only when you need access to the raw integral ordinal value. |
| fidl_xunion_tag_t Ordinal() const { return tag_; } |
| const std::vector<uint8_t>* UnknownBytes() const { |
| if (Which() != |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kUnknown) { |
| return nullptr; |
| } |
| return &unknown_data_; |
| } |
| |
| friend ::fidl::Equality<::fidl::test::requestflexibleenvelope::FlexibleFoo>; |
| |
| private: |
| void Destroy(); |
| void EnsureStorageInitialized(::fidl_xunion_tag_t tag); |
| |
| ::fidl_xunion_tag_t tag_ = static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::Invalid); |
| union { |
| ::std::string s_; |
| int32_t i_; |
| std::vector<uint8_t> unknown_data_; |
| }; |
| }; |
| |
| inline zx_status_t Clone( |
| const ::fidl::test::requestflexibleenvelope::FlexibleFoo& value, |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo* result) { |
| return value.Clone(result); |
| } |
| |
| using FlexibleFooPtr = ::std::unique_ptr<FlexibleFoo>; |
| |
| #ifdef __Fuchsia__ |
| |
| namespace _internal { |
| extern "C" const fidl_type_t |
| fidl_test_requestflexibleenvelope_ProtocolRequestStrictResponseFlexibleRequestTable; |
| |
| extern "C" const fidl_type_t |
| fidl_test_requestflexibleenvelope_ProtocolRequestFlexibleResponseStrictRequestTable; |
| |
| } // namespace _internal |
| class Protocol_RequestEncoder { |
| public: |
| static ::fidl::HLCPPOutgoingMessage RequestStrictResponseFlexible( |
| ::fidl::Encoder* _encoder, |
| ::fidl::test::requestflexibleenvelope::StrictFoo* s) { |
| fidl_trace(WillHLCPPEncode); |
| _encoder->Alloc(40 - sizeof(fidl_message_header_t)); |
| ::fidl::Encode(_encoder, s, 16); |
| |
| fidl_trace( |
| DidHLCPPEncode, |
| &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestStrictResponseFlexibleRequestTable, |
| _encoder->GetPtr<const char>(0), _encoder->CurrentLength(), |
| _encoder->CurrentHandleCount()); |
| |
| return _encoder->GetMessage(); |
| } |
| static ::fidl::HLCPPOutgoingMessage RequestFlexibleResponseStrict( |
| ::fidl::Encoder* _encoder, |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo* s) { |
| fidl_trace(WillHLCPPEncode); |
| _encoder->Alloc(40 - sizeof(fidl_message_header_t)); |
| ::fidl::Encode(_encoder, s, 16); |
| |
| fidl_trace( |
| DidHLCPPEncode, |
| &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestFlexibleResponseStrictRequestTable, |
| _encoder->GetPtr<const char>(0), _encoder->CurrentLength(), |
| _encoder->CurrentHandleCount()); |
| |
| return _encoder->GetMessage(); |
| } |
| }; |
| namespace _internal { |
| extern "C" const fidl_type_t |
| fidl_test_requestflexibleenvelope_ProtocolRequestStrictResponseFlexibleResponseTable; |
| |
| extern "C" const fidl_type_t |
| fidl_test_requestflexibleenvelope_ProtocolRequestFlexibleResponseStrictResponseTable; |
| |
| } // namespace _internal |
| class Protocol_ResponseEncoder { |
| public: |
| static ::fidl::HLCPPOutgoingMessage RequestStrictResponseFlexible( |
| ::fidl::Encoder* _encoder, |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo* f) { |
| fidl_trace(WillHLCPPEncode); |
| _encoder->Alloc(40 - sizeof(fidl_message_header_t)); |
| ::fidl::Encode(_encoder, f, 16); |
| |
| fidl_trace( |
| DidHLCPPEncode, |
| &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestStrictResponseFlexibleResponseTable, |
| _encoder->GetPtr<const char>(0), _encoder->CurrentLength(), |
| _encoder->CurrentHandleCount()); |
| return _encoder->GetMessage(); |
| } |
| static ::fidl::HLCPPOutgoingMessage RequestFlexibleResponseStrict( |
| ::fidl::Encoder* _encoder, |
| ::fidl::test::requestflexibleenvelope::StrictFoo* f) { |
| fidl_trace(WillHLCPPEncode); |
| _encoder->Alloc(40 - sizeof(fidl_message_header_t)); |
| ::fidl::Encode(_encoder, f, 16); |
| |
| fidl_trace( |
| DidHLCPPEncode, |
| &::fidl::test::requestflexibleenvelope::_internal:: |
| fidl_test_requestflexibleenvelope_ProtocolRequestFlexibleResponseStrictResponseTable, |
| _encoder->GetPtr<const char>(0), _encoder->CurrentLength(), |
| _encoder->CurrentHandleCount()); |
| return _encoder->GetMessage(); |
| } |
| }; |
| #endif // __Fuchsia__ |
| |
| } // namespace requestflexibleenvelope |
| } // namespace test |
| template <> |
| struct IsFidlXUnion<::fidl::test::requestflexibleenvelope::StrictFoo> |
| : public std::true_type {}; |
| |
| template <> |
| struct CodingTraits<::fidl::test::requestflexibleenvelope::StrictFoo> |
| : public EncodableCodingTraits< |
| ::fidl::test::requestflexibleenvelope::StrictFoo, 24> {}; |
| |
| template <> |
| struct CodingTraits< |
| std::unique_ptr<::fidl::test::requestflexibleenvelope::StrictFoo>> { |
| static constexpr size_t inline_size_v1_no_ee = 24; |
| |
| static void Encode( |
| Encoder* encoder, |
| std::unique_ptr<::fidl::test::requestflexibleenvelope::StrictFoo>* value, |
| size_t offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info) { |
| auto&& p_xunion = *value; |
| if (p_xunion) { |
| p_xunion->Encode(encoder, offset); |
| } |
| } |
| |
| static void Decode( |
| Decoder* decoder, |
| std::unique_ptr<::fidl::test::requestflexibleenvelope::StrictFoo>* value, |
| size_t offset) { |
| fidl_xunion_t* encoded = decoder->GetPtr<fidl_xunion_t>(offset); |
| if (encoded->tag == 0) { |
| value->reset(nullptr); |
| return; |
| } |
| |
| value->reset(new ::fidl::test::requestflexibleenvelope::StrictFoo); |
| |
| ::fidl::test::requestflexibleenvelope::StrictFoo::Decode( |
| decoder, value->get(), offset); |
| } |
| }; |
| |
| inline zx_status_t Clone( |
| const ::fidl::test::requestflexibleenvelope::StrictFoo& value, |
| ::fidl::test::requestflexibleenvelope::StrictFoo* result) { |
| return ::fidl::test::requestflexibleenvelope::Clone(value, result); |
| } |
| |
| template <> |
| struct Equality<::fidl::test::requestflexibleenvelope::StrictFoo> { |
| bool operator()( |
| const ::fidl::test::requestflexibleenvelope::StrictFoo& _lhs, |
| const ::fidl::test::requestflexibleenvelope::StrictFoo& _rhs) const { |
| if (_lhs.Ordinal() != _rhs.Ordinal()) { |
| return false; |
| } |
| |
| switch (_lhs.Ordinal()) { |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::Invalid): |
| return true; |
| case ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kS: |
| return ::fidl::Equals(_lhs.s_, _rhs.s_); |
| case ::fidl::test::requestflexibleenvelope::StrictFoo::Tag::kI: |
| return ::fidl::Equals(_lhs.i_, _rhs.i_); |
| |
| default: |
| return false; |
| } |
| } |
| }; |
| template <> |
| struct IsFidlXUnion<::fidl::test::requestflexibleenvelope::FlexibleFoo> |
| : public std::true_type {}; |
| |
| template <> |
| struct CodingTraits<::fidl::test::requestflexibleenvelope::FlexibleFoo> |
| : public EncodableCodingTraits< |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo, 24> {}; |
| |
| template <> |
| struct CodingTraits< |
| std::unique_ptr<::fidl::test::requestflexibleenvelope::FlexibleFoo>> { |
| static constexpr size_t inline_size_v1_no_ee = 24; |
| |
| static void Encode( |
| Encoder* encoder, |
| std::unique_ptr<::fidl::test::requestflexibleenvelope::FlexibleFoo>* |
| value, |
| size_t offset, |
| cpp17::optional<::fidl::HandleInformation> maybe_handle_info) { |
| auto&& p_xunion = *value; |
| if (p_xunion) { |
| p_xunion->Encode(encoder, offset); |
| } |
| } |
| |
| static void Decode( |
| Decoder* decoder, |
| std::unique_ptr<::fidl::test::requestflexibleenvelope::FlexibleFoo>* |
| value, |
| size_t offset) { |
| fidl_xunion_t* encoded = decoder->GetPtr<fidl_xunion_t>(offset); |
| if (encoded->tag == 0) { |
| value->reset(nullptr); |
| return; |
| } |
| |
| value->reset(new ::fidl::test::requestflexibleenvelope::FlexibleFoo); |
| |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo::Decode( |
| decoder, value->get(), offset); |
| } |
| }; |
| |
| inline zx_status_t Clone( |
| const ::fidl::test::requestflexibleenvelope::FlexibleFoo& value, |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo* result) { |
| return ::fidl::test::requestflexibleenvelope::Clone(value, result); |
| } |
| |
| template <> |
| struct Equality<::fidl::test::requestflexibleenvelope::FlexibleFoo> { |
| bool operator()( |
| const ::fidl::test::requestflexibleenvelope::FlexibleFoo& _lhs, |
| const ::fidl::test::requestflexibleenvelope::FlexibleFoo& _rhs) const { |
| if (_lhs.Ordinal() != _rhs.Ordinal()) { |
| return false; |
| } |
| |
| switch (_lhs.Ordinal()) { |
| case static_cast<fidl_xunion_tag_t>( |
| ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::Invalid): |
| return true; |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kS: |
| return ::fidl::Equals(_lhs.s_, _rhs.s_); |
| case ::fidl::test::requestflexibleenvelope::FlexibleFoo::Tag::kI: |
| return ::fidl::Equals(_lhs.i_, _rhs.i_); |
| default: |
| return ::fidl::Equals(_lhs.unknown_data_, _rhs.unknown_data_); |
| } |
| } |
| }; |
| |
| } // namespace fidl |