Coverage Report

Created: 2026-07-16 06:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/proc/self/cwd/common/values/legacy_struct_value.cc
Line
Count
Source
1
// Copyright 2023 Google LLC
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include "absl/log/absl_check.h"
16
#include "absl/types/optional.h"
17
#include "common/type.h"
18
#include "common/value.h"
19
#include "google/protobuf/message.h"
20
21
namespace cel::common_internal {
22
23
1
StructType LegacyStructValue::GetRuntimeType() const {
24
1
  return MessageType(message_ptr_->GetDescriptor());
25
1
}
26
27
269
bool IsLegacyStructValue(const Value& value) {
28
269
  return value.variant_.Is<LegacyStructValue>();
29
269
}
30
31
3
LegacyStructValue GetLegacyStructValue(const Value& value) {
32
3
  ABSL_DCHECK(IsLegacyStructValue(value));
33
3
  return value.variant_.Get<LegacyStructValue>();
34
3
}
35
36
269
absl::optional<LegacyStructValue> AsLegacyStructValue(const Value& value) {
37
269
  if (IsLegacyStructValue(value)) {
38
3
    return GetLegacyStructValue(value);
39
3
  }
40
266
  return std::nullopt;
41
269
}
42
43
}  // namespace cel::common_internal