66#include < stdexcept>
77#include < toml.hpp>
88#include < tsl/ordered_map.h>
9- #include < tsl/ordered_set.h>
109
1110template <>
1211const char *enumStrings<cmkr::parser::TargetType>::data[] = {" executable" , " library" , " shared" , " static" , " interface" , " custom" , " object" };
1312
1413namespace cmkr {
1514namespace parser {
1615
17- using TomlBasicValue = toml::basic_value<toml::preserve_comments , tsl::ordered_map, std::vector>;
16+ using TomlBasicValue = toml::basic_value<toml::discard_comments , tsl::ordered_map, std::vector>;
1817
1918template <typename EnumType>
2019static EnumType to_enum (const std::string &str, const std::string &help_name) {
@@ -63,8 +62,8 @@ static std::string format_key_error(const std::string &error, const toml::key &k
6362
6463class TomlChecker {
6564 const TomlBasicValue &m_v;
66- tsl::ordered_set <toml::key> m_visited;
67- tsl::ordered_set <toml::key> m_conditionVisited;
65+ tsl::ordered_map <toml::key, bool > m_visited;
66+ tsl::ordered_map <toml::key, bool > m_conditionVisited;
6867
6968 public:
7069 TomlChecker (const TomlBasicValue &v, const toml::key &ky) : m_v(toml::find(v, ky)) {}
@@ -91,7 +90,7 @@ class TomlChecker {
9190 // Handle visiting logic
9291 for (const auto &itr : destination) {
9392 if (!itr.first .empty ()) {
94- m_conditionVisited.emplace (itr.first );
93+ m_conditionVisited.emplace (itr.first , true );
9594 }
9695 }
9796 visit (ky);
@@ -122,7 +121,7 @@ class TomlChecker {
122121 return toml::find (m_v, ky);
123122 }
124123
125- void visit (const toml::key &ky) { m_visited.insert (ky); }
124+ void visit (const toml::key &ky) { m_visited.emplace (ky, true ); }
126125
127126 void check (const tsl::ordered_map<std::string, std::string> &conditions) const {
128127 for (const auto &itr : m_v.as_table ()) {
@@ -182,7 +181,7 @@ Project::Project(const Project *parent, const std::string &path, bool build) {
182181 if (!fs::exists (toml_path)) {
183182 throw std::runtime_error (" No cmake.toml was found!" );
184183 }
185- const auto toml = toml::parse<toml::preserve_comments , tsl::ordered_map, std::vector>(toml_path.string ());
184+ const auto toml = toml::parse<toml::discard_comments , tsl::ordered_map, std::vector>(toml_path.string ());
186185
187186 TomlCheckerRoot checker;
188187
@@ -274,7 +273,7 @@ Project::Project(const Project *parent, const std::string &path, bool build) {
274273 }
275274
276275 if (toml.contains (" settings" )) {
277- using set_map = std::map <std::string, TomlBasicValue>;
276+ using set_map = tsl::ordered_map <std::string, TomlBasicValue>;
278277 const auto &sets = toml::find<set_map>(toml, " settings" );
279278 for (const auto &itr : sets) {
280279 Setting s;
@@ -507,7 +506,7 @@ bool is_root_path(const std::string &path) {
507506 if (!fs::exists (toml_path)) {
508507 return false ;
509508 }
510- const auto toml = toml::parse<toml::preserve_comments , tsl::ordered_map, std::vector>(toml_path.string ());
509+ const auto toml = toml::parse<toml::discard_comments , tsl::ordered_map, std::vector>(toml_path.string ());
511510 return toml.contains (" project" );
512511}
513512
0 commit comments