Fix the build but the code is still untested.
This commit is contained in:
parent
6dffe9b848
commit
b39621ea51
1 changed files with 29 additions and 27 deletions
|
@ -173,11 +173,36 @@ namespace duck { namespace sl {
|
|||
MustacheEntry* m_current_mustache;
|
||||
};
|
||||
|
||||
mstch::map to_mustache_dict_recursive (const EntryNode& parNode, std::string_view parSrc, XPAthRunner& parRunner) {
|
||||
mstch::map to_mustache_dict_recursive (const EntryNode& parNode, std::string_view parSrc, XPathRunner& parRunner) {
|
||||
mstch::map retval;
|
||||
for (const XPathElement* xpath : parNode.xpaths) {
|
||||
assert(xpath);
|
||||
std::cout << "Running query for \"" << xpath->name << "\"\n";
|
||||
auto results = parRunner.query(parSrc, xpath->xpath);
|
||||
if (results.size() == 1) {
|
||||
retval[xpath->name] = results.front();
|
||||
}
|
||||
else if (results.size() > 1) {
|
||||
mstch::array values;
|
||||
values.reserve(results.size());
|
||||
std::copy(results.begin(), results.end(), std::back_inserter(values));
|
||||
retval[xpath->name] = std::move(values);
|
||||
}
|
||||
else if (xpath->def_val) {
|
||||
retval[xpath->name] = *xpath->def_val;
|
||||
}
|
||||
else {
|
||||
retval[xpath->name] = std::string();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& curr_struct : parNode.structs) {
|
||||
assert(not curr_struct.name.empty());
|
||||
retval[std::string(curr_struct.name)] =
|
||||
to_mustache_dict_recursive(curr_struct, parSrc, parRunner);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
mstch::map to_mustache_map (const EntryNodeList& parNodes, XPathRunner& parRunner) {
|
||||
|
@ -195,32 +220,9 @@ namespace duck { namespace sl {
|
|||
assert(false); //not implemented
|
||||
}
|
||||
|
||||
//mstch::map curr_entry_map = to_mustache_dict_recursive(
|
||||
for (const XPathElement* xpath : entry.second.xpaths) {
|
||||
assert(xpath);
|
||||
std::cout << "Running query for \"" << xpath->name << "\"\n";
|
||||
auto results = parRunner.query(src_url, xpath->xpath);
|
||||
if (results.size() == 1) {
|
||||
retval[xpath->name] = results.front();
|
||||
}
|
||||
else if (results.size() > 1) {
|
||||
mstch::array values;
|
||||
values.reserve(results.size());
|
||||
std::copy(results.begin(), results.end(), std::back_inserter(values));
|
||||
retval[xpath->name] = std::move(values);
|
||||
}
|
||||
else if (xpath->def_val) {
|
||||
retval[xpath->name] = *xpath->def_val;
|
||||
}
|
||||
else {
|
||||
retval[xpath->name] = std::string();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& curr_struct : entry.second.structs) {
|
||||
assert(not curr_struct.name.empty());
|
||||
retval[curr_struct.name] = struct_to_mustache(curr_struct, src_url, parRunner);
|
||||
}
|
||||
mstch::map curr_entry_map = to_mustache_dict_recursive(entry.second, src_url, parRunner);
|
||||
curr_entry_map.merge(std::move(retval));
|
||||
retval.swap(curr_entry_map);
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
|
Loading…
Reference in a new issue