libyang  3.4.2
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
printer_data.h File Reference

Data printers for libyang. More...

#include <stdint.h>
#include <stdio.h>
#include "log.h"
#include "out.h"
#include "tree_data.h"
Include dependency graph for printer_data.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LYD_PRINT_KEEPEMPTYCONT   0x04
 
#define LYD_PRINT_SHRINK   LY_PRINT_SHRINK
 
#define LYD_PRINT_WD_ALL   0x20
 
#define LYD_PRINT_WD_ALL_TAG   0x40
 
#define LYD_PRINT_WD_EXPLICIT   0x00
 
#define LYD_PRINT_WD_IMPL_TAG   0x80
 
#define LYD_PRINT_WD_MASK   0xF0
 
#define LYD_PRINT_WD_TRIM   0x10
 
#define LYD_PRINT_WITHSIBLINGS   0x01
 

Functions

LIBYANG_API_DECL ly_bool lyd_metadata_should_print (const struct lyd_meta *meta)
 Check whether the metadata should be printed. More...
 
LIBYANG_API_DECL ly_bool lyd_node_should_print (const struct lyd_node *node, uint32_t options)
 Check whether the node should be printed based on the printing options. More...
 
LIBYANG_API_DECL LY_ERR lyd_print_all (struct ly_out *out, const struct lyd_node *root, LYD_FORMAT format, uint32_t options)
 Print the whole data tree of the root, including all the siblings. More...
 
LIBYANG_API_DECL LY_ERR lyd_print_clb (ly_write_clb writeclb, void *user_data, const struct lyd_node *root, LYD_FORMAT format, uint32_t options)
 Print data tree in the specified format. More...
 
LIBYANG_API_DECL LY_ERR lyd_print_fd (int fd, const struct lyd_node *root, LYD_FORMAT format, uint32_t options)
 Print data tree in the specified format. More...
 
LIBYANG_API_DECL LY_ERR lyd_print_file (FILE *f, const struct lyd_node *root, LYD_FORMAT format, uint32_t options)
 Print data tree in the specified format. More...
 
LIBYANG_API_DECL LY_ERR lyd_print_mem (char **strp, const struct lyd_node *root, LYD_FORMAT format, uint32_t options)
 Print data tree in the specified format. More...
 
LIBYANG_API_DECL LY_ERR lyd_print_path (const char *path, const struct lyd_node *root, LYD_FORMAT format, uint32_t options)
 Print data tree in the specified format. More...
 
LIBYANG_API_DECL LY_ERR lyd_print_tree (struct ly_out *out, const struct lyd_node *root, LYD_FORMAT format, uint32_t options)
 Print the selected data subtree. More...
 

Detailed Description

Data printers for libyang.

Author
Radek Krejci rkrej.nosp@m.ci@c.nosp@m.esnet.nosp@m..cz Copyright (c) 2015-2019 CESNET, z.s.p.o.

This source code is licensed under BSD 3-Clause License (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at

https://opensource.org/licenses/BSD-3-Clause

Definition in file printer_data.h.

Function Documentation

LIBYANG_API_DECL ly_bool lyd_metadata_should_print ( const struct lyd_meta meta)

Check whether the metadata should be printed.

Parameters
[in]metaMetadata to check.
Returns
0 if not,
non-0 if should be printed.
LIBYANG_API_DECL ly_bool lyd_node_should_print ( const struct lyd_node node,
uint32_t  options 
)

Check whether the node should be printed based on the printing options.

Parameters
[in]nodeNode to check.
[in]optionsData printer flags.
Returns
0 if not,
non-0 if should be printed.
LIBYANG_API_DECL LY_ERR lyd_print_all ( struct ly_out out,
const struct lyd_node root,
LYD_FORMAT  format,
uint32_t  options 
)

Print the whole data tree of the root, including all the siblings.

Parameters
[in]outPrinter handler for a specific output. Use ly_out_*() functions to create and free the handler.
[in]rootThe root element of the tree to print, can be any sibling.
[in]formatOutput format.
[in]optionsData printer flags except LYD_PRINT_WITHSIBLINGS.
Returns
LY_ERR value.
LIBYANG_API_DECL LY_ERR lyd_print_clb ( ly_write_clb  writeclb,
void *  user_data,
const struct lyd_node root,
LYD_FORMAT  format,
uint32_t  options 
)

Print data tree in the specified format.

Parameters
[in]writeclbCallback function to write the data (see write(1)).
[in]user_dataOptional caller-specific argument to be passed to the writeclb callback.
[in]rootThe root element of the (sub)tree to print.
[in]formatOutput format.
[in]optionsData printer flags.
Returns
LY_ERR value.
LIBYANG_API_DECL LY_ERR lyd_print_fd ( int  fd,
const struct lyd_node root,
LYD_FORMAT  format,
uint32_t  options 
)

Print data tree in the specified format.

Parameters
[in]fdFile descriptor where to print the data.
[in]rootThe root element of the (sub)tree to print.
[in]formatOutput format.
[in]optionsData printer flags.
Returns
LY_ERR value.
LIBYANG_API_DECL LY_ERR lyd_print_file ( FILE *  f,
const struct lyd_node root,
LYD_FORMAT  format,
uint32_t  options 
)

Print data tree in the specified format.

Parameters
[in]fFile stream where to print the data.
[in]rootThe root element of the (sub)tree to print.
[in]formatOutput format.
[in]optionsData printer flags.
Returns
LY_ERR value.
LIBYANG_API_DECL LY_ERR lyd_print_mem ( char **  strp,
const struct lyd_node root,
LYD_FORMAT  format,
uint32_t  options 
)

Print data tree in the specified format.

Parameters
[out]strpPointer to store the resulting dump.
[in]rootThe root element of the (sub)tree to print.
[in]formatOutput format.
[in]optionsData printer flags.
Returns
LY_ERR value.
LIBYANG_API_DECL LY_ERR lyd_print_path ( const char *  path,
const struct lyd_node root,
LYD_FORMAT  format,
uint32_t  options 
)

Print data tree in the specified format.

Parameters
[in]pathFile path where to print the data.
[in]rootThe root element of the (sub)tree to print.
[in]formatOutput format.
[in]optionsData printer flags.
Returns
LY_ERR value.
LIBYANG_API_DECL LY_ERR lyd_print_tree ( struct ly_out out,
const struct lyd_node root,
LYD_FORMAT  format,
uint32_t  options 
)

Print the selected data subtree.

Parameters
[in]outPrinter handler for a specific output. Use ly_out_*() functions to create and free the handler.
[in]rootThe root element of the subtree to print.
[in]formatOutput format.
[in]optionsData printer flags except LYD_PRINT_WITHSIBLINGS.
Returns
LY_ERR value.