Skip to content

Commit 80c801d

Browse files
committed
port to libyang v6
Change-Id: I6b6ab3074c70b1952049302ce39badeca633a7a0
1 parent 22d3992 commit 80c801d

7 files changed

Lines changed: 27 additions & 9 deletions

File tree

.zuul.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
- f38-gcc-cover:
55
required-projects:
66
- name: github/CESNET/libyang
7-
override-checkout: cesnet/2026-07-09-before-v6
7+
override-checkout: devel
88
- name: github/doctest/doctest
99
override-checkout: v2.3.6
1010
- f38-clang-asan-ubsan:
1111
required-projects: &projects
1212
- name: github/CESNET/libyang
13-
override-checkout: cesnet/2026-07-09-before-v6
13+
override-checkout: devel
1414
- name: github/doctest/doctest
1515
override-checkout: v2.4.11
1616
- f38-clang-tsan:

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ if(NOT MSVC)
1515
set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Woverloaded-virtual -Wimplicit-fallthrough -Wsuggest-override ${CMAKE_CXX_FLAGS}")
1616
endif()
1717

18-
set(LIBYANG_CPP_PKG_VERSION "10")
18+
set(LIBYANG_CPP_PKG_VERSION "11")
1919

2020
find_package(Doxygen)
2121
option(WITH_DOCS "Create and install internal documentation (needs Doxygen)" ${DOXYGEN_FOUND})
2222
option(BUILD_SHARED_LIBS "By default, shared libs are enabled. Turn off for a static build." ON)
2323

2424
find_package(PkgConfig REQUIRED)
25-
pkg_check_modules(LIBYANG REQUIRED libyang>=5.6.1 IMPORTED_TARGET)
25+
pkg_check_modules(LIBYANG REQUIRED libyang>=6.1.1 IMPORTED_TARGET)
2626

2727
# FIXME from gcc 14.1 on we should be able to use the calendar/time from libstdc++ and thus remove the date dependency
2828
find_package(date)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Object lifetimes are managed automatically via RAII.
99

1010
## Dependencies
11-
- [libyang v5](https://github.com/CESNET/libyang) - the `cesnet/2026-07-09-before-v6` branch (even for the `master` branch of *libyang-cpp*)
11+
- [libyang tip of the `devel` branch](https://github.com/CESNET/libyang) - the `devel` branch (even for the `master` branch of *libyang-cpp*)
1212
- C++20 compiler (e.g., GCC 10.x+, clang 10+)
1313
- CMake 3.19+
1414
- optionally for built-in tests, [Doctest](https://github.com/doctest/doctest/) as a C++ unit test framework

include/libyang-cpp/Enum.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ enum class SchemaFormat {
4343
enum class DataFormat {
4444
Detect = 0,
4545
XML,
46-
JSON
46+
JSON,
47+
LYB,
48+
CBOR,
4749
};
4850

4951
/**
@@ -70,6 +72,7 @@ enum class PrintFlags : uint32_t {
7072
Siblings = 0x01,
7173
Shrink = 0x02,
7274
EmptyContainers = 0x04,
75+
EmptyLeafLists = 0x08,
7376
WithDefaultsTrim = 0x10,
7477
WithDefaultsAll = 0x20,
7578
WithDefaultsAllTag = 0x40,
@@ -111,6 +114,7 @@ enum class ValidationErrorCode : uint32_t {
111114
Semantics,
112115
XmlSyntax,
113116
JsonSyntax,
117+
CborSyntax,
114118
Data,
115119
Other
116120
};

src/Enum.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ std::string stringify(const ValidationErrorCode err)
9292
CHECK_AND_STRINGIFY(ValidationErrorCode::Semantics, LYVE_SEMANTICS);
9393
CHECK_AND_STRINGIFY(ValidationErrorCode::XmlSyntax, LYVE_SYNTAX_XML);
9494
CHECK_AND_STRINGIFY(ValidationErrorCode::JsonSyntax, LYVE_SYNTAX_JSON);
95+
CHECK_AND_STRINGIFY(ValidationErrorCode::CborSyntax, LYVE_SYNTAX_CBOR);
9596
CHECK_AND_STRINGIFY(ValidationErrorCode::Data, LYVE_DATA);
9697
CHECK_AND_STRINGIFY(ValidationErrorCode::Other, LYVE_OTHER);
9798
}

src/utils/enum.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ constexpr LYD_FORMAT toLydFormat(const DataFormat format)
2626
static_assert(LYD_FORMAT::LYD_UNKNOWN == toLydFormat(DataFormat::Detect));
2727
static_assert(LYD_FORMAT::LYD_XML == toLydFormat(DataFormat::XML));
2828
static_assert(LYD_FORMAT::LYD_JSON == toLydFormat(DataFormat::JSON));
29+
static_assert(LYD_FORMAT::LYD_LYB == toLydFormat(DataFormat::LYB));
30+
static_assert(LYD_FORMAT::LYD_CBOR == toLydFormat(DataFormat::CBOR));
2931

3032
constexpr uint32_t toPrintFlags(const PrintFlags flags)
3133
{
@@ -34,6 +36,7 @@ constexpr uint32_t toPrintFlags(const PrintFlags flags)
3436
// These tests ensure that I used the right numbers when defining my enum.
3537
// TODO: add asserts for operator|(PrintFlags, PrintFlags)
3638
static_assert(LYD_PRINT_EMPTY_CONT == toPrintFlags(PrintFlags::EmptyContainers));
39+
static_assert(LYD_PRINT_EMPTY_LEAF_LIST == toPrintFlags(PrintFlags::EmptyLeafLists));
3740
static_assert(LYD_PRINT_SHRINK == toPrintFlags(PrintFlags::Shrink));
3841
static_assert(LYD_PRINT_WD_ALL == toPrintFlags(PrintFlags::WithDefaultsAll));
3942
static_assert(LYD_PRINT_WD_ALL_TAG == toPrintFlags(PrintFlags::WithDefaultsAllTag));

tests/data_node.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,11 @@ TEST_CASE("Data Node manipulation")
137137
DOCTEST_SUBCASE("Printing")
138138
{
139139
auto node = ctx.parseData(data, libyang::DataFormat::JSON);
140-
auto str = node->printStr(libyang::DataFormat::JSON, libyang::PrintFlags::Siblings | libyang::PrintFlags::EmptyContainers);
140+
auto str = node->printStr(libyang::DataFormat::JSON, libyang::PrintFlags::Siblings | libyang::PrintFlags::EmptyContainers | libyang::PrintFlags::EmptyLeafLists);
141141
const auto expected = R"({
142142
"example-schema:leafInt32": 420,
143+
"example-schema:person": [
144+
],
143145
"example-schema:first": {
144146
"second": {
145147
"third": {
@@ -149,9 +151,17 @@ TEST_CASE("Data Node manipulation")
149151
},
150152
"example-schema:bigTree": {
151153
"one": {},
152-
"two": {}
154+
"two": {
155+
"myList": [
156+
]
157+
}
153158
},
154-
"ietf-yang-schema-mount:schema-mounts": {}
159+
"ietf-yang-schema-mount:schema-mounts": {
160+
"ietf-yang-schema-mount:namespace": [
161+
],
162+
"ietf-yang-schema-mount:mount-point": [
163+
]
164+
}
155165
}
156166
)"s;
157167

0 commit comments

Comments
 (0)