/proc/self/cwd/extensions/protobuf/ast_converters.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_EXTENSIONS_PROTOBUF_AST_CONVERTERS_H_ |
16 | | #define THIRD_PARTY_CEL_CPP_EXTENSIONS_PROTOBUF_AST_CONVERTERS_H_ |
17 | | |
18 | | #include <memory> |
19 | | |
20 | | #include "cel/expr/checked.pb.h" |
21 | | #include "cel/expr/syntax.pb.h" |
22 | | #include "absl/base/attributes.h" |
23 | | #include "absl/status/statusor.h" |
24 | | #include "common/ast.h" |
25 | | #include "common/ast_proto.h" |
26 | | |
27 | | namespace cel::extensions { |
28 | | |
29 | | // Creates a runtime AST from a parsed-only protobuf AST. |
30 | | // May return a non-ok Status if the AST is malformed (e.g. unset required |
31 | | // fields). |
32 | | ABSL_DEPRECATED("Use cel::CreateAstFromParsedExpr instead.") |
33 | | inline absl::StatusOr<std::unique_ptr<Ast>> CreateAstFromParsedExpr( |
34 | | const cel::expr::Expr& expr, |
35 | 10.3k | const cel::expr::SourceInfo* source_info = nullptr) { |
36 | 10.3k | return cel::CreateAstFromParsedExpr(expr, source_info); |
37 | 10.3k | } |
38 | | |
39 | | ABSL_DEPRECATED("Use cel::CreateAstFromParsedExpr instead.") |
40 | | inline absl::StatusOr<std::unique_ptr<Ast>> CreateAstFromParsedExpr( |
41 | 0 | const cel::expr::ParsedExpr& parsed_expr) { |
42 | 0 | return cel::CreateAstFromParsedExpr(parsed_expr); |
43 | 0 | } |
44 | | |
45 | | // Creates a runtime AST from a checked protobuf AST. |
46 | | // May return a non-ok Status if the AST is malformed (e.g. unset required |
47 | | // fields). |
48 | | ABSL_DEPRECATED("Use cel::CreateAstFromCheckedExpr instead.") |
49 | | inline absl::StatusOr<std::unique_ptr<Ast>> CreateAstFromCheckedExpr( |
50 | 0 | const cel::expr::CheckedExpr& checked_expr) { |
51 | 0 | return cel::CreateAstFromCheckedExpr(checked_expr); |
52 | 0 | } |
53 | | |
54 | | } // namespace cel::extensions |
55 | | |
56 | | #endif // THIRD_PARTY_CEL_CPP_EXTENSIONS_PROTOBUF_AST_CONVERTERS_H_ |