diff --git a/common/value.cc b/common/value.cc index fa937bdf0..bc8a3d7a0 100644 --- a/common/value.cc +++ b/common/value.cc @@ -43,7 +43,6 @@ #include "absl/types/source_location.h" #include "absl/types/variant.h" #include "common/allocator.h" -#include "common/optional_ref.h" #include "common/type.h" #include "common/value_kind.h" #include "common/values/list_value_builder.h" @@ -2007,60 +2006,6 @@ Value Value::WrapMapFieldValueUnsafe( message_factory, arena); } -optional_ref Value::AsBytes() const& { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -absl::optional Value::AsBytes() && { - if (auto* alternative = variant_.As(); alternative != nullptr) { - return std::move(*alternative); - } - return std::nullopt; -} - -absl::optional Value::AsDouble() const { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -absl::optional Value::AsDuration() const { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -optional_ref Value::AsError() const& { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -absl::optional Value::AsError() && { - if (auto* alternative = variant_.As(); alternative != nullptr) { - return std::move(*alternative); - } - return std::nullopt; -} - -absl::optional Value::AsInt() const { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - absl::optional Value::AsList() const& { if (const auto* alternative = variant_.As(); alternative != nullptr) { @@ -2141,205 +2086,6 @@ absl::optional Value::AsMap() && { return std::nullopt; } -absl::optional Value::AsMessage() const& { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -absl::optional Value::AsMessage() && { - if (auto* alternative = variant_.As(); - alternative != nullptr) { - return std::move(*alternative); - } - return std::nullopt; -} - -absl::optional Value::AsNull() const { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -optional_ref Value::AsOpaque() const& { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -absl::optional Value::AsOpaque() && { - if (auto* alternative = variant_.As(); alternative != nullptr) { - return std::move(*alternative); - } - return std::nullopt; -} - -optional_ref Value::AsOptional() const& { - if (const auto* alternative = variant_.As(); - alternative != nullptr && alternative->IsOptional()) { - return static_cast(*alternative); - } - return std::nullopt; -} - -absl::optional Value::AsOptional() && { - if (auto* alternative = variant_.As(); - alternative != nullptr && alternative->IsOptional()) { - return static_cast(*alternative); - } - return std::nullopt; -} - -optional_ref Value::AsParsedJsonList() const& { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -absl::optional Value::AsParsedJsonList() && { - if (auto* alternative = variant_.As(); - alternative != nullptr) { - return std::move(*alternative); - } - return std::nullopt; -} - -optional_ref Value::AsParsedJsonMap() const& { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -absl::optional Value::AsParsedJsonMap() && { - if (auto* alternative = variant_.As(); - alternative != nullptr) { - return std::move(*alternative); - } - return std::nullopt; -} - -optional_ref Value::AsCustomList() const& { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -absl::optional Value::AsCustomList() && { - if (auto* alternative = variant_.As(); - alternative != nullptr) { - return std::move(*alternative); - } - return std::nullopt; -} - -optional_ref Value::AsCustomMap() const& { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -absl::optional Value::AsCustomMap() && { - if (auto* alternative = variant_.As(); - alternative != nullptr) { - return std::move(*alternative); - } - return std::nullopt; -} - -optional_ref Value::AsParsedMapField() const& { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -absl::optional Value::AsParsedMapField() && { - if (auto* alternative = variant_.As(); - alternative != nullptr) { - return std::move(*alternative); - } - return std::nullopt; -} - -optional_ref Value::AsParsedMessage() const& { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -absl::optional Value::AsParsedMessage() && { - if (auto* alternative = variant_.As(); - alternative != nullptr) { - return std::move(*alternative); - } - return std::nullopt; -} - -optional_ref Value::AsParsedRepeatedField() - const& { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -absl::optional Value::AsParsedRepeatedField() && { - if (auto* alternative = variant_.As(); - alternative != nullptr) { - return std::move(*alternative); - } - return std::nullopt; -} - -optional_ref Value::AsCustomStruct() const& { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -absl::optional Value::AsCustomStruct() && { - if (auto* alternative = variant_.As(); - alternative != nullptr) { - return std::move(*alternative); - } - return std::nullopt; -} - -optional_ref Value::AsString() const& { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -absl::optional Value::AsString() && { - if (auto* alternative = variant_.As(); alternative != nullptr) { - return std::move(*alternative); - } - return std::nullopt; -} - absl::optional Value::AsStruct() const& { if (const auto* alternative = variant_.As(); @@ -2373,87 +2119,6 @@ absl::optional Value::AsStruct() && { return std::nullopt; } -absl::optional Value::AsTimestamp() const { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -optional_ref Value::AsType() const& { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -absl::optional Value::AsType() && { - if (auto* alternative = variant_.As(); alternative != nullptr) { - return std::move(*alternative); - } - return std::nullopt; -} - -absl::optional Value::AsUint() const { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -optional_ref Value::AsUnknown() const& { - if (const auto* alternative = variant_.As(); - alternative != nullptr) { - return *alternative; - } - return std::nullopt; -} - -absl::optional Value::AsUnknown() && { - if (auto* alternative = variant_.As(); alternative != nullptr) { - return std::move(*alternative); - } - return std::nullopt; -} - -const BytesValue& Value::GetBytes() const& { - ABSL_DCHECK(IsBytes()) << *this; - return variant_.Get(); -} - -BytesValue Value::GetBytes() && { - ABSL_DCHECK(IsBytes()) << *this; - return std::move(variant_).Get(); -} - -DoubleValue Value::GetDouble() const { - ABSL_DCHECK(IsDouble()) << *this; - return variant_.Get(); -} - -DurationValue Value::GetDuration() const { - ABSL_DCHECK(IsDuration()) << *this; - return variant_.Get(); -} - -const ErrorValue& Value::GetError() const& { - ABSL_DCHECK(IsError()) << *this; - return variant_.Get(); -} - -ErrorValue Value::GetError() && { - ABSL_DCHECK(IsError()) << *this; - return std::move(variant_).Get(); -} - -IntValue Value::GetInt() const { - ABSL_DCHECK(IsInt()) << *this; - return variant_.Get(); -} - #ifdef ABSL_HAVE_EXCEPTIONS #define CEL_VALUE_THROW_BAD_VARIANT_ACCESS() throw absl::bad_variant_access() #else @@ -2545,131 +2210,6 @@ MapValue Value::GetMap() && { CEL_VALUE_THROW_BAD_VARIANT_ACCESS(); } -MessageValue Value::GetMessage() const& { - ABSL_DCHECK(IsMessage()) << *this; - return variant_.Get(); -} - -MessageValue Value::GetMessage() && { - ABSL_DCHECK(IsMessage()) << *this; - return std::move(variant_).Get(); -} - -NullValue Value::GetNull() const { - ABSL_DCHECK(IsNull()) << *this; - return variant_.Get(); -} - -const OpaqueValue& Value::GetOpaque() const& { - ABSL_DCHECK(IsOpaque()) << *this; - return variant_.Get(); -} - -OpaqueValue Value::GetOpaque() && { - ABSL_DCHECK(IsOpaque()) << *this; - return std::move(variant_).Get(); -} - -const OptionalValue& Value::GetOptional() const& { - ABSL_DCHECK(IsOptional()) << *this; - return static_cast(variant_.Get()); -} - -OptionalValue Value::GetOptional() && { - ABSL_DCHECK(IsOptional()) << *this; - return static_cast(std::move(variant_).Get()); -} - -const ParsedJsonListValue& Value::GetParsedJsonList() const& { - ABSL_DCHECK(IsParsedJsonList()) << *this; - return variant_.Get(); -} - -ParsedJsonListValue Value::GetParsedJsonList() && { - ABSL_DCHECK(IsParsedJsonList()) << *this; - return std::move(variant_).Get(); -} - -const ParsedJsonMapValue& Value::GetParsedJsonMap() const& { - ABSL_DCHECK(IsParsedJsonMap()) << *this; - return variant_.Get(); -} - -ParsedJsonMapValue Value::GetParsedJsonMap() && { - ABSL_DCHECK(IsParsedJsonMap()) << *this; - return std::move(variant_).Get(); -} - -const CustomListValue& Value::GetCustomList() const& { - ABSL_DCHECK(IsCustomList()) << *this; - return variant_.Get(); -} - -CustomListValue Value::GetCustomList() && { - ABSL_DCHECK(IsCustomList()) << *this; - return std::move(variant_).Get(); -} - -const CustomMapValue& Value::GetCustomMap() const& { - ABSL_DCHECK(IsCustomMap()) << *this; - return variant_.Get(); -} - -CustomMapValue Value::GetCustomMap() && { - ABSL_DCHECK(IsCustomMap()) << *this; - return std::move(variant_).Get(); -} - -const ParsedMapFieldValue& Value::GetParsedMapField() const& { - ABSL_DCHECK(IsParsedMapField()) << *this; - return variant_.Get(); -} - -ParsedMapFieldValue Value::GetParsedMapField() && { - ABSL_DCHECK(IsParsedMapField()) << *this; - return std::move(variant_).Get(); -} - -const ParsedMessageValue& Value::GetParsedMessage() const& { - ABSL_DCHECK(IsParsedMessage()) << *this; - return variant_.Get(); -} - -ParsedMessageValue Value::GetParsedMessage() && { - ABSL_DCHECK(IsParsedMessage()) << *this; - return std::move(variant_).Get(); -} - -const ParsedRepeatedFieldValue& Value::GetParsedRepeatedField() const& { - ABSL_DCHECK(IsParsedRepeatedField()) << *this; - return variant_.Get(); -} - -ParsedRepeatedFieldValue Value::GetParsedRepeatedField() && { - ABSL_DCHECK(IsParsedRepeatedField()) << *this; - return std::move(variant_).Get(); -} - -const CustomStructValue& Value::GetCustomStruct() const& { - ABSL_DCHECK(IsCustomStruct()) << *this; - return variant_.Get(); -} - -CustomStructValue Value::GetCustomStruct() && { - ABSL_DCHECK(IsCustomStruct()) << *this; - return std::move(variant_).Get(); -} - -const StringValue& Value::GetString() const& { - ABSL_DCHECK(IsString()) << *this; - return variant_.Get(); -} - -StringValue Value::GetString() && { - ABSL_DCHECK(IsString()) << *this; - return std::move(variant_).Get(); -} - StructValue Value::GetStruct() const& { ABSL_DCHECK(IsStruct()) << *this; if (const auto* alternative = @@ -2705,36 +2245,6 @@ StructValue Value::GetStruct() && { CEL_VALUE_THROW_BAD_VARIANT_ACCESS(); } -TimestampValue Value::GetTimestamp() const { - ABSL_DCHECK(IsTimestamp()) << *this; - return variant_.Get(); -} - -const TypeValue& Value::GetType() const& { - ABSL_DCHECK(IsType()) << *this; - return variant_.Get(); -} - -TypeValue Value::GetType() && { - ABSL_DCHECK(IsType()) << *this; - return std::move(variant_).Get(); -} - -UintValue Value::GetUint() const { - ABSL_DCHECK(IsUint()) << *this; - return variant_.Get(); -} - -const UnknownValue& Value::GetUnknown() const& { - ABSL_DCHECK(IsUnknown()) << *this; - return variant_.Get(); -} - -UnknownValue Value::GetUnknown() && { - ABSL_DCHECK(IsUnknown()) << *this; - return std::move(variant_).Get(); -} - namespace { class EmptyValueIterator final : public ValueIterator { diff --git a/common/value.h b/common/value.h index c2c8a0c7a..9278cf4de 100644 --- a/common/value.h +++ b/common/value.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -2946,6 +2947,498 @@ absl::StatusOr RepeatedFieldAccessorFor( inline BytesValue::BytesValue(const StringValue& other) : BytesValue(other.value_) {} +inline optional_ref Value::AsBytes() const& { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline absl::optional Value::AsBytes() && { + if (auto* alternative = variant_.As(); alternative != nullptr) { + return std::move(*alternative); + } + return std::nullopt; +} + +inline absl::optional Value::AsDouble() const { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline absl::optional Value::AsDuration() const { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline optional_ref Value::AsError() const& { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline absl::optional Value::AsError() && { + if (auto* alternative = variant_.As(); alternative != nullptr) { + return std::move(*alternative); + } + return std::nullopt; +} + +inline absl::optional Value::AsInt() const { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline absl::optional Value::AsMessage() const& { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline absl::optional Value::AsMessage() && { + if (auto* alternative = variant_.As(); + alternative != nullptr) { + return std::move(*alternative); + } + return std::nullopt; +} + +inline absl::optional Value::AsNull() const { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline optional_ref Value::AsOpaque() const& { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline absl::optional Value::AsOpaque() && { + if (auto* alternative = variant_.As(); alternative != nullptr) { + return std::move(*alternative); + } + return std::nullopt; +} + +inline optional_ref Value::AsOptional() const& { + if (const auto* alternative = variant_.As(); + alternative != nullptr && alternative->IsOptional()) { + return static_cast(*alternative); + } + return std::nullopt; +} + +inline absl::optional Value::AsOptional() && { + if (auto* alternative = variant_.As(); + alternative != nullptr && alternative->IsOptional()) { + return static_cast(*alternative); + } + return std::nullopt; +} + +inline optional_ref Value::AsParsedJsonList() + const& { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline absl::optional Value::AsParsedJsonList() && { + if (auto* alternative = variant_.As(); + alternative != nullptr) { + return std::move(*alternative); + } + return std::nullopt; +} + +inline optional_ref Value::AsParsedJsonMap() const& { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline absl::optional Value::AsParsedJsonMap() && { + if (auto* alternative = variant_.As(); + alternative != nullptr) { + return std::move(*alternative); + } + return std::nullopt; +} + +inline optional_ref Value::AsCustomList() const& { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline absl::optional Value::AsCustomList() && { + if (auto* alternative = variant_.As(); + alternative != nullptr) { + return std::move(*alternative); + } + return std::nullopt; +} + +inline optional_ref Value::AsCustomMap() const& { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline absl::optional Value::AsCustomMap() && { + if (auto* alternative = variant_.As(); + alternative != nullptr) { + return std::move(*alternative); + } + return std::nullopt; +} + +inline optional_ref Value::AsParsedMapField() + const& { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline absl::optional Value::AsParsedMapField() && { + if (auto* alternative = variant_.As(); + alternative != nullptr) { + return std::move(*alternative); + } + return std::nullopt; +} + +inline optional_ref Value::AsParsedMessage() const& { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline absl::optional Value::AsParsedMessage() && { + if (auto* alternative = variant_.As(); + alternative != nullptr) { + return std::move(*alternative); + } + return std::nullopt; +} + +inline optional_ref +Value::AsParsedRepeatedField() const& { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline absl::optional +Value::AsParsedRepeatedField() && { + if (auto* alternative = variant_.As(); + alternative != nullptr) { + return std::move(*alternative); + } + return std::nullopt; +} + +inline optional_ref Value::AsCustomStruct() const& { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline absl::optional Value::AsCustomStruct() && { + if (auto* alternative = variant_.As(); + alternative != nullptr) { + return std::move(*alternative); + } + return std::nullopt; +} + +inline optional_ref Value::AsString() const& { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline absl::optional Value::AsString() && { + if (auto* alternative = variant_.As(); alternative != nullptr) { + return std::move(*alternative); + } + return std::nullopt; +} + +inline absl::optional Value::AsTimestamp() const { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline optional_ref Value::AsType() const& { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline absl::optional Value::AsType() && { + if (auto* alternative = variant_.As(); alternative != nullptr) { + return std::move(*alternative); + } + return std::nullopt; +} + +inline absl::optional Value::AsUint() const { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline optional_ref Value::AsUnknown() const& { + if (const auto* alternative = variant_.As(); + alternative != nullptr) { + return *alternative; + } + return std::nullopt; +} + +inline absl::optional Value::AsUnknown() && { + if (auto* alternative = variant_.As(); alternative != nullptr) { + return std::move(*alternative); + } + return std::nullopt; +} + +inline const BytesValue& Value::GetBytes() const& { + ABSL_DCHECK(IsBytes()) << *this; + return variant_.Get(); +} + +inline BytesValue Value::GetBytes() && { + ABSL_DCHECK(IsBytes()) << *this; + return std::move(variant_).Get(); +} + +inline DoubleValue Value::GetDouble() const { + ABSL_DCHECK(IsDouble()) << *this; + return variant_.Get(); +} + +inline DurationValue Value::GetDuration() const { + ABSL_DCHECK(IsDuration()) << *this; + return variant_.Get(); +} + +inline const ErrorValue& Value::GetError() const& { + ABSL_DCHECK(IsError()) << *this; + return variant_.Get(); +} + +inline ErrorValue Value::GetError() && { + ABSL_DCHECK(IsError()) << *this; + return std::move(variant_).Get(); +} + +inline IntValue Value::GetInt() const { + ABSL_DCHECK(IsInt()) << *this; + return variant_.Get(); +} + +inline MessageValue Value::GetMessage() const& { + ABSL_DCHECK(IsMessage()) << *this; + return variant_.Get(); +} + +inline MessageValue Value::GetMessage() && { + ABSL_DCHECK(IsMessage()) << *this; + return std::move(variant_).Get(); +} + +inline NullValue Value::GetNull() const { + ABSL_DCHECK(IsNull()) << *this; + return variant_.Get(); +} + +inline const OpaqueValue& Value::GetOpaque() const& { + ABSL_DCHECK(IsOpaque()) << *this; + return variant_.Get(); +} + +inline OpaqueValue Value::GetOpaque() && { + ABSL_DCHECK(IsOpaque()) << *this; + return std::move(variant_).Get(); +} + +inline const OptionalValue& Value::GetOptional() const& { + ABSL_DCHECK(IsOptional()) << *this; + return static_cast(variant_.Get()); +} + +inline OptionalValue Value::GetOptional() && { + ABSL_DCHECK(IsOptional()) << *this; + return static_cast(std::move(variant_).Get()); +} + +inline const ParsedJsonListValue& Value::GetParsedJsonList() const& { + ABSL_DCHECK(IsParsedJsonList()) << *this; + return variant_.Get(); +} + +inline ParsedJsonListValue Value::GetParsedJsonList() && { + ABSL_DCHECK(IsParsedJsonList()) << *this; + return std::move(variant_).Get(); +} + +inline const ParsedJsonMapValue& Value::GetParsedJsonMap() const& { + ABSL_DCHECK(IsParsedJsonMap()) << *this; + return variant_.Get(); +} + +inline ParsedJsonMapValue Value::GetParsedJsonMap() && { + ABSL_DCHECK(IsParsedJsonMap()) << *this; + return std::move(variant_).Get(); +} + +inline const CustomListValue& Value::GetCustomList() const& { + ABSL_DCHECK(IsCustomList()) << *this; + return variant_.Get(); +} + +inline CustomListValue Value::GetCustomList() && { + ABSL_DCHECK(IsCustomList()) << *this; + return std::move(variant_).Get(); +} + +inline const CustomMapValue& Value::GetCustomMap() const& { + ABSL_DCHECK(IsCustomMap()) << *this; + return variant_.Get(); +} + +inline CustomMapValue Value::GetCustomMap() && { + ABSL_DCHECK(IsCustomMap()) << *this; + return std::move(variant_).Get(); +} + +inline const ParsedMapFieldValue& Value::GetParsedMapField() const& { + ABSL_DCHECK(IsParsedMapField()) << *this; + return variant_.Get(); +} + +inline ParsedMapFieldValue Value::GetParsedMapField() && { + ABSL_DCHECK(IsParsedMapField()) << *this; + return std::move(variant_).Get(); +} + +inline const ParsedMessageValue& Value::GetParsedMessage() const& { + ABSL_DCHECK(IsParsedMessage()) << *this; + return variant_.Get(); +} + +inline ParsedMessageValue Value::GetParsedMessage() && { + ABSL_DCHECK(IsParsedMessage()) << *this; + return std::move(variant_).Get(); +} + +inline const ParsedRepeatedFieldValue& Value::GetParsedRepeatedField() const& { + ABSL_DCHECK(IsParsedRepeatedField()) << *this; + return variant_.Get(); +} + +inline ParsedRepeatedFieldValue Value::GetParsedRepeatedField() && { + ABSL_DCHECK(IsParsedRepeatedField()) << *this; + return std::move(variant_).Get(); +} + +inline const CustomStructValue& Value::GetCustomStruct() const& { + ABSL_DCHECK(IsCustomStruct()) << *this; + return variant_.Get(); +} + +inline CustomStructValue Value::GetCustomStruct() && { + ABSL_DCHECK(IsCustomStruct()) << *this; + return std::move(variant_).Get(); +} + +inline const StringValue& Value::GetString() const& { + ABSL_DCHECK(IsString()) << *this; + return variant_.Get(); +} + +inline StringValue Value::GetString() && { + ABSL_DCHECK(IsString()) << *this; + return std::move(variant_).Get(); +} + +inline TimestampValue Value::GetTimestamp() const { + ABSL_DCHECK(IsTimestamp()) << *this; + return variant_.Get(); +} + +inline const TypeValue& Value::GetType() const& { + ABSL_DCHECK(IsType()) << *this; + return variant_.Get(); +} + +inline TypeValue Value::GetType() && { + ABSL_DCHECK(IsType()) << *this; + return std::move(variant_).Get(); +} + +inline UintValue Value::GetUint() const { + ABSL_DCHECK(IsUint()) << *this; + return variant_.Get(); +} + +inline const UnknownValue& Value::GetUnknown() const& { + ABSL_DCHECK(IsUnknown()) << *this; + return variant_.Get(); +} + +inline UnknownValue Value::GetUnknown() && { + ABSL_DCHECK(IsUnknown()) << *this; + return std::move(variant_).Get(); +} + } // namespace cel #pragma pop_macro("GetMessage")