MCPcopy Create free account
hub / github.com/build-cpp/cmkr / TomlCheckerRoot

Class TomlCheckerRoot

src/project_parser.cpp:171–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169};
170
171class TomlCheckerRoot {
172 const TomlBasicValue &m_root;
173 std::deque<TomlChecker> m_checkers;
174 tsl::ordered_set<toml::key> m_visisted;
175 bool m_checked = false;
176
177 public:
178 explicit TomlCheckerRoot(const TomlBasicValue &root) : m_root(root) {
179 }
180 TomlCheckerRoot(const TomlCheckerRoot &) = delete;
181 TomlCheckerRoot(TomlCheckerRoot &&) = delete;
182
183 bool contains(const toml::key &ky) {
184 m_visisted.emplace(ky);
185 return m_root.contains(ky);
186 }
187
188 TomlChecker &create(const TomlBasicValue &v) {
189 m_checkers.emplace_back(v);
190 return m_checkers.back();
191 }
192
193 TomlChecker &create(const TomlBasicValue &v, const toml::key &ky) {
194 m_checkers.emplace_back(v, ky);
195 return m_checkers.back();
196 }
197
198 void check(const tsl::ordered_map<std::string, std::string> &conditions, bool check_root) {
199 if (check_root) {
200 for (const auto &itr : m_root.as_table()) {
201 if (!m_visisted.contains(itr.first)) {
202 throw_key_error("Unknown key '" + itr.first + "'", itr.first, itr.second);
203 }
204 }
205 }
206 for (const auto &checker : m_checkers) {
207 checker.check(conditions);
208 }
209 }
210};
211
212Project::Project(const Project *parent, const std::string &path, bool build) : parent(parent) {
213 const auto toml_path = fs::path(path) / "cmake.toml";

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected