| 28 | namespace cel { |
| 29 | |
| 30 | class Config { |
| 31 | public: |
| 32 | void SetName(std::string name) { name_ = std::move(name); } |
| 33 | std::string GetName() const { return name_; } |
| 34 | |
| 35 | struct ContainerConfig { |
| 36 | std::string name; |
| 37 | // TODO(uncreated-issue/87): add support for aliases and abbreviations. |
| 38 | |
| 39 | bool IsEmpty() const { return name.empty(); } |
| 40 | }; |
| 41 | |
| 42 | void SetContainerConfig(ContainerConfig container_config) { |
| 43 | container_config_ = std::move(container_config); |
| 44 | } |
| 45 | |
| 46 | const ContainerConfig& GetContainerConfig() const { |
| 47 | return container_config_; |
| 48 | } |
| 49 | |
| 50 | struct ExtensionConfig { |
| 51 | static constexpr int kLatest = std::numeric_limits<int>::max(); |
| 52 | |
| 53 | std::string name; |
| 54 | int version = kLatest; |
| 55 | }; |
| 56 | |
| 57 | absl::Status AddExtensionConfig(std::string name, |
| 58 | int version = ExtensionConfig::kLatest); |
| 59 | |
| 60 | const std::vector<ExtensionConfig>& GetExtensionConfigs() const { |
| 61 | return extension_configs_; |
| 62 | } |
| 63 | |
| 64 | struct StandardLibraryConfig { |
| 65 | // Exclude the entire standard library. |
| 66 | bool disable = false; |
| 67 | |
| 68 | // Exclude all standard library macros. |
| 69 | bool disable_macros = false; |
| 70 | |
| 71 | // Either included or excluded macros can be set, not both. If neither are |
| 72 | // set, all standard library macros are included. |
| 73 | absl::flat_hash_set<std::string> included_macros; |
| 74 | absl::flat_hash_set<std::string> excluded_macros; |
| 75 | |
| 76 | // Sets of pairs of function name and overload id to include or exclude. |
| 77 | // Either included or excluded functions can be set, not both. If neither |
| 78 | // are set, all standard library functions are included. |
| 79 | // If an overload is specified, only that overload is included or excluded. |
| 80 | // If no overload is specified (empty second element of pair), all overloads |
| 81 | // are included or excluded. |
| 82 | absl::flat_hash_set<std::pair<std::string, std::string>> included_functions; |
| 83 | absl::flat_hash_set<std::pair<std::string, std::string>> excluded_functions; |
| 84 | |
| 85 | bool IsEmpty() const { |
| 86 | return !disable && !disable_macros && included_macros.empty() && |
| 87 | excluded_macros.empty() && included_functions.empty() && |