blob: df90db415c030102d4ad71725808cf68602faa98 [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:
Jan Kundrátcc2538f2020-02-03 11:33:42 +010020 return value->uint32();
Václav Kubernát02a71152020-01-21 14:52:51 +010021 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())};
Jan Kundrát4225b3f2020-01-24 12:58:38 +010029 case LY_TYPE_BINARY:
30 return std::string{value->binary()};
Václav Kubernát02a71152020-01-21 14:52:51 +010031 default: // TODO: implement all types
32 return "(can't print)"s;
33 }
34}