From cd07912073c951b4bbb871ed2653af1be2cfc714 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 11:55:11 +0200 Subject: Adding upstream version 2.1.30. Signed-off-by: Daniel Baumann --- src/plugins_exts/metadata.h | 66 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/plugins_exts/metadata.h (limited to 'src/plugins_exts/metadata.h') diff --git a/src/plugins_exts/metadata.h b/src/plugins_exts/metadata.h new file mode 100644 index 0000000..59ea2bf --- /dev/null +++ b/src/plugins_exts/metadata.h @@ -0,0 +1,66 @@ +/** + * @file metadata.h + * @author Radek Krejci + * @author Michal Vasko + * @brief ietf-yang-metadata API + * + * Copyright (c) 2019 - 2022 CESNET, z.s.p.o. + * + * This source code is licensed under BSD 3-Clause License (the "License"). + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + */ + +#ifndef LY_PLUGINS_EXTS_METADATA_H_ +#define LY_PLUGINS_EXTS_METADATA_H_ + +#include "plugins_exts.h" +#include "tree_data.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Metadata structure. + * + * The structure provides information about metadata of a data element. Such attributes must map to + * annotations as specified in RFC 7952. The only exception is the filter type (in NETCONF get operations) + * and edit-config's operation attributes. In XML, they are represented as standard XML attributes. In JSON, + * they are represented as JSON elements starting with the '@' character (for more information, see the + * YANG metadata RFC. + * + */ +struct lyd_meta { + struct lyd_node *parent; /**< data node where the metadata is placed */ + struct lyd_meta *next; /**< pointer to the next metadata of the same element */ + struct lysc_ext_instance *annotation; /**< pointer to the annotation's definition */ + const char *name; /**< metadata name */ + struct lyd_value value; /**< metadata value representation */ +}; + +/** + * @brief Get the (canonical) value of a metadata node. + * + * @param[in] meta Metadata node to use. + * @return Canonical value. + */ +static inline const char * +lyd_get_meta_value(const struct lyd_meta *meta) +{ + if (meta) { + const struct lyd_value *value = &meta->value; + + return value->_canonical ? value->_canonical : lyd_value_get_canonical(meta->annotation->module->ctx, value); + } + + return NULL; +} + +#ifdef __cplusplus +} +#endif + +#endif /* LY_PLUGINS_EXTS_METADATA_H_ */ -- cgit v1.2.3