]> git.mxchange.org Git - flightgear.git/commitdiff
Pkg: nicer Nasal syntax for tags in queries.
authorJames Turner <zakalawe@mac.com>
Wed, 11 Jun 2014 17:41:16 +0000 (18:41 +0100)
committerJames Turner <zakalawe@mac.com>
Thu, 12 Jun 2014 07:17:05 +0000 (08:17 +0100)
src/Network/HTTPClient.cxx

index cf35c950d1ffb6596c44a66012b4f28c9b354717..9e6e07dedd7e15d4df3987eb0d9add0ad9203586 100644 (file)
@@ -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<std::string>());
         } else if (strutils::starts_with(key, "rating-")) {
             props->setIntValue(key, it->getValue<int>());
-        } 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>();
+            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);
         }