Coverage Report

Created: 2026-05-27 07:00

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
0
StructType LegacyStructValue::GetRuntimeType() const {
24
0
  return MessageType(message_ptr_->GetDescriptor());
25
0
}
26
27
2
bool IsLegacyStructValue(const Value& value) {
28
2
  return value.variant_.Is<LegacyStructValue>();
29
2
}
30
31
1
LegacyStructValue GetLegacyStructValue(const Value& value) {
32
1
  ABSL_DCHECK(IsLegacyStructValue(value));
33
1
  return value.variant_.Get<LegacyStructValue>();
34
1
}
35
36
2
absl::optional<LegacyStructValue> AsLegacyStructValue(const Value& value) {
37
2
  if (IsLegacyStructValue(value)) {
38
1
    return GetLegacyStructValue(value);
39
1
  }
40
1
  return absl::nullopt;
41
2
}
42
43
}  // namespace cel::common_internal