blob: 7ffb99db8337650b2c75e8849fbb74e78831f062 (
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
|
// 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
{
string
to_string (state s)
{
switch (s)
{
case state::fetched: return "fetched";
case state::unpacked: return "unpacked";
case state::configured: return "configured";
case state::updated: return "updated";
case state::broken: return "broken";
}
return string (); // Should never reach.
}
state
from_string (const string& s)
{
if (s == "fetched") return state::fetched;
else if (s == "unpacked") return state::unpacked;
else if (s == "configured") return state::configured;
else if (s == "updated") return state::updated;
else if (s == "broken") return state::broken;
else throw invalid_argument (s);
}
}
|