aboutsummaryrefslogtreecommitdiff
path: root/bpkg/package.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-09-21 18:08:39 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-09-21 18:08:39 +0200
commit221f0250fcd7cba4fa4b5e4fd6c0d410eb6e5811 (patch)
tree3ea5eca558f612fcc9b27db2778d4bfa47e38556 /bpkg/package.cxx
parent9792fc9d137b4dd702360ac0242f9a7a26e675c2 (diff)
Implement rep-add command
Diffstat (limited to 'bpkg/package.cxx')
-rw-r--r--bpkg/package.cxx65
1 files changed, 65 insertions, 0 deletions
diff --git a/bpkg/package.cxx b/bpkg/package.cxx
index 66769d1..9528288 100644
--- a/bpkg/package.cxx
+++ b/bpkg/package.cxx
@@ -4,12 +4,77 @@
#include <bpkg/package>
+#include <cassert>
#include <stdexcept> // invalid_argument
using namespace std;
namespace bpkg
{
+ // repository
+ //
+ repository::_id_type repository::
+ _id () const
+ {
+ return _id_type {location.canonical_name (), location.string ()};
+ }
+
+ void repository::
+ _id (_id_type&& l)
+ {
+ location = repository_location (move (l.location));
+ assert (location.canonical_name () == l.name);
+ }
+
+ // package_version_id
+ //
+ bool
+ operator< (const package_version_id& x, const package_version_id& y)
+ {
+ int r (x.name.compare (y.name));
+
+ if (r != 0)
+ return r < 0;
+
+ if (x.epoch != y.epoch)
+ return x.epoch < y.epoch;
+
+ r = x.upstream.compare (y.upstream);
+
+ if (r != 0)
+ return r < 0;
+
+ return x.revision < y.revision;
+ }
+
+ // available_package
+ //
+ available_package::_id_type available_package::
+ _id () const
+ {
+ return _id_type {
+ {
+ name,
+ version.epoch (),
+ version.canonical_upstream (),
+ version.revision ()
+ },
+ version.upstream ()
+ };
+ }
+
+ void available_package::
+ _id (_id_type&& v)
+ {
+ name = move (v.data.name);
+ version = version_type (v.data.epoch,
+ move (v.version_original_upstream),
+ v.data.revision);
+ assert (version.canonical_upstream () == v.data.upstream);
+ }
+
+ // state
+ //
string
to_string (state s)
{