`Value` is a composition type which encompasses all values supported by the Common Expression Language. When default constructed or moved, `Value` is in a known but invalid state. Any attempt to use it from then on, without assigning another type, is undefined behavior. In debug builds, we do our best to fail.
| 97 | // assigning another type, is undefined behavior. In debug builds, we do our |
| 98 | // best to fail. |
| 99 | class Value final : private common_internal::ValueMixin<Value> { |
| 100 | public: |
| 101 | // Returns an appropriate `Value` for the dynamic protobuf enum. For open |
| 102 | // enums, returns `cel::IntValue`. For closed enums, returns `cel::ErrorValue` |
| 103 | // if the value is not present in the enum otherwise returns `cel::IntValue`. |
| 104 | static Value Enum(const google::protobuf::EnumValueDescriptor* absl_nonnull value); |
| 105 | static Value Enum(const google::protobuf::EnumDescriptor* absl_nonnull type, |
| 106 | int32_t number); |
| 107 | |
| 108 | // SFINAE overload for generated protobuf enums which are not well-known. |
| 109 | // Always returns `cel::IntValue`. |
| 110 | template <typename T> |
| 111 | static common_internal::EnableIfGeneratedEnum<T, IntValue> Enum(T value) { |
| 112 | return IntValue(value); |
| 113 | } |
| 114 | |
| 115 | // SFINAE overload for google::protobuf::NullValue. Always returns |
| 116 | // `cel::NullValue`. |
| 117 | template <typename T> |
| 118 | static common_internal::EnableIfWellKnownEnum<T, google::protobuf::NullValue, |
| 119 | NullValue> |
| 120 | Enum(T) { |
| 121 | return NullValue(); |
| 122 | } |
| 123 | |
| 124 | // Returns an appropriate `Value` for the dynamic protobuf message. If |
| 125 | // `message` is the well known type `google.protobuf.Any`, `descriptor_pool` |
| 126 | // and `message_factory` will be used to unpack the value. Both must outlive |
| 127 | // the resulting value and any of its shallow copies. Otherwise the message is |
| 128 | // copied using `arena`. |
| 129 | static Value FromMessage( |
| 130 | const google::protobuf::Message& message, |
| 131 | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool |
| 132 | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
| 133 | google::protobuf::MessageFactory* absl_nonnull message_factory |
| 134 | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
| 135 | google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND); |
| 136 | static Value FromMessage( |
| 137 | google::protobuf::Message&& message, |
| 138 | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool |
| 139 | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
| 140 | google::protobuf::MessageFactory* absl_nonnull message_factory |
| 141 | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
| 142 | google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND); |
| 143 | |
| 144 | // Returns an appropriate `Value` for the dynamic protobuf message. If |
| 145 | // `message` is the well known type `google.protobuf.Any`, `descriptor_pool` |
| 146 | // and `message_factory` will be used to unpack the value. Both must outlive |
| 147 | // the resulting value and any of its shallow copies. Otherwise the message is |
| 148 | // borrowed (no copying). If the message is on an arena, that arena will be |
| 149 | // attributed as the owner. Otherwise `arena` is used. |
| 150 | static Value WrapMessage( |
| 151 | const google::protobuf::Message* absl_nonnull message ABSL_ATTRIBUTE_LIFETIME_BOUND, |
| 152 | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool |
| 153 | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
| 154 | google::protobuf::MessageFactory* absl_nonnull message_factory |
| 155 | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
| 156 | google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND); |