blob: e91e82b6a137c051e9be6ecb944e3cfdd1fd46d4 [file] [log] [blame]
Václav Kubernátcbdc98a2021-01-28 13:24:37 +01001/*
2 * Copyright (C) 2021 CESNET, https://photonics.cesnet.cz/
3 *
4 * Written by Václav Kubernát <kubernat@cesnet.cz>
5 *
6*/
7
8#pragma once
9#include <memory>
Tomáš Peckafd90efb2021-10-07 10:40:44 +020010#include <optional>
Jan Kundrát4a10d0a2024-04-10 03:33:43 +020011#include <string>
Václav Kubernátcbdc98a2021-01-28 13:24:37 +010012
13namespace libyang {
Václav Kubernát7efd6d52021-11-09 01:31:11 +010014 class DataNode;
Václav Kubernátcbdc98a2021-01-28 13:24:37 +010015}
16
Tomáš Peckafd5ebd32021-10-07 09:48:13 +020017namespace velia::utils {
18
Václav Kubernátcbdc98a2021-01-28 13:24:37 +010019/**
20 * @brief Gets a string value from a node.
21 *
22 * @param node A libyang data node. Mustn't be nullptr. Must be a leaf.
23 *
24 */
Jan Kundrát4a10d0a2024-04-10 03:33:43 +020025std::string getValueAsString(const libyang::DataNode& node);
Václav Kubernátcbdc98a2021-01-28 13:24:37 +010026
Václav Kubernát7efd6d52021-11-09 01:31:11 +010027/** @brief Gets exactly one node based on `path` starting from `start`. Uses findXPath, so it works even with lists with
28 * missing predicates.
Václav Kubernátcbdc98a2021-01-28 13:24:37 +010029 *
Tomáš Peckafd90efb2021-10-07 10:40:44 +020030 * Throws if there is more than one matching node. Returns std::nullopt if no node matches.
Václav Kubernátcbdc98a2021-01-28 13:24:37 +010031 */
Jan Kundrátb3e99982022-03-18 17:38:20 +010032std::optional<libyang::DataNode> getUniqueSubtree(const libyang::DataNode& start, const std::string& path);
Tomáš Peckafd5ebd32021-10-07 09:48:13 +020033}