2 #include <libvirt/libvirt.h> 3 #include <rapidjson/pointer.h> 10 case VIR_TYPED_PARAM_INT:
11 ret.AddMember(rapidjson::Value(v.name(), jalloc), rapidjson::Value(v.value().i), jalloc);
13 case VIR_TYPED_PARAM_UINT:
14 ret.AddMember(rapidjson::Value(v.name(), jalloc), rapidjson::Value(v.value().ui), jalloc);
16 case VIR_TYPED_PARAM_LLONG:
17 ret.AddMember(rapidjson::Value(v.name(), jalloc), rapidjson::Value(int64_t{v.value().l}), jalloc);
19 case VIR_TYPED_PARAM_ULLONG:
20 ret.AddMember(rapidjson::Value(v.name(), jalloc), rapidjson::Value(uint64_t{v.value().ul}), jalloc);
22 case VIR_TYPED_PARAM_DOUBLE:
23 ret.AddMember(rapidjson::Value(v.name(), jalloc), rapidjson::Value(v.value().d), jalloc);
25 case VIR_TYPED_PARAM_BOOLEAN:
26 ret.AddMember(rapidjson::Value(v.name(), jalloc), rapidjson::Value(v.value().b), jalloc);
28 case VIR_TYPED_PARAM_STRING:
29 ret.AddMember(rapidjson::Value(v.name(), jalloc), rapidjson::Value(v.value().s, jalloc), jalloc);
38 template <
class JAllocator>
auto to_json(
const char* cstr, JAllocator&& jalloc) -> rapidjson::Value {
return {cstr, jalloc}; }
41 return to_json(static_cast<const char*>(zstr), std::forward<JAllocator>(jalloc));
47 rapidjson::Value ret{};
49 ret.AddMember(
"seconds", static_cast<int64_t>(time.seconds), jalloc);
50 ret.AddMember(
"nanosec", static_cast<unsigned>(time.nanosec), jalloc);
51 return std::move(ret);
54 template <
class JAllocator>
auto to_json(virNetworkDHCPLease lease, JAllocator&& jalloc) -> rapidjson::Value {
55 rapidjson::Value json_lease;
56 json_lease.AddMember(
"type", lease.type, jalloc);
57 json_lease.AddMember(
"client-id",
to_json(lease.clientid, jalloc), jalloc);
58 json_lease.AddMember(
"expiry-time", static_cast<std::int64_t>(lease.expirytime), jalloc);
59 json_lease.AddMember(
"hostname",
to_json(lease.hostname, jalloc), jalloc);
60 json_lease.AddMember(
"iaid",
to_json(lease.iaid, jalloc), jalloc);
61 json_lease.AddMember(
"interface",
to_json(lease.iface, jalloc), jalloc);
62 json_lease.AddMember(
"ip-address",
to_json(lease.ipaddr, jalloc), jalloc);
63 json_lease.AddMember(
"mac-address",
to_json(lease.mac, jalloc), jalloc);
64 json_lease.AddMember(
"prefix", lease.prefix, jalloc);
71 v.SetBool(static_cast<bool>(tfe));
75 template <
class T,
class JAllocator>
auto to_json(std::vector<T> vec, JAllocator&& jalloc) -> rapidjson::Value {
78 for (
auto&& element : std::move(vec))
79 arr.PushBack(
to_json(std::move(element), jalloc), jalloc);
80 return std::move(arr);
83 template <
class T,
class JAllocator>
auto get_to_json(std::optional<T> opt, JAllocator&& jalloc) -> rapidjson::Value {
84 return to_json(std::move(*opt), std::forward<JAllocator>(jalloc));
Definition: TypesParam.hpp:29
#define UNREACHABLE
Definition: utility.hpp:19
auto to_json(const virt::TypedParams &tp, JAllocator &&jalloc) noexcept-> rapidjson::Value
Definition: virt2json.hpp:6
TypePair< T, U > tp
Definition: utils.hpp:19
auto get_to_json(std::optional< T > opt, JAllocator &&jalloc) -> rapidjson::Value
Definition: virt2json.hpp:83
decltype(*std::declval< virt::Domain >().getTime()) VirtWrappedDomainTime
Definition: virt2json.hpp:44
Definition: utility.hpp:122
Definition: TypesParam.hpp:38