From 7a5b729052d6622c23403d445f7937ed42334673 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 11 Jun 2014 18:41:16 +0100 Subject: [PATCH] Pkg: nicer Nasal syntax for tags in queries. --- src/Network/HTTPClient.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Network/HTTPClient.cxx b/src/Network/HTTPClient.cxx index cf35c950d..9e6e07ded 100644 --- a/src/Network/HTTPClient.cxx +++ b/src/Network/HTTPClient.cxx @@ -168,7 +168,6 @@ static naRef f_package_uninstall(pkg::Package& pkg, const nasal::CallContext& ct static SGPropertyNode_ptr queryPropsFromHash(const nasal::Hash& h) { SGPropertyNode_ptr props(new SGPropertyNode); - int tagCount = 0; for (nasal::Hash::const_iterator it = h.begin(); it != h.end(); ++it) { std::string const key = it->getKey(); @@ -176,9 +175,14 @@ static SGPropertyNode_ptr queryPropsFromHash(const nasal::Hash& h) props->setStringValue(key, it->getValue()); } else if (strutils::starts_with(key, "rating-")) { props->setIntValue(key, it->getValue()); - } else if (strutils::starts_with(key, "tag-")) { - SGPropertyNode_ptr tag = props->getChild("tag", tagCount++, true); - tag->setStringValue(key.substr(4)); + } else if (key == "tags") { + string_list tags = it->getValue(); + string_list::const_iterator tagIt; + int tagCount = 0; + for (tagIt = tags.begin(); tagIt != tags.end(); ++tagIt) { + SGPropertyNode_ptr tag = props->getChild("tag", tagCount++, true); + tag->setStringValue(*tagIt); + } } else { SG_LOG(SG_GENERAL, SG_WARN, "unknown filter term in hash:" << key); }