blob: 6a9541973daf739e26bd50beea791cff098feb0c [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/**
Radek Krejci75104122021-04-01 15:37:45 +020025 * @defgroup pluginsExtensionsPrint Plugins: Extensions printer support
26 * @ingroup pluginsExtensions
27 *
28 * Helper functions to implement extension plugin's sprinter callback.
Radek Krejcif8d7f9a2021-03-10 14:32:36 +010029 *
30 * @{
31 */
32
33/**
Radek Krejci0b013302021-03-29 15:22:32 +020034 * @brief YANG printer context for use in ::lyplg_ext_schema_printer_clb callback implementation.
Radek Krejcif8d7f9a2021-03-10 14:32:36 +010035 *
36 * The structure provides basic information how the compiled schema is supposed to be printed and where. In the most simple
37 * case, the provided context is just passed into ::lysc_print_extension_instance() function which handles printing the
38 * extension's substatements in the standard way.
39 *
40 * To access various items from the context, use some of the following lys_ypr_ctx_get_* getters.
41 */
42struct lyspr_ctx;
43
44/**
45 * @brief YANG printer context getter for output handler.
46 * @param[in] ctx YANG printer context.
47 * @return Output handler where the data are being printed. Note that the address of the handler pointer in the context is
48 * returned to allow to modify the handler.
49 */
50struct ly_out **lys_ypr_ctx_get_out(const struct lyspr_ctx *ctx);
51
52/**
53 * @brief YANG printer context getter for printer options.
54 * @param[in] ctx YANG printer context.
55 * @return pointer to the printer options to allow modifying them with @ref schemaprinterflags values.
56 */
57uint32_t *lys_ypr_ctx_get_options(const struct lyspr_ctx *ctx);
58
59/**
60 * @brief YANG printer context getter for printer indentation level.
61 * @param[in] ctx YANG printer context.
62 * @return pointer to the printer's indentation level to allow modifying its value.
63 */
64uint16_t *lys_ypr_ctx_get_level(const struct lyspr_ctx *ctx);
65
66/**
67 * @brief Print substatements of an extension instance
68 *
Radek Krejci0b013302021-03-29 15:22:32 +020069 * Generic function to access YANG printer functions from the extension plugins (::lyplg_ext_schema_printer_clb).
Radek Krejcif8d7f9a2021-03-10 14:32:36 +010070 *
71 * @param[in] ctx YANG printer context to provide output handler and other information for printing.
72 * @param[in] ext The compiled extension instance to access the extensions and substatements data.
73 * @param[in, out] flag Flag to be shared with the caller regarding the opening brackets - 0 if the '{' not yet printed,
74 * 1 otherwise.
75 */
76void lysc_print_extension_instance(struct lyspr_ctx *ctx, const struct lysc_ext_instance *ext, ly_bool *flag);
77
Radek Krejci75104122021-04-01 15:37:45 +020078/** @} pluginsExtensionsPrint */
Radek Krejcif8d7f9a2021-03-10 14:32:36 +010079
80#ifdef __cplusplus
81}
82#endif
83
84#endif /* LY_PLUGINS_EXTS_PRINT_H_ */