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

Method SetStandardLibraryConfig

env/config.cc:77–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77absl::Status Config::SetStandardLibraryConfig(
78 const Config::StandardLibraryConfig& standard_library_config) {
79 if (!standard_library_config.included_macros.empty() &&
80 !standard_library_config.excluded_macros.empty()) {
81 return absl::InvalidArgumentError(
82 "Cannot set both included and excluded macros.");
83 }
84
85 if (!standard_library_config.included_functions.empty() &&
86 !standard_library_config.excluded_functions.empty()) {
87 return absl::InvalidArgumentError(
88 "Cannot set both included and excluded functions.");
89 }
90
91 absl::flat_hash_set<std::string> included_function_names;
92 for (const auto& function : standard_library_config.included_functions) {
93 if (function.second.empty()) {
94 included_function_names.insert(function.first);
95 }
96 }
97 for (const auto& function : standard_library_config.included_functions) {
98 if (included_function_names.contains(function.first) &&
99 !function.second.empty()) {
100 return absl::InvalidArgumentError(absl::StrCat(
101 "Cannot include function '", function.first,
102 "' and also its specific overload '", function.second, "'"));
103 }
104 }
105
106 absl::flat_hash_set<std::string> excluded_function_names;
107 for (const auto& function : standard_library_config.excluded_functions) {
108 if (function.second.empty()) {
109 excluded_function_names.insert(function.first);
110 }
111 }
112 for (const auto& function : standard_library_config.excluded_functions) {
113 if (excluded_function_names.contains(function.first) &&
114 !function.second.empty()) {
115 return absl::InvalidArgumentError(absl::StrCat(
116 "Cannot exclude function '", function.first,
117 "' and also its specific overload '", function.second, "'"));
118 }
119 }
120
121 standard_library_config_ = standard_library_config;
122 return absl::OkStatus();
123}
124
125absl::Status Config::AddVariableConfig(const VariableConfig& variable_config) {
126 for (const VariableConfig& existing_variable_config : variable_configs_) {

Callers 4

GetExportTestCasesFunction · 0.80
TEST_PFunction · 0.80
TEST_PFunction · 0.80

Calls 1

emptyMethod · 0.45

Tested by 3

GetExportTestCasesFunction · 0.64
TEST_PFunction · 0.64
TEST_PFunction · 0.64