blob: aed3b36181ede76cceceef9c0bfaf44a541f9fdf [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
Jan Kundrátc6e39de2021-12-09 16:01:19 +010020#include "config.h"
21
Radek Krejcif8d7f9a2021-03-10 14:32:36 +010022#ifdef __cplusplus
23extern "C" {
24#endif
25
26/**
Radek Krejci75104122021-04-01 15:37:45 +020027 * @defgroup pluginsExtensionsPrint Plugins: Extensions printer support
28 * @ingroup pluginsExtensions
29 *
30 * Helper functions to implement extension plugin's sprinter callback.
Radek Krejcif8d7f9a2021-03-10 14:32:36 +010031 *
32 * @{
33 */
34
35/**
Radek Krejci0b013302021-03-29 15:22:32 +020036 * @brief YANG printer context for use in ::lyplg_ext_schema_printer_clb callback implementation.
Radek Krejcif8d7f9a2021-03-10 14:32:36 +010037 *
38 * The structure provides basic information how the compiled schema is supposed to be printed and where. In the most simple
39 * case, the provided context is just passed into ::lysc_print_extension_instance() function which handles printing the
40 * extension's substatements in the standard way.
41 *
42 * To access various items from the context, use some of the following lys_ypr_ctx_get_* getters.
43 */
44struct lyspr_ctx;
45
46/**
47 * @brief YANG printer context getter for output handler.
48 * @param[in] ctx YANG printer context.
49 * @return Output handler where the data are being printed. Note that the address of the handler pointer in the context is
50 * returned to allow to modify the handler.
51 */
Jan Kundrátc6e39de2021-12-09 16:01:19 +010052LIBYANG_API_DECL struct ly_out **lys_ypr_ctx_get_out(const struct lyspr_ctx *ctx);
Radek Krejcif8d7f9a2021-03-10 14:32:36 +010053
54/**
55 * @brief YANG printer context getter for printer options.
56 * @param[in] ctx YANG printer context.
57 * @return pointer to the printer options to allow modifying them with @ref schemaprinterflags values.
58 */
Jan Kundrátc6e39de2021-12-09 16:01:19 +010059LIBYANG_API_DECL uint32_t *lys_ypr_ctx_get_options(const struct lyspr_ctx *ctx);
Radek Krejcif8d7f9a2021-03-10 14:32:36 +010060
61/**
62 * @brief YANG printer context getter for printer indentation level.
63 * @param[in] ctx YANG printer context.
64 * @return pointer to the printer's indentation level to allow modifying its value.
65 */
Jan Kundrátc6e39de2021-12-09 16:01:19 +010066LIBYANG_API_DECL uint16_t *lys_ypr_ctx_get_level(const struct lyspr_ctx *ctx);
Radek Krejcif8d7f9a2021-03-10 14:32:36 +010067
68/**
69 * @brief Print substatements of an extension instance
70 *
Radek Krejci0b013302021-03-29 15:22:32 +020071 * Generic function to access YANG printer functions from the extension plugins (::lyplg_ext_schema_printer_clb).
Radek Krejcif8d7f9a2021-03-10 14:32:36 +010072 *
73 * @param[in] ctx YANG printer context to provide output handler and other information for printing.
74 * @param[in] ext The compiled extension instance to access the extensions and substatements data.
75 * @param[in, out] flag Flag to be shared with the caller regarding the opening brackets - 0 if the '{' not yet printed,
76 * 1 otherwise.
77 */
Jan Kundrátc6e39de2021-12-09 16:01:19 +010078LIBYANG_API_DECL void lysc_print_extension_instance(struct lyspr_ctx *ctx, const struct lysc_ext_instance *ext, ly_bool *flag);
Radek Krejcif8d7f9a2021-03-10 14:32:36 +010079
Radek Krejci75104122021-04-01 15:37:45 +020080/** @} pluginsExtensionsPrint */
Radek Krejcif8d7f9a2021-03-10 14:32:36 +010081
82#ifdef __cplusplus
83}
84#endif
85
86#endif /* LY_PLUGINS_EXTS_PRINT_H_ */