Coverage Report

Created: 2025-07-18 06:09

/src/libyang/build/libyang/metadata.h
Line
Count
Source (jump to first uncovered line)
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
0
56
0
        return value->_canonical ? value->_canonical : lyd_value_get_canonical(meta->annotation->module->ctx, value);
57
0
    }
58
0
59
0
    return NULL;
60
0
}
Unexecuted instantiation: lyd_parse_mem_xml.c:lyd_get_meta_value
Unexecuted instantiation: tree_data_common.c:lyd_get_meta_value
Unexecuted instantiation: tree_data_sorted.c:lyd_get_meta_value
Unexecuted instantiation: nacm.c:lyd_get_meta_value
Unexecuted instantiation: yangdata.c:lyd_get_meta_value
Unexecuted instantiation: schema_mount.c:lyd_get_meta_value
Unexecuted instantiation: structure.c:lyd_get_meta_value
Unexecuted instantiation: binary.c:lyd_get_meta_value
Unexecuted instantiation: bits.c:lyd_get_meta_value
Unexecuted instantiation: boolean.c:lyd_get_meta_value
Unexecuted instantiation: decimal64.c:lyd_get_meta_value
Unexecuted instantiation: empty.c:lyd_get_meta_value
Unexecuted instantiation: enumeration.c:lyd_get_meta_value
Unexecuted instantiation: identityref.c:lyd_get_meta_value
Unexecuted instantiation: instanceid.c:lyd_get_meta_value
Unexecuted instantiation: instanceid_keys.c:lyd_get_meta_value
Unexecuted instantiation: integer.c:lyd_get_meta_value
Unexecuted instantiation: leafref.c:lyd_get_meta_value
Unexecuted instantiation: lyds_tree.c:lyd_get_meta_value
Unexecuted instantiation: string.c:lyd_get_meta_value
Unexecuted instantiation: union.c:lyd_get_meta_value
Unexecuted instantiation: ipv4_address.c:lyd_get_meta_value
Unexecuted instantiation: ipv4_address_no_zone.c:lyd_get_meta_value
Unexecuted instantiation: ipv6_address.c:lyd_get_meta_value
Unexecuted instantiation: ipv6_address_no_zone.c:lyd_get_meta_value
Unexecuted instantiation: ipv4_prefix.c:lyd_get_meta_value
Unexecuted instantiation: ipv6_prefix.c:lyd_get_meta_value
Unexecuted instantiation: date_and_time.c:lyd_get_meta_value
Unexecuted instantiation: hex_string.c:lyd_get_meta_value
Unexecuted instantiation: xpath1.0.c:lyd_get_meta_value
Unexecuted instantiation: node_instanceid.c:lyd_get_meta_value
Unexecuted instantiation: time_period.c:lyd_get_meta_value
Unexecuted instantiation: out.c:lyd_get_meta_value
Unexecuted instantiation: lyd_parse_mem_json.c:lyd_get_meta_value
Unexecuted instantiation: lys_parse_mem.c:lyd_get_meta_value
61
62
#ifdef __cplusplus
63
}
64
#endif
65
66
#endif /* LY_PLUGINS_EXTS_METADATA_H_ */