blob: 2abced8d5bc21dd528624e1dc34f13dede964134 [file] [log] [blame]
// WARNING: This file is machine generated by fidlgen.
// fidl_experiment = output_index_json
#pragma once
#include <fidl/test.exampleusing/cpp/common_types.h>
#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_placementofattributes {
// |ExampleBits| 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 ExampleBits final {
public:
constexpr ExampleBits() = default;
// Constructs an instance of |ExampleBits| from an underlying primitive value,
// preserving any bit member not defined in the FIDL schema.
explicit constexpr ExampleBits(uint32_t value) : value_(value) {}
const static ExampleBits kMember;
const static ExampleBits 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 ExampleBits& other) const { return value_ == other.value_; }
constexpr inline bool operator!=(const ExampleBits& other) const { return value_ != other.value_; }
constexpr inline ExampleBits operator~() const;
constexpr inline ExampleBits operator|(const ExampleBits& other) const;
constexpr inline ExampleBits operator&(const ExampleBits& other) const;
constexpr inline ExampleBits operator^(const ExampleBits& other) const;
constexpr inline ExampleBits operator-(const ExampleBits& other) const;
constexpr inline void operator|=(const ExampleBits& other);
constexpr inline void operator&=(const ExampleBits& other);
constexpr inline void operator^=(const ExampleBits& other);
constexpr inline void operator-=(const ExampleBits& other);
// Constructs an instance of |ExampleBits| 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<ExampleBits> TryFrom(uint32_t value) {
if (value & ~kMask.value_) {
return std::nullopt;
}
return ExampleBits(value & ExampleBits::kMask.value_);
}
// Constructs an instance of |ExampleBits| from an underlying primitive value,
// clearing any bit member not defined in the FIDL schema.
constexpr inline static ExampleBits TruncatingUnknown(uint32_t value) {
return ExampleBits(value & ExampleBits::kMask.value_);
}
private:
uint32_t value_ = 0;
};
constexpr const ::test_placementofattributes::ExampleBits ExampleBits::kMember =
::test_placementofattributes::ExampleBits(1u);
constexpr const ::test_placementofattributes::ExampleBits ExampleBits::kMask = ::test_placementofattributes::ExampleBits(1u);
constexpr inline ::test_placementofattributes::ExampleBits ExampleBits::operator~() const {
return ::test_placementofattributes::ExampleBits(static_cast<uint32_t>(~this->value_ & kMask.value_));
}
constexpr inline ::test_placementofattributes::ExampleBits ExampleBits::operator|(
const ::test_placementofattributes::ExampleBits& other) const {
return ::test_placementofattributes::ExampleBits(static_cast<uint32_t>(this->value_ | other.value_));
}
constexpr inline ::test_placementofattributes::ExampleBits ExampleBits::operator&(
const ::test_placementofattributes::ExampleBits& other) const {
return ::test_placementofattributes::ExampleBits(static_cast<uint32_t>(this->value_ & other.value_));
}
constexpr inline ::test_placementofattributes::ExampleBits ExampleBits::operator^(
const ::test_placementofattributes::ExampleBits& other) const {
return ::test_placementofattributes::ExampleBits(static_cast<uint32_t>(this->value_ ^ other.value_));
}
constexpr inline ::test_placementofattributes::ExampleBits ExampleBits::operator-(
const ::test_placementofattributes::ExampleBits& other) const {
return ::test_placementofattributes::ExampleBits(static_cast<uint32_t>(this->value_ & ~other.value_));
}
constexpr inline void ExampleBits::operator|=(
const ::test_placementofattributes::ExampleBits& other) {
this->value_ |= other.value_;
}
constexpr inline void ExampleBits::operator&=(
const ::test_placementofattributes::ExampleBits& other) {
this->value_ &= other.value_;
}
constexpr inline void ExampleBits::operator^=(
const ::test_placementofattributes::ExampleBits& other) {
this->value_ ^= other.value_;
}
constexpr inline void ExampleBits::operator-=(
const ::test_placementofattributes::ExampleBits& other) {
this->value_ &= ~other.value_;
}
enum class ExampleEnum : uint32_t {
kMember = 1u,
};
} // namespace test_placementofattributes
template <>
struct fidl::internal::DisplayError<::test_placementofattributes::ExampleEnum> {
static size_t Format(const ::test_placementofattributes::ExampleEnum& value, char* destination, size_t capacity);
};
namespace fidl {
constexpr inline auto ToUnderlying(::test_placementofattributes::ExampleEnum value) -> uint32_t {
return static_cast<uint32_t>(value);
}
template <>
struct IsFidlType<::test_placementofattributes::ExampleBits> : public std::true_type {};
template <>
struct ContainsHandle<::test_placementofattributes::ExampleBits> : public std::false_type {};
static_assert(std::is_standard_layout_v<::test_placementofattributes::ExampleBits>);
static_assert(sizeof(::test_placementofattributes::ExampleBits) == sizeof(uint32_t));
template <>
struct IsFidlType<::test_placementofattributes::ExampleEnum> : public std::true_type {};
template <>
struct ContainsHandle<::test_placementofattributes::ExampleEnum> : public std::false_type {};
#pragma clang diagnostic pop
} // namespace fidl