blob: 9f6fb563a13d2d6928400a993f24fe83b80c3116 [file] [log] [blame]
Radek Krejcif8d7f9a2021-03-10 14:32:36 +01001/**
2 * @file plugins_exts_print.h
3 * @author Radek Krejci <rkrejci@cesnet.cz>
4 * @brief libyang support for YANG extensions implementation - schema print related items.
5 *
6 * Copyright (c) 2015 - 2021 CESNET, z.s.p.o.
7 *
8 * This source code is licensed under BSD 3-Clause License (the "License").
9 * You may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * https://opensource.org/licenses/BSD-3-Clause
13 */
14
15#ifndef LY_PLUGINS_EXTS_PRINT_H_
16#define LY_PLUGINS_EXTS_PRINT_H_
17
18#include <stdint.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24/**
25 * @ingroup extensions YANG Extensions
26 *
27 * @{
28 */
29
30/**
Radek Krejci0b013302021-03-29 15:22:32 +020031 * @brief YANG printer context for use in ::lyplg_ext_schema_printer_clb callback implementation.
Radek Krejcif8d7f9a2021-03-10 14:32:36 +010032 *
33 * The structure provides basic information how the compiled schema is supposed to be printed and where. In the most simple
34 * case, the provided context is just passed into ::lysc_print_extension_instance() function which handles printing the
35 * extension's substatements in the standard way.
36 *
37 * To access various items from the context, use some of the following lys_ypr_ctx_get_* getters.
38 */
39struct lyspr_ctx;
40
41/**
42 * @brief YANG printer context getter for output handler.
43 * @param[in] ctx YANG printer context.
44 * @return Output handler where the data are being printed. Note that the address of the handler pointer in the context is
45 * returned to allow to modify the handler.
46 */
47struct ly_out **lys_ypr_ctx_get_out(const struct lyspr_ctx *ctx);
48
49/**
50 * @brief YANG printer context getter for printer options.
51 * @param[in] ctx YANG printer context.
52 * @return pointer to the printer options to allow modifying them with @ref schemaprinterflags values.
53 */
54uint32_t *lys_ypr_ctx_get_options(const struct lyspr_ctx *ctx);
55
56/**
57 * @brief YANG printer context getter for printer indentation level.
58 * @param[in] ctx YANG printer context.
59 * @return pointer to the printer's indentation level to allow modifying its value.
60 */
61uint16_t *lys_ypr_ctx_get_level(const struct lyspr_ctx *ctx);
62
63/**
64 * @brief Print substatements of an extension instance
65 *
Radek Krejci0b013302021-03-29 15:22:32 +020066 * Generic function to access YANG printer functions from the extension plugins (::lyplg_ext_schema_printer_clb).
Radek Krejcif8d7f9a2021-03-10 14:32:36 +010067 *
68 * @param[in] ctx YANG printer context to provide output handler and other information for printing.
69 * @param[in] ext The compiled extension instance to access the extensions and substatements data.
70 * @param[in, out] flag Flag to be shared with the caller regarding the opening brackets - 0 if the '{' not yet printed,
71 * 1 otherwise.
72 */
73void lysc_print_extension_instance(struct lyspr_ctx *ctx, const struct lysc_ext_instance *ext, ly_bool *flag);
74
75/** @} extensions */
76
77#ifdef __cplusplus
78}
79#endif
80
81#endif /* LY_PLUGINS_EXTS_PRINT_H_ */