| // WARNING: This file is machine generated by fidlgen. |
| |
| // fidl_experiment = output_index_json |
| |
| #pragma once |
| |
| #include "lib/fidl/cpp/internal/header.h" |
| |
| namespace test { |
| namespace serializable { |
| |
| // |
| // Domain objects declarations |
| // |
| |
| class SerializableStruct; |
| |
| class SerializableTable; |
| |
| class SerializableUnion; |
| |
| class SerializableStruct final { |
| public: |
| static const fidl_type_t* FidlType; |
| |
| uint8_t __reserved = 0u; |
| |
| static inline ::std::unique_ptr<SerializableStruct> New() { return ::std::make_unique<SerializableStruct>(); } |
| |
| void Encode(::fidl::Encoder* _encoder, size_t _offset, |
| std::optional<::fidl::HandleInformation> maybe_handle_info = std::nullopt); |
| static void Decode(::fidl::Decoder* _decoder, SerializableStruct* value, size_t _offset); |
| zx_status_t Clone(SerializableStruct* result) const; |
| }; |
| |
| inline zx_status_t Clone(const ::test::serializable::SerializableStruct& _value, |
| ::test::serializable::SerializableStruct* _result) { |
| return _value.Clone(_result); |
| } |
| |
| using SerializableStructPtr = ::std::unique_ptr<SerializableStruct>; |
| |
| class SerializableTable final { |
| public: |
| static const fidl_type_t* FidlType; |
| /// Returns whether no field is set. |
| bool IsEmpty() const; |
| |
| SerializableTable(); |
| SerializableTable(SerializableTable&& other); |
| ~SerializableTable(); |
| SerializableTable& operator=(SerializableTable&& other); |
| |
| static inline ::std::unique_ptr<SerializableTable> New() { return ::std::make_unique<SerializableTable>(); } |
| |
| void Encode(::fidl::Encoder* _encoder, size_t _offset, |
| std::optional<::fidl::HandleInformation> maybe_handle_info = std::nullopt); |
| static void Decode(::fidl::Decoder* _decoder, SerializableTable* _value, size_t _offset); |
| zx_status_t Clone(SerializableTable* _result) const; |
| |
| private: |
| template <class T, class... Args> |
| void Construct(T* p, Args&&... args) { |
| new (p) T(std::forward<Args>(args)...); |
| } |
| |
| template <class T> |
| void Destruct(T* p) { |
| p->~T(); |
| } |
| |
| size_t MaxOrdinal() const { |
| return static_cast<size_t>(field_presence_.MaxSetIndex()) + std::size_t{1}; |
| } |
| |
| static bool IsOrdinalKnown(uint64_t ordinal) { |
| switch (ordinal) { |
| return true; |
| default: |
| return false; |
| } |
| } |
| |
| ::fidl::internal::BitSet<0> field_presence_; |
| }; |
| |
| using SerializableTablePtr = ::std::unique_ptr<SerializableTable>; |
| |
| class SerializableUnion final { |
| public: |
| static const fidl_type_t* FidlType; |
| |
| SerializableUnion(); |
| ~SerializableUnion(); |
| |
| SerializableUnion(SerializableUnion&&); |
| SerializableUnion& operator=(SerializableUnion&&); |
| |
| static SerializableUnion WithUnused(bool&&); |
| |
| enum __attribute__((enum_extensibility(closed))) Tag : fidl_xunion_tag_t { |
| |
| kUnused = 1, // 0x1 |
| Invalid = ::std::numeric_limits<::fidl_union_tag_t>::max(), |
| }; |
| |
| static inline ::std::unique_ptr<SerializableUnion> New() { return ::std::make_unique<SerializableUnion>(); } |
| |
| void Encode(::fidl::Encoder* encoder, size_t offset, |
| std::optional<::fidl::HandleInformation> maybe_handle_info = std::nullopt); |
| static void Decode(::fidl::Decoder* _decoder, SerializableUnion* value, size_t offset); |
| zx_status_t Clone(SerializableUnion* result) const; |
| |
| bool has_invalid_tag() const { |
| return tag_ == Invalid; |
| } |
| |
| bool is_unused() const { return tag_ == ::test::serializable::SerializableUnion::Tag::kUnused; } |
| |
| bool& unused() { |
| EnsureStorageInitialized(::test::serializable::SerializableUnion::Tag::kUnused); |
| return unused_; |
| } |
| |
| const bool& unused() const { |
| ZX_ASSERT(is_unused()); |
| return unused_; |
| } |
| SerializableUnion& set_unused(bool value); |
| |
| ::test::serializable::SerializableUnion::Tag Which() const { |
| return ::test::serializable::SerializableUnion::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<::test::serializable::SerializableUnion>; |
| |
| private: |
| void Destroy(); |
| void EnsureStorageInitialized(::fidl_xunion_tag_t tag); |
| |
| ::fidl_xunion_tag_t tag_ = static_cast<fidl_xunion_tag_t>(::test::serializable::SerializableUnion::Tag::Invalid); |
| union { |
| bool unused_; |
| }; |
| }; |
| |
| inline zx_status_t Clone(const ::test::serializable::SerializableUnion& value, |
| ::test::serializable::SerializableUnion* result) { |
| return value.Clone(result); |
| } |
| |
| using SerializableUnionPtr = ::std::unique_ptr<SerializableUnion>; |
| |
| } // namespace serializable |
| } // namespace test |
| namespace fidl { |
| |
| template <> |
| struct CodingTraits<::test::serializable::SerializableStruct> |
| : public EncodableCodingTraits<::test::serializable::SerializableStruct, 1> {}; |
| |
| template <> |
| struct IsMemcpyCompatible<::test::serializable::SerializableStruct> : public internal::BoolConstant< |
| !HasPadding<::test::serializable::SerializableStruct>::value && IsMemcpyCompatible<uint8_t>::value> {}; |
| |
| inline zx_status_t Clone(const ::test::serializable::SerializableStruct& value, |
| ::test::serializable::SerializableStruct* result) { |
| return ::test::serializable::Clone(value, result); |
| } |
| |
| template <> |
| struct Equality<::test::serializable::SerializableStruct> { |
| bool operator()(const ::test::serializable::SerializableStruct& _lhs, const ::test::serializable::SerializableStruct& _rhs) const { |
| if (!::fidl::Equals(_lhs.__reserved, _rhs.__reserved)) { |
| return false; |
| } |
| return true; |
| } |
| }; |
| template <> |
| struct CodingTraits<::test::serializable::SerializableTable> |
| : public EncodableCodingTraits<::test::serializable::SerializableTable, 16> {}; |
| |
| inline zx_status_t Clone(const ::test::serializable::SerializableTable& _value, |
| ::test::serializable::SerializableTable* result) { |
| return _value.Clone(result); |
| } |
| template <> |
| struct Equality<::test::serializable::SerializableTable> { |
| bool operator()(const ::test::serializable::SerializableTable& _lhs, const ::test::serializable::SerializableTable& _rhs) const { |
| return true; |
| } |
| }; |
| template <> |
| struct IsFidlXUnion<::test::serializable::SerializableUnion> : public std::true_type {}; |
| |
| template <> |
| struct CodingTraits<::test::serializable::SerializableUnion> |
| : public EncodableCodingTraits<::test::serializable::SerializableUnion, 16> {}; |
| |
| template <> |
| struct CodingTraits<std::unique_ptr<::test::serializable::SerializableUnion>> { |
| static constexpr size_t kInlineSize = 16; |
| |
| static void Encode(Encoder* encoder, std::unique_ptr<::test::serializable::SerializableUnion>* value, size_t offset, |
| std::optional<::fidl::HandleInformation> maybe_handle_info = std::nullopt) { |
| auto&& p_xunion = *value; |
| if (p_xunion) { |
| p_xunion->Encode(encoder, offset); |
| } |
| } |
| |
| static void Decode(Decoder* _decoder, std::unique_ptr<::test::serializable::SerializableUnion>* value, size_t offset) { |
| fidl_union_t* encoded = _decoder->GetPtr<fidl_union_t>(offset); |
| if (encoded->tag == 0) { |
| value->reset(nullptr); |
| return; |
| } |
| |
| value->reset(new ::test::serializable::SerializableUnion); |
| |
| ::test::serializable::SerializableUnion::Decode(_decoder, value->get(), offset); |
| } |
| }; |
| |
| inline zx_status_t Clone(const ::test::serializable::SerializableUnion& value, |
| ::test::serializable::SerializableUnion* result) { |
| return ::test::serializable::Clone(value, result); |
| } |
| |
| template <> |
| struct Equality<::test::serializable::SerializableUnion> { |
| bool operator()(const ::test::serializable::SerializableUnion& _lhs, const ::test::serializable::SerializableUnion& _rhs) const { |
| if (_lhs.Ordinal() != _rhs.Ordinal()) { |
| return false; |
| } |
| |
| switch (_lhs.Ordinal()) { |
| case static_cast<fidl_xunion_tag_t>(::test::serializable::SerializableUnion::Tag::Invalid): |
| return true; |
| case ::test::serializable::SerializableUnion::Tag::kUnused: |
| return ::fidl::Equals(_lhs.unused_, _rhs.unused_); |
| |
| default: |
| return false; |
| } |
| } |
| }; |
| |
| // |
| // Proxies and stubs declarations |
| // |
| } // namespace fidl |