Skip to content

Commit bac6680

Browse files
committed
API add: module organization
Add a getter for module organization (lys_module::org). Change-Id: Ic3564a6d244685ec8c74385f0ff54c7d2632d81b
1 parent 079db04 commit bac6680

4 files changed

Lines changed: 19 additions & 0 deletions

File tree

include/libyang-cpp/Module.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class LIBYANG_CPP_EXPORT Module {
7777
std::string name() const;
7878
std::optional<std::string> revision() const;
7979
std::string ns() const;
80+
std::optional<std::string> org() const;
8081
bool implemented() const;
8182
bool featureEnabled(const std::string& featureName) const;
8283
std::vector<Feature> features() const;

src/Module.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,20 @@ std::string Module::ns() const
7575
return m_module->ns;
7676
}
7777

78+
/**
79+
* @brief Returns the (optional) organization of the module.
80+
*
81+
* Wraps `lys_module::org`.
82+
*/
83+
std::optional<std::string> Module::org() const
84+
{
85+
if (!m_module->org) {
86+
return std::nullopt;
87+
}
88+
89+
return m_module->org;
90+
}
91+
7892
/**
7993
* @brief Checks whether the module is implemented (or just imported).
8094
*

tests/context.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,11 @@ TEST_CASE("context")
388388
REQUIRE(modules.at(6).ns() == "urn:ietf:params:xml:ns:yang:ietf-yang-structure-ext");
389389
REQUIRE(modules.at(7).name() == "mod1");
390390
REQUIRE(modules.at(7).ns() == "http://example.com");
391+
REQUIRE(*modules.at(7).org() == "CESNET");
391392
REQUIRE(*modules.at(7).revision() == "2021-11-15");
392393
REQUIRE(modules.at(8).name() == "test");
393394
REQUIRE(modules.at(8).ns() == "http://example.com");
395+
REQUIRE(modules.at(8).org() == std::nullopt);
394396
REQUIRE(modules.at(8).revision() == std::nullopt);
395397
}
396398

tests/yang/mod1.yang

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module mod1 {
22
namespace "http://example.com";
33
prefix "mod";
44

5+
organization "CESNET";
6+
57
revision "2021-11-15";
68

79
feature "feature1";

0 commit comments

Comments
 (0)