16
16
* Authored by: Thomas Voß <thomas.voss@canonical.com>
19
#include <com/ubuntu/location/service/state.h>
19
#include <location/service/state.h>
22
22
#include <type_traits>
24
namespace culs = com::ubuntu::location::service;
28
typedef typename std::underlying_type<culs::State>::type UT;
26
typedef typename std::underlying_type<location::service::State>::type UT;
30
typedef std::pair<std::map<culs::State, std::string>, std::map<std::string, culs::State>> Lut;
28
typedef std::pair<std::map<location::service::State, std::string>, std::map<std::string, location::service::State>> Lut;
34
32
static const Lut instance
37
{culs::State::disabled, "disabled"},
38
{culs::State::enabled, "enabled"},
39
{culs::State::active, "active"}
35
{location::service::State::disabled, "disabled"},
36
{location::service::State::enabled, "enabled"},
37
{location::service::State::active, "active"}
42
{"disabled", culs::State::disabled},
43
{"enabled", culs::State::enabled},
44
{"active", culs::State::active}
40
{"disabled", location::service::State::disabled},
41
{"enabled", location::service::State::enabled},
42
{"active", location::service::State::active}
52
bool culs::operator==(culs::State lhs, culs::State rhs)
50
bool location::service::operator==(location::service::State lhs, location::service::State rhs)
54
52
return static_cast<UT>(lhs) == static_cast<UT>(rhs);
57
bool culs::operator!=(culs::State lhs, culs::State rhs)
55
bool location::service::operator!=(location::service::State lhs, location::service::State rhs)
59
57
return static_cast<UT>(lhs) != static_cast<UT>(rhs);
62
std::ostream& culs::operator<<(std::ostream& out, culs::State state)
60
std::ostream& location::service::operator<<(std::ostream& out, location::service::State state)
64
62
return out << lut().first.at(state);
67
std::istream& culs::operator>>(std::istream& in, culs::State& state)
65
std::istream& location::service::operator>>(std::istream& in, location::service::State& state)
69
67
std::string s; in >> s; state = lut().second.at(s);