blob: 0885c64a5c01ea6391e40c9ae8879fd7929682b5 [file] [log] [blame]
Václav Kubernát02a71152020-01-21 14:52:51 +01001#include "libyang_utils.hpp"
2
3leaf_data_ leafValueFromValue(const libyang::S_Value& value, LY_DATA_TYPE type)
4{
5 using namespace std::string_literals;
6 switch (type) {
7 case LY_TYPE_INT8:
8 return value->int8();
9 case LY_TYPE_INT16:
10 return value->int16();
11 case LY_TYPE_INT32:
12 return value->int32();
13 case LY_TYPE_INT64:
14 return value->int64();
15 case LY_TYPE_UINT8:
16 return value->uint8();
17 case LY_TYPE_UINT16:
18 return value->uint16();
19 case LY_TYPE_UINT32:
20 return value->uintu32();
21 case LY_TYPE_UINT64:
22 return value->uint64();
23 case LY_TYPE_BOOL:
24 return bool(value->bln());
25 case LY_TYPE_STRING:
26 return std::string(value->string());
27 case LY_TYPE_ENUM:
28 return enum_{std::string(value->enm()->name())};
29 default: // TODO: implement all types
30 return "(can't print)"s;
31 }
32}