blob: 1862fe4183719defff34cfb8419e2230ad69e199 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
// file : bpkg/package.cxx -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
// license : MIT; see accompanying LICENSE file
#include <bpkg/package>
#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 {package_version_id (name, version), 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)
{
switch (s)
{
case state::broken: return "broken";
case state::fetched: return "fetched";
case state::unpacked: return "unpacked";
case state::configured: return "configured";
}
return string (); // Should never reach.
}
state
from_string (const string& s)
{
if (s == "broken") return state::broken;
else if (s == "fetched") return state::fetched;
else if (s == "unpacked") return state::unpacked;
else if (s == "configured") return state::configured;
else throw invalid_argument (s);
}
}
|