| // WARNING: This file is machine generated by fidlgen. |
| |
| #pragma once |
| |
| #include <lib/fidl/internal.h> |
| #include <lib/fidl/llcpp/array.h> |
| #include <lib/fidl/llcpp/coding.h> |
| #include <lib/fidl/llcpp/envelope.h> |
| #include <lib/fidl/llcpp/errors.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/vector_view.h> |
| #include <lib/fit/function.h> |
| #include <lib/stdcompat/optional.h> |
| |
| #include <algorithm> |
| #include <cstddef> |
| #include <variant> |
| #ifdef __Fuchsia__ |
| #include <lib/fidl/llcpp/client.h> |
| #include <lib/fidl/llcpp/client_end.h> |
| #include <lib/fidl/llcpp/connect_service.h> |
| #include <lib/fidl/llcpp/result.h> |
| #include <lib/fidl/llcpp/server.h> |
| #include <lib/fidl/llcpp/server_end.h> |
| #include <lib/fidl/llcpp/service_handler_interface.h> |
| #include <lib/fidl/llcpp/sync_call.h> |
| #include <lib/fidl/llcpp/transaction.h> |
| #include <lib/fidl/llcpp/wire_messaging.h> |
| #include <lib/fidl/txn_header.h> |
| |
| #endif // __Fuchsia__ |
| #include <zircon/fidl.h> |
| |
| namespace fidl_test_bitsconstants { |
| namespace wire { |
| // |BitsType| is strict, hence is guaranteed to only contain |
| // members defined in the FIDL schema when receiving it in a message. |
| // Sending unknown members will fail at runtime. |
| class BitsType final { |
| public: |
| constexpr BitsType() = default; |
| constexpr BitsType(const BitsType& other) = default; |
| |
| // Constructs an instance of |BitsType| from an underlying primitive value, |
| // preserving any bit member not defined in the FIDL schema. |
| explicit constexpr BitsType(uint32_t value) : value_(value) {} |
| const static BitsType kA; |
| const static BitsType kB; |
| const static BitsType kC; |
| const static BitsType kMask; |
| |
| explicit constexpr inline operator uint32_t() const { return value_; } |
| explicit constexpr inline operator bool() const { |
| return static_cast<bool>(value_); |
| } |
| constexpr inline bool operator==(const BitsType& other) const { |
| return value_ == other.value_; |
| } |
| constexpr inline bool operator!=(const BitsType& other) const { |
| return value_ != other.value_; |
| } |
| constexpr inline BitsType operator~() const; |
| constexpr inline BitsType operator|(const BitsType& other) const; |
| constexpr inline BitsType operator&(const BitsType& other) const; |
| constexpr inline BitsType operator^(const BitsType& other) const; |
| constexpr inline void operator|=(const BitsType& other); |
| constexpr inline void operator&=(const BitsType& other); |
| constexpr inline void operator^=(const BitsType& other); |
| |
| // Constructs an instance of |BitsType| from an underlying primitive value |
| // if the primitive does not contain any unknown members not defined in the |
| // FIDL schema. Otherwise, returns |cpp17::nullopt|. |
| constexpr inline static cpp17::optional<BitsType> TryFrom(uint32_t value) { |
| if (value & ~kMask.value_) { |
| return cpp17::nullopt; |
| } |
| return BitsType(value & BitsType::kMask.value_); |
| } |
| |
| // Constructs an instance of |BitsType| from an underlying primitive value, |
| // clearing any bit member not defined in the FIDL schema. |
| constexpr inline static BitsType TruncatingUnknown(uint32_t value) { |
| return BitsType(value & BitsType::kMask.value_); |
| } |
| |
| private: |
| uint32_t value_ = 0; |
| }; |
| constexpr const ::fidl_test_bitsconstants::wire::BitsType BitsType::kA = |
| ::fidl_test_bitsconstants::wire::BitsType(1u); |
| constexpr const ::fidl_test_bitsconstants::wire::BitsType BitsType::kB = |
| ::fidl_test_bitsconstants::wire::BitsType(128u); |
| constexpr const ::fidl_test_bitsconstants::wire::BitsType BitsType::kC = |
| ::fidl_test_bitsconstants::wire::BitsType(2u); |
| constexpr const ::fidl_test_bitsconstants::wire::BitsType BitsType::kMask = |
| ::fidl_test_bitsconstants::wire::BitsType(131u); |
| |
| constexpr inline ::fidl_test_bitsconstants::wire::BitsType BitsType::operator~() |
| const { |
| return ::fidl_test_bitsconstants::wire::BitsType( |
| static_cast<uint32_t>(~this->value_ & kMask.value_)); |
| } |
| |
| constexpr inline ::fidl_test_bitsconstants::wire::BitsType BitsType::operator|( |
| const ::fidl_test_bitsconstants::wire::BitsType& other) const { |
| return ::fidl_test_bitsconstants::wire::BitsType( |
| static_cast<uint32_t>(this->value_ | other.value_)); |
| } |
| |
| constexpr inline ::fidl_test_bitsconstants::wire::BitsType BitsType::operator&( |
| const ::fidl_test_bitsconstants::wire::BitsType& other) const { |
| return ::fidl_test_bitsconstants::wire::BitsType( |
| static_cast<uint32_t>(this->value_ & other.value_)); |
| } |
| |
| constexpr inline ::fidl_test_bitsconstants::wire::BitsType BitsType::operator^( |
| const ::fidl_test_bitsconstants::wire::BitsType& other) const { |
| return ::fidl_test_bitsconstants::wire::BitsType( |
| static_cast<uint32_t>(this->value_ ^ other.value_)); |
| } |
| |
| constexpr inline void BitsType::operator|=( |
| const ::fidl_test_bitsconstants::wire::BitsType& other) { |
| this->value_ |= other.value_; |
| } |
| |
| constexpr inline void BitsType::operator&=( |
| const ::fidl_test_bitsconstants::wire::BitsType& other) { |
| this->value_ &= other.value_; |
| } |
| |
| constexpr inline void BitsType::operator^=( |
| const ::fidl_test_bitsconstants::wire::BitsType& other) { |
| this->value_ ^= other.value_; |
| } |
| |
| constexpr ::fidl_test_bitsconstants::wire::BitsType kConst3 = |
| static_cast<::fidl_test_bitsconstants::wire::BitsType>(131); |
| |
| constexpr ::fidl_test_bitsconstants::wire::BitsType kConst2 = |
| static_cast<::fidl_test_bitsconstants::wire::BitsType>(129); |
| |
| constexpr ::fidl_test_bitsconstants::wire::BitsType kConst1 = |
| ::fidl_test_bitsconstants::wire::BitsType::kA; |
| |
| } // namespace wire |
| } // namespace fidl_test_bitsconstants |
| namespace fidl { |
| |
| template <> |
| struct IsFidlType<::fidl_test_bitsconstants::wire::BitsType> |
| : public std::true_type {}; |
| static_assert( |
| std::is_standard_layout_v<::fidl_test_bitsconstants::wire::BitsType>); |
| static_assert(sizeof(::fidl_test_bitsconstants::wire::BitsType) == |
| sizeof(uint32_t)); |
| |
| } // namespace fidl |