diff options
Diffstat (limited to 'src/libfetchers/attrs.cc')
-rw-r--r-- | src/libfetchers/attrs.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libfetchers/attrs.cc b/src/libfetchers/attrs.cc index 40c02de42..feb0a6085 100644 --- a/src/libfetchers/attrs.cc +++ b/src/libfetchers/attrs.cc @@ -89,4 +89,19 @@ bool getBoolAttr(const Attrs & attrs, const std::string & name) return *s; } +std::map<std::string, std::string> attrsToQuery(const Attrs & attrs) +{ + std::map<std::string, std::string> query; + for (auto & attr : attrs) { + if (auto v = std::get_if<int64_t>(&attr.second)) { + query.insert_or_assign(attr.first, fmt("%d", *v)); + } else if (auto v = std::get_if<std::string>(&attr.second)) { + query.insert_or_assign(attr.first, *v); + } else if (auto v = std::get_if<Explicit<bool>>(&attr.second)) { + query.insert_or_assign(attr.first, v->t ? "1" : "0"); + } else abort(); + } + return query; +} + } |