tree schema REFACTOR move ext definitions to plugins_exts header
diff --git a/src/plugins_exts/metadata.h b/src/plugins_exts/metadata.h
index f9dbd12..6387e1f 100644
--- a/src/plugins_exts/metadata.h
+++ b/src/plugins_exts/metadata.h
@@ -1,9 +1,10 @@
/**
* @file metadata.h
* @author Radek Krejci <rkrejci@cesnet.cz>
+ * @author Michal Vasko <mvasko@cesnet.cz>
* @brief ietf-yang-metadata API
*
- * Copyright (c) 2019 CESNET, z.s.p.o.
+ * 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.
@@ -15,6 +16,9 @@
#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
@@ -26,6 +30,42 @@
#define ANNOTATION_SUBSTMT_DSC 4 /**< index for the LY_STMT_DSC substatement in annotation's ::lysc_ext_instance.substmts */
#define ANNOTATION_SUBSTMT_REF 5 /**< index for the LY_STMT_REF substatement in annotation's ::lysc_ext_instance.substmts */
+/**
+ * @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