add option comments

This commit is contained in:
MoAlyousef
2020-09-14 16:39:57 +03:00
parent 3b09103d98
commit e6219d6571
5 changed files with 20 additions and 7 deletions
+14 -3
View File
@@ -69,12 +69,23 @@ CMake::CMake(const std::string &path, bool build) {
}
if (toml.contains("options")) {
using opts_map = std::map<std::string, bool>;
using opts_map =
std::map<std::string, toml::basic_value<toml::discard_comments, std::unordered_map,
std::vector>>;
const auto &opts = toml::find<opts_map>(toml, "options");
for (const auto opt: opts) {
for (const auto opt : opts) {
Option o;
o.name = opt.first;
o.val = opt.second;
if (opt.second.is_boolean()) {
o.val = opt.second.as_boolean();
} else {
if (opt.second.contains("comment")) {
o.comment = toml::find(opt.second, "comment").as_string();
}
if (opt.second.contains("value")) {
o.val = toml::find(opt.second, "value").as_boolean();
}
}
options.push_back(o);
}
}