Václav Kubernát | 02a7115 | 2020-01-21 14:52:51 +0100 | [diff] [blame] | 1 | #include "libyang_utils.hpp" |
| 2 | |
| 3 | leaf_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())}; |
Jan Kundrát | 4225b3f | 2020-01-24 12:58:38 +0100 | [diff] [blame^] | 29 | case LY_TYPE_BINARY: |
| 30 | return std::string{value->binary()}; |
Václav Kubernát | 02a7115 | 2020-01-21 14:52:51 +0100 | [diff] [blame] | 31 | default: // TODO: implement all types |
| 32 | return "(can't print)"s; |
| 33 | } |
| 34 | } |