aboutsummaryrefslogtreecommitdiff
path: root/brep/package.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-10-19 15:28:19 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-10-28 01:53:51 +0200
commit5b336ac46f60606cdcf77889d624ce15cdd62530 (patch)
tree469c0dd598b072d13b9a27f458c96c8353745638 /brep/package.cxx
parent3e37999a5f9efd4caf44c40985b3e1254660a625 (diff)
Implement package search by terms
Diffstat (limited to 'brep/package.cxx')
-rw-r--r--brep/package.cxx42
1 files changed, 42 insertions, 0 deletions
diff --git a/brep/package.cxx b/brep/package.cxx
index fd40bc6..9b7d24a 100644
--- a/brep/package.cxx
+++ b/brep/package.cxx
@@ -66,6 +66,48 @@ namespace brep
external_repositories.emplace_back (move (rp));
}
+ weighted_text package::
+ search_text () const
+ {
+ if (internal_repository == nullptr)
+ return weighted_text ();
+
+ // Derive keywords from the basic package information: name,
+ // version.
+ //
+ //@@ What about 'stable' from cppget.org/stable? Add path of
+ // the repository to keywords? Or is it too "polluting" and
+ // we will handle it in some other way (e.g., by allowing
+ // the user to specify repo location in the drop-down box)?
+ // Probably drop-box would be better as also tells what are
+ // the available internal repositories.
+ //
+ string k (id.name + " " + version.string () + " " + version.string (true));
+
+ // Add tags to keywords.
+ //
+ for (const auto& t: tags)
+ k += " " + t;
+
+ // Add licenses to keywords.
+ //
+ for (const auto& la: license_alternatives)
+ {
+ for (const auto& l: la)
+ {
+ k += " " + l;
+
+ // If license is say LGPLv2 then LGPL is also a keyword.
+ //
+ size_t n (l.size ());
+ if (n > 2 && l[n - 2] == 'v' && l[n - 1] >= '0' && l[n - 1] <= '9')
+ k += " " + string (l, 0, n - 2);
+ }
+ }
+
+ return {move (k), summary, description ? *description : "", changes};
+ }
+
// repository
//
repository::