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

Method optional

src/project_parser.cpp:82–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80
81 template <typename T>
82 void optional(const toml::key &ky, Condition<T> &destination) {
83 // TODO: this algorithm in O(n) over the amount of keys, kinda bad
84 const auto &table = m_v.as_table();
85 for (const auto &itr : table) {
86 const auto &key = itr.first;
87 const auto &value = itr.second;
88 if (value.is_table()) {
89 if (value.contains(ky)) {
90 destination[key] = toml::find<T>(value, ky);
91 }
92 } else if (key == ky) {
93 destination[""] = toml::find<T>(m_v, ky);
94 }
95 }
96
97 // Handle visiting logic
98 for (const auto &itr : destination) {
99 if (!itr.first.empty()) {
100 m_conditionVisited.emplace(itr.first);
101 }
102 }
103 visit(ky);
104 }
105
106 template <typename T>
107 void optional(const toml::key &ky, T &destination) {

Callers 1

ProjectMethod · 0.80

Calls 2

emptyMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected