blob: ec3f3c8272cd2dc56d98937fd12bd3a8fd8787a6 [file] [log] [blame]
Václav Kubernát94938b72018-05-04 15:12:24 +02001/*
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át4108e0d2018-10-29 13:32:22 +01008/*! \file utils.hpp
9 \brief A header containing utility functions
10*/
Václav Kubernátdd769f62020-04-29 23:32:07 +020011#pragma once
12
Václav Kubernát94938b72018-05-04 15:12:24 +020013#include <string>
Václav Kubernátebca2552018-06-08 19:06:02 +020014#include "ast_path.hpp"
Václav Kubernátc31bd602019-03-07 11:44:48 +010015#include "ast_values.hpp"
Václav Kubernát0b0272f2018-06-13 14:13:08 +020016#include "schema.hpp"
Václav Kubernát94938b72018-05-04 15:12:24 +020017
18std::string joinPaths(const std::string& prefix, const std::string& suffix);
Václav Kubernát60d6f292018-05-25 09:45:32 +020019std::string stripLastNodeFromPath(const std::string& path);
Václav Kubernát2eaceb82018-10-08 19:56:30 +020020schemaPath_ pathWithoutLastNode(const schemaPath_& path);
21dataPath_ pathWithoutLastNode(const dataPath_& path);
Jan Kundrát6ebcc6c2020-05-07 01:58:51 +020022ModuleNodePair splitModuleNode(const std::string& input);
Václav Kubernát3a99f002020-03-31 02:27:41 +020023std::string leafDataTypeToString(const yang::LeafDataType& type);
Václav Kubernát2eaceb82018-10-08 19:56:30 +020024std::string fullNodeName(const schemaPath_& location, const ModuleNodePair& pair);
25std::string fullNodeName(const dataPath_& location, const ModuleNodePair& pair);
Václav Kubernát9b725992019-05-29 16:39:47 +020026std::string leafDataToString(const leaf_data_ value);
Václav Kubernát3a823f42020-04-29 23:40:21 +020027schemaPath_ anyPathToSchemaPath(const boost::variant<dataPath_, schemaPath_, module_>& path);
Václav Kubernát5b8a8f32020-05-20 00:57:22 +020028std::string stripLeafListValueFromPath(const std::string& path);
Václav Kubernátbf65dd72020-05-28 02:32:31 +020029std::string stripLastListInstanceFromPath(const std::string& path);
Václav Kubernát2c4778b2020-06-18 11:55:20 +020030// The second argument controls whether module prefixes should be added to the keys.
31std::string instanceToString(const ListInstance& instance, const std::optional<std::string>& modName = std::nullopt);