Coverage Report

Created: 2026-06-07 07:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libyang/src/plugins_exts/metadata.h
Line
Count
Source
1
/**
2
 * @file metadata.h
3
 * @author Radek Krejci <rkrejci@cesnet.cz>
4
 * @author Michal Vasko <mvasko@cesnet.cz>
5
 * @brief ietf-yang-metadata API
6
 *
7
 * Copyright (c) 2019 - 2022 CESNET, z.s.p.o.
8
 *
9
 * This source code is licensed under BSD 3-Clause License (the "License").
10
 * You may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12
 *
13
 *     https://opensource.org/licenses/BSD-3-Clause
14
 */
15
16
#ifndef LY_PLUGINS_EXTS_METADATA_H_
17
#define LY_PLUGINS_EXTS_METADATA_H_
18
19
#include "plugins_exts.h"
20
#include "tree_data.h"
21
22
#ifdef __cplusplus
23
extern "C" {
24
#endif
25
26
/**
27
 * @brief Metadata structure.
28
 *
29
 * The structure provides information about metadata of a data element. Such attributes must map to
30
 * annotations as specified in RFC 7952. The only exception is the filter type (in NETCONF get operations)
31
 * and edit-config's operation attributes. In XML, they are represented as standard XML attributes. In JSON,
32
 * they are represented as JSON elements starting with the '@' character (for more information, see the
33
 * YANG metadata RFC.
34
 *
35
 */
36
struct lyd_meta {
37
    struct lyd_node *parent;         /**< data node where the metadata is placed */
38
    struct lyd_meta *next;           /**< pointer to the next metadata of the same element */
39
    struct lysc_ext_instance *annotation; /**< pointer to the annotation's definition */
40
    const char *name;                /**< metadata name */
41
    struct lyd_value value;          /**< metadata value representation */
42
};
43
44
/**
45
 * @brief Get the (canonical) value of a metadata node.
46
 *
47
 * @param[in] meta Metadata node to use.
48
 * @return Canonical value.
49
 */
50
static inline const char *
51
lyd_get_meta_value(const struct lyd_meta *meta)
52
0
{
53
0
    if (meta) {
54
0
        const struct lyd_value *value = &meta->value;
55
56
0
        return value->_canonical ? value->_canonical : lyd_value_get_canonical(meta->annotation->module->ctx, value);
57
0
    }
58
59
0
    return NULL;
60
0
}
Unexecuted instantiation: tree_data.c:lyd_get_meta_value
Unexecuted instantiation: tree_data_free.c:lyd_get_meta_value
Unexecuted instantiation: tree_data_new.c:lyd_get_meta_value
Unexecuted instantiation: parser_lyb.c:lyd_get_meta_value
Unexecuted instantiation: printer_xml.c:lyd_get_meta_value
Unexecuted instantiation: printer_json.c:lyd_get_meta_value
Unexecuted instantiation: printer_lyb.c:lyd_get_meta_value
Unexecuted instantiation: parser_common.c:lyd_get_meta_value
Unexecuted instantiation: metadata.c:lyd_get_meta_value
Unexecuted instantiation: xpath.c:lyd_get_meta_value
Unexecuted instantiation: validation.c:lyd_get_meta_value
Unexecuted instantiation: diff.c:lyd_get_meta_value
61
62
#ifdef __cplusplus
63
}
64
#endif
65
66
#endif /* LY_PLUGINS_EXTS_METADATA_H_ */