blob: ad54e51efd87b33c3d9ed1fd126c9f7be9eaa7e1 (
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
|
// 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
{
// available_package_id
//
bool
operator< (const available_package_id& x, const available_package_id& y)
{
int r (x.name.compare (y.name));
if (r != 0)
return r < 0;
const auto& xv (x.version);
const auto& yv (y.version);
if (xv.epoch != yv.epoch)
return xv.epoch < yv.epoch;
r = xv.canonical_upstream.compare (yv.canonical_upstream);
if (r != 0)
return r < 0;
return xv.revision < yv.revision;
}
// 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);
}
}
|