MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / ExtensionSpec

Class ExtensionSpec

common/ast/metadata.h:39–153  ·  view source on GitHub ↗

An extension that was requested for the source expression.

Source from the content-addressed store, hash-verified

37
38// An extension that was requested for the source expression.
39class ExtensionSpec {
40 public:
41 // Version
42 class Version {
43 public:
44 Version() : major_(0), minor_(0) {}
45 Version(int64_t major, int64_t minor) : major_(major), minor_(minor) {}
46
47 Version(const Version& other) = default;
48 Version(Version&& other) = default;
49 Version& operator=(const Version& other) = default;
50 Version& operator=(Version&& other) = default;
51
52 static const Version& DefaultInstance();
53
54 // Major version changes indicate different required support level from
55 // the required components.
56 int64_t major() const { return major_; }
57 void set_major(int64_t val) { major_ = val; }
58
59 // Minor version changes must not change the observed behavior from
60 // existing implementations, but may be provided informationally.
61 int64_t minor() const { return minor_; }
62 void set_minor(int64_t val) { minor_ = val; }
63
64 bool operator==(const Version& other) const {
65 return major_ == other.major_ && minor_ == other.minor_;
66 }
67
68 bool operator!=(const Version& other) const { return !operator==(other); }
69
70 private:
71 int64_t major_;
72 int64_t minor_;
73 };
74
75 // CEL component specifier.
76 enum class Component {
77 // Unspecified, default.
78 kUnspecified,
79 // Parser. Converts a CEL string to an AST.
80 kParser,
81 // Type checker. Checks that references in an AST are defined and types
82 // agree.
83 kTypeChecker,
84 // Runtime. Evaluates a parsed and optionally checked CEL AST against a
85 // context.
86 kRuntime
87 };
88
89 static const ExtensionSpec& DefaultInstance();
90
91 ExtensionSpec() = default;
92 ExtensionSpec(std::string id, std::unique_ptr<Version> version,
93 std::vector<Component> affected_components)
94 : id_(std::move(id)),
95 affected_components_(std::move(affected_components)),
96 version_(std::move(version)) {}

Callers 5

TESTFunction · 0.85
CheckMethod · 0.85
TESTFunction · 0.85
TESTFunction · 0.85

Calls

no outgoing calls

Tested by 3

TESTFunction · 0.68
TESTFunction · 0.68
TESTFunction · 0.68