Coverage Report

Created: 2026-10-09 06:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/proc/self/cwd/base/function_result.h
Line
Count
Source
1
// Copyright 2022 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
#ifndef THIRD_PARTY_CEL_CPP_BASE_FUNCTION_RESULT_H_
16
#define THIRD_PARTY_CEL_CPP_BASE_FUNCTION_RESULT_H_
17
18
#include <cstdint>
19
#include <string>
20
#include <utility>
21
22
#include "absl/base/attributes.h"
23
#include "absl/strings/string_view.h"
24
#include "base/function_descriptor.h"
25
26
namespace cel {
27
28
// Represents a function result that is unknown at the time of execution. This
29
// allows for lazy evaluation of expensive functions.
30
class FunctionResult final {
31
 public:
32
  FunctionResult() = delete;
33
0
  FunctionResult(const FunctionResult&) = default;
34
0
  FunctionResult(FunctionResult&&) = default;
35
  FunctionResult& operator=(const FunctionResult&) = default;
36
  FunctionResult& operator=(FunctionResult&&) = default;
37
38
0
  explicit FunctionResult(std::string_view name) : name_(name) {}
39
40
0
  absl::string_view name() const ABSL_ATTRIBUTE_LIFETIME_BOUND { return name_; }
41
42
  // Equality operator provided for testing. Compatible with set less-than
43
  // comparator.
44
  // Compares descriptor then arguments elementwise.
45
0
  bool IsEqualTo(const FunctionResult& other) const {
46
0
    return name() == other.name();
47
0
  }
48
49
  // TODO(uncreated-issue/5): re-implement argument capture
50
51
 private:
52
  std::string name_;
53
};
54
55
0
inline bool operator==(const FunctionResult& lhs, const FunctionResult& rhs) {
56
0
  return lhs.IsEqualTo(rhs);
57
0
}
58
59
0
inline bool operator<(const FunctionResult& lhs, const FunctionResult& rhs) {
60
0
  return lhs.name() < rhs.name();
61
0
}
62
63
}  // namespace cel
64
65
#endif  // THIRD_PARTY_CEL_CPP_BASE_FUNCTION_RESULT_H_