| // WARNING: This file is machine generated by fidlgen. |
| |
| // fidl_experiment = output_index_json |
| |
| #pragma once |
| |
| #include <lib/fidl/cpp/wire/internal/display_error.h> |
| #include <lib/fidl/cpp/wire/traits.h> |
| #include <lib/stdcompat/optional.h> |
| |
| #include <cinttypes> |
| |
| #pragma clang diagnostic push |
| #pragma clang diagnostic ignored "-Wshadow" |
| |
| namespace test_bits { |
| |
| // |MyBits| 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 MyBits final { |
| public: |
| constexpr MyBits() = default; |
| |
| // Constructs an instance of |MyBits| from an underlying primitive value, |
| // preserving any bit member not defined in the FIDL schema. |
| explicit constexpr MyBits(uint32_t value) : value_(value) {} |
| const static MyBits kMyFirstBit; |
| const static MyBits kMyOtherBit; |
| const static MyBits kMask_; |
| const static MyBits 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 MyBits& other) const { return value_ == other.value_; } |
| constexpr inline bool operator!=(const MyBits& other) const { return value_ != other.value_; } |
| constexpr inline MyBits operator~() const; |
| constexpr inline MyBits operator|(const MyBits& other) const; |
| constexpr inline MyBits operator&(const MyBits& other) const; |
| constexpr inline MyBits operator^(const MyBits& other) const; |
| constexpr inline MyBits operator-(const MyBits& other) const; |
| constexpr inline void operator|=(const MyBits& other); |
| constexpr inline void operator&=(const MyBits& other); |
| constexpr inline void operator^=(const MyBits& other); |
| constexpr inline void operator-=(const MyBits& other); |
| |
| // Constructs an instance of |MyBits| from an underlying primitive value |
| // if the primitive does not contain any unknown members not defined in the |
| // FIDL schema. Otherwise, returns |std::nullopt|. |
| constexpr inline static std::optional<MyBits> TryFrom(uint32_t value) { |
| if (value & ~kMask.value_) { |
| return std::nullopt; |
| } |
| return MyBits(value & MyBits::kMask.value_); |
| } |
| |
| // Constructs an instance of |MyBits| from an underlying primitive value, |
| // clearing any bit member not defined in the FIDL schema. |
| constexpr inline static MyBits TruncatingUnknown(uint32_t value) { |
| return MyBits(value & MyBits::kMask.value_); |
| } |
| |
| private: |
| uint32_t value_ = 0; |
| }; |
| constexpr const ::test_bits::MyBits MyBits::kMyFirstBit = |
| ::test_bits::MyBits(1u); |
| constexpr const ::test_bits::MyBits MyBits::kMyOtherBit = |
| ::test_bits::MyBits(2u); |
| constexpr const ::test_bits::MyBits MyBits::kMask_ = |
| ::test_bits::MyBits(4u); |
| constexpr const ::test_bits::MyBits MyBits::kMask = ::test_bits::MyBits(7u); |
| |
| constexpr inline ::test_bits::MyBits MyBits::operator~() const { |
| return ::test_bits::MyBits(static_cast<uint32_t>(~this->value_ & kMask.value_)); |
| } |
| |
| constexpr inline ::test_bits::MyBits MyBits::operator|( |
| const ::test_bits::MyBits& other) const { |
| return ::test_bits::MyBits(static_cast<uint32_t>(this->value_ | other.value_)); |
| } |
| |
| constexpr inline ::test_bits::MyBits MyBits::operator&( |
| const ::test_bits::MyBits& other) const { |
| return ::test_bits::MyBits(static_cast<uint32_t>(this->value_ & other.value_)); |
| } |
| |
| constexpr inline ::test_bits::MyBits MyBits::operator^( |
| const ::test_bits::MyBits& other) const { |
| return ::test_bits::MyBits(static_cast<uint32_t>(this->value_ ^ other.value_)); |
| } |
| |
| constexpr inline ::test_bits::MyBits MyBits::operator-( |
| const ::test_bits::MyBits& other) const { |
| return ::test_bits::MyBits(static_cast<uint32_t>(this->value_ & ~other.value_)); |
| } |
| |
| constexpr inline void MyBits::operator|=( |
| const ::test_bits::MyBits& other) { |
| this->value_ |= other.value_; |
| } |
| |
| constexpr inline void MyBits::operator&=( |
| const ::test_bits::MyBits& other) { |
| this->value_ &= other.value_; |
| } |
| |
| constexpr inline void MyBits::operator^=( |
| const ::test_bits::MyBits& other) { |
| this->value_ ^= other.value_; |
| } |
| |
| constexpr inline void MyBits::operator-=( |
| const ::test_bits::MyBits& other) { |
| this->value_ &= ~other.value_; |
| } |
| |
| // |StrictBits| 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 StrictBits final { |
| public: |
| constexpr StrictBits() = default; |
| |
| // Constructs an instance of |StrictBits| from an underlying primitive value, |
| // preserving any bit member not defined in the FIDL schema. |
| explicit constexpr StrictBits(uint64_t value) : value_(value) {} |
| const static StrictBits kSmallest; |
| const static StrictBits kBiggest; |
| const static StrictBits kMask; |
| |
| explicit constexpr inline operator uint64_t() const { return value_; } |
| explicit constexpr inline operator bool() const { return static_cast<bool>(value_); } |
| constexpr inline bool operator==(const StrictBits& other) const { return value_ == other.value_; } |
| constexpr inline bool operator!=(const StrictBits& other) const { return value_ != other.value_; } |
| constexpr inline StrictBits operator~() const; |
| constexpr inline StrictBits operator|(const StrictBits& other) const; |
| constexpr inline StrictBits operator&(const StrictBits& other) const; |
| constexpr inline StrictBits operator^(const StrictBits& other) const; |
| constexpr inline StrictBits operator-(const StrictBits& other) const; |
| constexpr inline void operator|=(const StrictBits& other); |
| constexpr inline void operator&=(const StrictBits& other); |
| constexpr inline void operator^=(const StrictBits& other); |
| constexpr inline void operator-=(const StrictBits& other); |
| |
| // Constructs an instance of |StrictBits| from an underlying primitive value |
| // if the primitive does not contain any unknown members not defined in the |
| // FIDL schema. Otherwise, returns |std::nullopt|. |
| constexpr inline static std::optional<StrictBits> TryFrom(uint64_t value) { |
| if (value & ~kMask.value_) { |
| return std::nullopt; |
| } |
| return StrictBits(value & StrictBits::kMask.value_); |
| } |
| |
| // Constructs an instance of |StrictBits| from an underlying primitive value, |
| // clearing any bit member not defined in the FIDL schema. |
| constexpr inline static StrictBits TruncatingUnknown(uint64_t value) { |
| return StrictBits(value & StrictBits::kMask.value_); |
| } |
| |
| private: |
| uint64_t value_ = 0; |
| }; |
| constexpr const ::test_bits::StrictBits StrictBits::kSmallest = |
| ::test_bits::StrictBits(1u); |
| constexpr const ::test_bits::StrictBits StrictBits::kBiggest = |
| ::test_bits::StrictBits(9223372036854775808u); |
| constexpr const ::test_bits::StrictBits StrictBits::kMask = ::test_bits::StrictBits(9223372036854775809u); |
| |
| constexpr inline ::test_bits::StrictBits StrictBits::operator~() const { |
| return ::test_bits::StrictBits(static_cast<uint64_t>(~this->value_ & kMask.value_)); |
| } |
| |
| constexpr inline ::test_bits::StrictBits StrictBits::operator|( |
| const ::test_bits::StrictBits& other) const { |
| return ::test_bits::StrictBits(static_cast<uint64_t>(this->value_ | other.value_)); |
| } |
| |
| constexpr inline ::test_bits::StrictBits StrictBits::operator&( |
| const ::test_bits::StrictBits& other) const { |
| return ::test_bits::StrictBits(static_cast<uint64_t>(this->value_ & other.value_)); |
| } |
| |
| constexpr inline ::test_bits::StrictBits StrictBits::operator^( |
| const ::test_bits::StrictBits& other) const { |
| return ::test_bits::StrictBits(static_cast<uint64_t>(this->value_ ^ other.value_)); |
| } |
| |
| constexpr inline ::test_bits::StrictBits StrictBits::operator-( |
| const ::test_bits::StrictBits& other) const { |
| return ::test_bits::StrictBits(static_cast<uint64_t>(this->value_ & ~other.value_)); |
| } |
| |
| constexpr inline void StrictBits::operator|=( |
| const ::test_bits::StrictBits& other) { |
| this->value_ |= other.value_; |
| } |
| |
| constexpr inline void StrictBits::operator&=( |
| const ::test_bits::StrictBits& other) { |
| this->value_ &= other.value_; |
| } |
| |
| constexpr inline void StrictBits::operator^=( |
| const ::test_bits::StrictBits& other) { |
| this->value_ ^= other.value_; |
| } |
| |
| constexpr inline void StrictBits::operator-=( |
| const ::test_bits::StrictBits& other) { |
| this->value_ &= ~other.value_; |
| } |
| |
| // |FlexibleBits| is flexible, hence may contain unknown members not |
| // defined in the FIDL schema. |
| class FlexibleBits final { |
| public: |
| constexpr FlexibleBits() = default; |
| |
| // Constructs an instance of |FlexibleBits| from an underlying primitive value, |
| // preserving any bit member not defined in the FIDL schema. |
| explicit constexpr FlexibleBits(uint64_t value) : value_(value) {} |
| const static FlexibleBits kSmallest; |
| const static FlexibleBits kBiggest; |
| const static FlexibleBits kMask; |
| |
| explicit constexpr inline operator uint64_t() const { return value_; } |
| explicit constexpr inline operator bool() const { return static_cast<bool>(value_); } |
| constexpr inline bool operator==(const FlexibleBits& other) const { return value_ == other.value_; } |
| constexpr inline bool operator!=(const FlexibleBits& other) const { return value_ != other.value_; } |
| constexpr inline FlexibleBits operator~() const; |
| constexpr inline FlexibleBits operator|(const FlexibleBits& other) const; |
| constexpr inline FlexibleBits operator&(const FlexibleBits& other) const; |
| constexpr inline FlexibleBits operator^(const FlexibleBits& other) const; |
| constexpr inline FlexibleBits operator-(const FlexibleBits& other) const; |
| constexpr inline void operator|=(const FlexibleBits& other); |
| constexpr inline void operator&=(const FlexibleBits& other); |
| constexpr inline void operator^=(const FlexibleBits& other); |
| constexpr inline void operator-=(const FlexibleBits& other); |
| |
| // Constructs an instance of |FlexibleBits| from an underlying primitive value |
| // if the primitive does not contain any unknown members not defined in the |
| // FIDL schema. Otherwise, returns |std::nullopt|. |
| constexpr inline static std::optional<FlexibleBits> TryFrom(uint64_t value) { |
| if (value & ~kMask.value_) { |
| return std::nullopt; |
| } |
| return FlexibleBits(value & FlexibleBits::kMask.value_); |
| } |
| |
| // Constructs an instance of |FlexibleBits| from an underlying primitive value, |
| // clearing any bit member not defined in the FIDL schema. |
| constexpr inline static FlexibleBits TruncatingUnknown(uint64_t value) { |
| return FlexibleBits(value & FlexibleBits::kMask.value_); |
| } |
| constexpr inline FlexibleBits unknown_bits() const { |
| return *this & FlexibleBits(~kMask.value_); |
| } |
| constexpr inline bool has_unknown_bits() const { return static_cast<bool>(unknown_bits()); } |
| |
| private: |
| uint64_t value_ = 0; |
| }; |
| constexpr const ::test_bits::FlexibleBits FlexibleBits::kSmallest = |
| ::test_bits::FlexibleBits(1u); |
| constexpr const ::test_bits::FlexibleBits FlexibleBits::kBiggest = |
| ::test_bits::FlexibleBits(9223372036854775808u); |
| constexpr const ::test_bits::FlexibleBits FlexibleBits::kMask = ::test_bits::FlexibleBits(9223372036854775809u); |
| |
| constexpr inline ::test_bits::FlexibleBits FlexibleBits::operator~() const { |
| return ::test_bits::FlexibleBits(static_cast<uint64_t>(~this->value_ & kMask.value_)); |
| } |
| |
| constexpr inline ::test_bits::FlexibleBits FlexibleBits::operator|( |
| const ::test_bits::FlexibleBits& other) const { |
| return ::test_bits::FlexibleBits(static_cast<uint64_t>(this->value_ | other.value_)); |
| } |
| |
| constexpr inline ::test_bits::FlexibleBits FlexibleBits::operator&( |
| const ::test_bits::FlexibleBits& other) const { |
| return ::test_bits::FlexibleBits(static_cast<uint64_t>(this->value_ & other.value_)); |
| } |
| |
| constexpr inline ::test_bits::FlexibleBits FlexibleBits::operator^( |
| const ::test_bits::FlexibleBits& other) const { |
| return ::test_bits::FlexibleBits(static_cast<uint64_t>(this->value_ ^ other.value_)); |
| } |
| |
| constexpr inline ::test_bits::FlexibleBits FlexibleBits::operator-( |
| const ::test_bits::FlexibleBits& other) const { |
| return ::test_bits::FlexibleBits(static_cast<uint64_t>(this->value_ & ~other.value_)); |
| } |
| |
| constexpr inline void FlexibleBits::operator|=( |
| const ::test_bits::FlexibleBits& other) { |
| this->value_ |= other.value_; |
| } |
| |
| constexpr inline void FlexibleBits::operator&=( |
| const ::test_bits::FlexibleBits& other) { |
| this->value_ &= other.value_; |
| } |
| |
| constexpr inline void FlexibleBits::operator^=( |
| const ::test_bits::FlexibleBits& other) { |
| this->value_ ^= other.value_; |
| } |
| |
| constexpr inline void FlexibleBits::operator-=( |
| const ::test_bits::FlexibleBits& other) { |
| this->value_ &= ~other.value_; |
| } |
| |
| // |EmptyBits| is flexible, hence may contain unknown members not |
| // defined in the FIDL schema. |
| class EmptyBits final { |
| public: |
| constexpr EmptyBits() = default; |
| |
| // Constructs an instance of |EmptyBits| from an underlying primitive value, |
| // preserving any bit member not defined in the FIDL schema. |
| explicit constexpr EmptyBits(uint32_t value) : value_(value) {} |
| const static EmptyBits 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 EmptyBits& other) const { return value_ == other.value_; } |
| constexpr inline bool operator!=(const EmptyBits& other) const { return value_ != other.value_; } |
| constexpr inline EmptyBits operator~() const; |
| constexpr inline EmptyBits operator|(const EmptyBits& other) const; |
| constexpr inline EmptyBits operator&(const EmptyBits& other) const; |
| constexpr inline EmptyBits operator^(const EmptyBits& other) const; |
| constexpr inline EmptyBits operator-(const EmptyBits& other) const; |
| constexpr inline void operator|=(const EmptyBits& other); |
| constexpr inline void operator&=(const EmptyBits& other); |
| constexpr inline void operator^=(const EmptyBits& other); |
| constexpr inline void operator-=(const EmptyBits& other); |
| |
| // Constructs an instance of |EmptyBits| from an underlying primitive value |
| // if the primitive does not contain any unknown members not defined in the |
| // FIDL schema. Otherwise, returns |std::nullopt|. |
| constexpr inline static std::optional<EmptyBits> TryFrom(uint32_t value) { |
| if (value & ~kMask.value_) { |
| return std::nullopt; |
| } |
| return EmptyBits(value & EmptyBits::kMask.value_); |
| } |
| |
| // Constructs an instance of |EmptyBits| from an underlying primitive value, |
| // clearing any bit member not defined in the FIDL schema. |
| constexpr inline static EmptyBits TruncatingUnknown(uint32_t value) { |
| return EmptyBits(value & EmptyBits::kMask.value_); |
| } |
| constexpr inline EmptyBits unknown_bits() const { |
| return *this & EmptyBits(~kMask.value_); |
| } |
| constexpr inline bool has_unknown_bits() const { return static_cast<bool>(unknown_bits()); } |
| |
| private: |
| uint32_t value_ = 0; |
| }; |
| constexpr const ::test_bits::EmptyBits EmptyBits::kMask = ::test_bits::EmptyBits(0u); |
| |
| constexpr inline ::test_bits::EmptyBits EmptyBits::operator~() const { |
| return ::test_bits::EmptyBits(static_cast<uint32_t>(~this->value_ & kMask.value_)); |
| } |
| |
| constexpr inline ::test_bits::EmptyBits EmptyBits::operator|( |
| const ::test_bits::EmptyBits& other) const { |
| return ::test_bits::EmptyBits(static_cast<uint32_t>(this->value_ | other.value_)); |
| } |
| |
| constexpr inline ::test_bits::EmptyBits EmptyBits::operator&( |
| const ::test_bits::EmptyBits& other) const { |
| return ::test_bits::EmptyBits(static_cast<uint32_t>(this->value_ & other.value_)); |
| } |
| |
| constexpr inline ::test_bits::EmptyBits EmptyBits::operator^( |
| const ::test_bits::EmptyBits& other) const { |
| return ::test_bits::EmptyBits(static_cast<uint32_t>(this->value_ ^ other.value_)); |
| } |
| |
| constexpr inline ::test_bits::EmptyBits EmptyBits::operator-( |
| const ::test_bits::EmptyBits& other) const { |
| return ::test_bits::EmptyBits(static_cast<uint32_t>(this->value_ & ~other.value_)); |
| } |
| |
| constexpr inline void EmptyBits::operator|=( |
| const ::test_bits::EmptyBits& other) { |
| this->value_ |= other.value_; |
| } |
| |
| constexpr inline void EmptyBits::operator&=( |
| const ::test_bits::EmptyBits& other) { |
| this->value_ &= other.value_; |
| } |
| |
| constexpr inline void EmptyBits::operator^=( |
| const ::test_bits::EmptyBits& other) { |
| this->value_ ^= other.value_; |
| } |
| |
| constexpr inline void EmptyBits::operator-=( |
| const ::test_bits::EmptyBits& other) { |
| this->value_ &= ~other.value_; |
| } |
| |
| } // namespace test_bits |
| namespace fidl { |
| |
| template <> |
| struct IsFidlType<::test_bits::MyBits> : public std::true_type {}; |
| template <> |
| struct ContainsHandle<::test_bits::MyBits> : public std::false_type {}; |
| static_assert(std::is_standard_layout_v<::test_bits::MyBits>); |
| static_assert(sizeof(::test_bits::MyBits) == sizeof(uint32_t)); |
| |
| template <> |
| struct IsFidlType<::test_bits::StrictBits> : public std::true_type {}; |
| template <> |
| struct ContainsHandle<::test_bits::StrictBits> : public std::false_type {}; |
| static_assert(std::is_standard_layout_v<::test_bits::StrictBits>); |
| static_assert(sizeof(::test_bits::StrictBits) == sizeof(uint64_t)); |
| |
| template <> |
| struct IsFidlType<::test_bits::FlexibleBits> : public std::true_type {}; |
| template <> |
| struct ContainsHandle<::test_bits::FlexibleBits> : public std::false_type {}; |
| static_assert(std::is_standard_layout_v<::test_bits::FlexibleBits>); |
| static_assert(sizeof(::test_bits::FlexibleBits) == sizeof(uint64_t)); |
| |
| template <> |
| struct IsFidlType<::test_bits::EmptyBits> : public std::true_type {}; |
| template <> |
| struct ContainsHandle<::test_bits::EmptyBits> : public std::false_type {}; |
| static_assert(std::is_standard_layout_v<::test_bits::EmptyBits>); |
| static_assert(sizeof(::test_bits::EmptyBits) == sizeof(uint32_t)); |
| |
| #pragma clang diagnostic pop |
| |
| } // namespace fidl |