Václav Kubernát | 94938b7 | 2018-05-04 15:12:24 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/ |
| 3 | * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/ |
| 4 | * |
| 5 | * Written by Václav Kubernát <kubervac@fit.cvut.cz> |
| 6 | * |
| 7 | */ |
Václav Kubernát | 4108e0d | 2018-10-29 13:32:22 +0100 | [diff] [blame] | 8 | /*! \file utils.hpp |
| 9 | \brief A header containing utility functions |
| 10 | */ |
Václav Kubernát | dd769f6 | 2020-04-29 23:32:07 +0200 | [diff] [blame] | 11 | #pragma once |
| 12 | |
Václav Kubernát | 94938b7 | 2018-05-04 15:12:24 +0200 | [diff] [blame] | 13 | #include <string> |
Václav Kubernát | ebca255 | 2018-06-08 19:06:02 +0200 | [diff] [blame] | 14 | #include "ast_path.hpp" |
Václav Kubernát | c31bd60 | 2019-03-07 11:44:48 +0100 | [diff] [blame] | 15 | #include "ast_values.hpp" |
Václav Kubernát | 0b0272f | 2018-06-13 14:13:08 +0200 | [diff] [blame] | 16 | #include "schema.hpp" |
Václav Kubernát | 94938b7 | 2018-05-04 15:12:24 +0200 | [diff] [blame] | 17 | |
| 18 | std::string joinPaths(const std::string& prefix, const std::string& suffix); |
Václav Kubernát | 60d6f29 | 2018-05-25 09:45:32 +0200 | [diff] [blame] | 19 | std::string stripLastNodeFromPath(const std::string& path); |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 20 | schemaPath_ pathWithoutLastNode(const schemaPath_& path); |
| 21 | dataPath_ pathWithoutLastNode(const dataPath_& path); |
Jan Kundrát | 6ebcc6c | 2020-05-07 01:58:51 +0200 | [diff] [blame] | 22 | ModuleNodePair splitModuleNode(const std::string& input); |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 23 | std::string leafDataTypeToString(const yang::LeafDataType& type); |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 24 | std::string fullNodeName(const schemaPath_& location, const ModuleNodePair& pair); |
| 25 | std::string fullNodeName(const dataPath_& location, const ModuleNodePair& pair); |
Václav Kubernát | 9b72599 | 2019-05-29 16:39:47 +0200 | [diff] [blame] | 26 | std::string leafDataToString(const leaf_data_ value); |
Václav Kubernát | 3a823f4 | 2020-04-29 23:40:21 +0200 | [diff] [blame] | 27 | schemaPath_ anyPathToSchemaPath(const boost::variant<dataPath_, schemaPath_, module_>& path); |
Václav Kubernát | 5b8a8f3 | 2020-05-20 00:57:22 +0200 | [diff] [blame] | 28 | std::string stripLeafListValueFromPath(const std::string& path); |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 29 | std::string stripLastListInstanceFromPath(const std::string& path); |
Václav Kubernát | 2c4778b | 2020-06-18 11:55:20 +0200 | [diff] [blame] | 30 | // The second argument controls whether module prefixes should be added to the keys. |
| 31 | std::string instanceToString(const ListInstance& instance, const std::optional<std::string>& modName = std::nullopt); |