Port to libyang-cpp and sysrepo-cpp API change to std::string

Change-Id: I9e683e0ab3a5db696c35699d22cf1cb982c8ceda
Depends-on: https://gerrit.cesnet.cz/c/CzechLight/dependencies/+/5564
diff --git a/tests/datastore_access.cpp b/tests/datastore_access.cpp
index 57871c0..1f8bb55 100644
--- a/tests/datastore_access.cpp
+++ b/tests/datastore_access.cpp
@@ -901,7 +901,7 @@
             // `xpath` holds the subscription xpath which won't have list keys. We need the path with list keys and
             // we'll find that in the input.
             auto inputPath = input.findXPath("/example-schema:ports/shutdown").front().path();
-            output.newPath(joinPaths(std::string{inputPath}, "success").c_str(), "true", libyang::CreationOptions::Output);
+            output.newPath(joinPaths(inputPath, "success"), "true", libyang::CreationOptions::Output);
             return sysrepo::ErrorCode::Ok;
         }
         throw std::runtime_error("unrecognized RPC");
@@ -939,21 +939,21 @@
 
                 if (inputNode.path() == nukes + "/payload/kilotons") {
                     kilotons = std::get<uint64_t>(inputNode.asTerm().value());
-                } else if (std::string_view{inputNode.path().get().get()}.find(nukes + "/cities") == 0) {
+                } else if (inputNode.path().find(nukes + "/cities") == 0) {
                     hasCities = true;
                 } else {
-                    throw std::runtime_error("RPC launch-nukes: unexpected input "s + inputNode.path().get().get());
+                    throw std::runtime_error("RPC launch-nukes: unexpected input "s + inputNode.path());
                 }
             }
             if (kilotons == 333'666) {
                 // magic, just do not generate any output. This is important because the NETCONF RPC returns just <ok/>.
                 return sysrepo::ErrorCode::Ok;
             }
-            output.newPath((nukes + "/blast-radius").c_str(), "33666", libyang::CreationOptions::Output);
-            output.newPath((nukes + "/actual-yield").c_str(), std::to_string(static_cast<uint64_t>(1.33 * kilotons)).c_str(), libyang::CreationOptions::Output);
+            output.newPath(nukes + "/blast-radius", "33666", libyang::CreationOptions::Output);
+            output.newPath(nukes + "/actual-yield", std::to_string(static_cast<uint64_t>(1.33 * kilotons)), libyang::CreationOptions::Output);
             if (hasCities) {
-                output.newPath((nukes + "/damaged-places/targets[city='London']/city").c_str(), "London", libyang::CreationOptions::Output);
-                output.newPath((nukes + "/damaged-places/targets[city='Berlin']/city").c_str(), "Berlin", libyang::CreationOptions::Output);
+                output.newPath(nukes + "/damaged-places/targets[city='London']/city", "London", libyang::CreationOptions::Output);
+                output.newPath(nukes + "/damaged-places/targets[city='Berlin']/city", "Berlin", libyang::CreationOptions::Output);
             }
             return sysrepo::ErrorCode::Ok;
         }
diff --git a/tests/mock/sysrepo_subscription.cpp b/tests/mock/sysrepo_subscription.cpp
index d4827bb..94d4c44 100644
--- a/tests/mock/sysrepo_subscription.cpp
+++ b/tests/mock/sysrepo_subscription.cpp
@@ -34,7 +34,7 @@
             return sysrepo::ErrorCode::Ok;
         }
 
-        for (const auto& it : sess.getChanges(("/"s + module_name.data() + ":*//.").c_str())) {
+        for (const auto& it : sess.getChanges("/"s + module_name.data() + ":*//.")) {
             auto xpath = it.node.path();
             std::optional<std::string> oldValue;
             std::optional<std::string> newValue;
@@ -72,7 +72,7 @@
 
 SysrepoSubscription::SysrepoSubscription(const std::string& moduleName, Recorder* rec, sysrepo::Datastore ds)
     : m_subscription([&moduleName, &rec, ds] { // This is an immediately invoked lambda.
-        return sysrepo::Connection{}.sessionStart(ds).onModuleChange(moduleName.c_str(),
+        return sysrepo::Connection{}.sessionStart(ds).onModuleChange(moduleName,
                 rec ? sysrepo::ModuleChangeCb{MyCallback{moduleName, rec}}
                 : sysrepo::ModuleChangeCb{[](auto, auto, auto, auto, auto, auto) { return sysrepo::ErrorCode::Ok; }});
     }())
@@ -97,9 +97,9 @@
         auto data = m_dataSupplier.get_data(subXPath->data());
         for (const auto& [p, v] : data) {
             if (!output) {
-                output = session.getContext().newPath(p.c_str(), v.type() == typeid(empty_) ? nullptr : leafDataToString(v).c_str());
+                output = session.getContext().newPath(p, v.type() == typeid(empty_) ? std::nullopt : std::optional<std::string>(leafDataToString(v)));
             } else {
-                output->newPath(p.c_str(), v.type() == typeid(empty_) ? nullptr : leafDataToString(v).c_str());
+                output->newPath(p, v.type() == typeid(empty_) ? std::nullopt : std::optional<std::string>(leafDataToString(v)));
             }
         }
         return sysrepo::ErrorCode::Ok;
@@ -110,6 +110,6 @@
 };
 
 OperationalDataSubscription::OperationalDataSubscription(const std::string& moduleName, const std::string& path, const DataSupplier& dataSupplier)
-    : m_subscription(sysrepo::Connection{}.sessionStart().onOperGet(moduleName.c_str(), OperationalDataCallback{dataSupplier}, path.c_str()))
+    : m_subscription(sysrepo::Connection{}.sessionStart().onOperGet(moduleName, OperationalDataCallback{dataSupplier}, path))
 {
 }
diff --git a/tests/utils.cpp b/tests/utils.cpp
index c24f4de..7d0af08 100644
--- a/tests/utils.cpp
+++ b/tests/utils.cpp
@@ -357,7 +357,7 @@
             expectedLeafData = std::string{"Xaver"};
         }
 
-        auto leaf = dataNode->findPath(("/" + path).c_str());
+        auto leaf = dataNode->findPath("/" + path);
         REQUIRE(leafValueFromNode(leaf->asTerm()) == expectedLeafData);
     }
 
diff --git a/tests/yang.cpp b/tests/yang.cpp
index 205616c..2560f64 100644
--- a/tests/yang.cpp
+++ b/tests/yang.cpp
@@ -477,21 +477,19 @@
 
 TEST_CASE("yangschema")
 {
-    using namespace std::string_literals;
-    using namespace std::string_view_literals;
     YangSchema ys;
-    ys.registerModuleCallback([]([[maybe_unused]] auto modName, auto, auto subModule, auto) {
-        if (modName != "example-schema"sv) {
-            throw std::logic_error("unrecognized module "s + modName);
+    ys.registerModuleCallback([](const auto modName, auto, const auto subModule, auto) {
+        if (modName != "example-schema") {
+            throw std::logic_error("unrecognized module " + std::string{modName});
         }
-        if (subModule == nullptr) {
+        if (!subModule) {
             return example_schema;
         }
-        if (subModule == "sub-module"sv) {
+        if (*subModule == "sub-module") {
             return included_submodule;
         }
 
-        throw std::logic_error("unrecognized submodule "s + subModule);
+        throw std::logic_error("unrecognized submodule " + std::string{*subModule});
     });
     ys.addSchemaString(second_schema);
     ys.addSchemaString(R"(