Loading...
Searching...
No Matches
Trees
Collaboration diagram for Trees:

## Topics

| Data Tree
| Schema Tree
| Trees - modification

## Macros

#define | LY_ARRAY_COUNT(ARRAY)
| Get the number of records in the ARRAY.
#define | LY_ARRAY_COUNT_TYPE uint64_t
| Type (i.e. size) of the sized array's size counter.
#define | LY_ARRAY_FOR(ARRAY, ...)
| Sized-array iterator (for-loop).
#define | LY_ARRAY_FOR_INDEX(ARRAY, INDEX)
| Helper macro to go through sized-arrays with a numeric iterator.
#define | LY_ARRAY_FOR_ITER(ARRAY, TYPE, ITER)
| Helper macro to go through sized-arrays with a pointer iterator.
#define | LY_ARRAY_SELECT(_1, _2, NAME, ...)
| Macro selector for other LY_ARRAY_* macros, do not use directly!
#define | LY_DATA_TYPE_COUNT 20
#define | LY_LIST_FOR(START, ELEM)
| Macro to iterate via all sibling elements without affecting the list itself.
#define | LY_LIST_FOR_SAFE(START, NEXT, ELEM)
| Macro to iterate via all sibling elements allowing to modify the list itself (e.g. removing elements).
#define | LY_PRI_ARRAY_COUNT_TYPE PRIu64
| Printing format specifier macro for LY_ARRAY_SIZE_TYPE values.

## Enumerations

enum | LY_DATA_TYPE { LY_TYPE_UNKNOWN = 0 , LY_TYPE_BINARY , LY_TYPE_UINT8 , LY_TYPE_UINT16 , LY_TYPE_UINT32 , LY_TYPE_UINT64 , LY_TYPE_STRING , LY_TYPE_BITS , LY_TYPE_BOOL , LY_TYPE_DEC64 , LY_TYPE_EMPTY , LY_TYPE_ENUM , LY_TYPE_IDENT , LY_TYPE_INST , LY_TYPE_LEAFREF , LY_TYPE_UNION , LY_TYPE_INT8 , LY_TYPE_INT16 , LY_TYPE_INT32 , LY_TYPE_INT64 }
| YANG built-in types. More...
enum | LY_VALUE_FORMAT { LY_VALUE_CANON , LY_VALUE_SCHEMA , LY_VALUE_SCHEMA_RESOLVED , LY_VALUE_XML , LY_VALUE_JSON , LY_VALUE_LYB , LY_VALUE_STR_NS }
| All kinds of supported value formats and prefix mappings to modules. More...

## Variables

const char * | ly_data_type2str [20]
| Stringfield YANG built-in data types.

## Detailed Description

Generic macros, functions, etc. to work with both schema and data trees.

## Macro Definition Documentation

## LY_ARRAY_COUNT

#define LY_ARRAY_COUNT | ( |  | ARRAY | ) |

Value:
(ARRAY ? (*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1)) : 0)
LY_ARRAY_COUNT_TYPE
#define LY_ARRAY_COUNT_TYPE
Type (i.e. size) of the sized array's size counter.
Definition tree.h:104

Get the number of records in the ARRAY.

Definition at line 148 of file tree.h.

## LY_ARRAY_COUNT_TYPE

#define LY_ARRAY_COUNT_TYPE uint64_t

Type (i.e. size) of the sized array's size counter.

To print the value via a print format, use LY_PRI_ARRAY_COUNT_TYPE specifier.

Definition at line 104 of file tree.h.

## LY_ARRAY_FOR

#define LY_ARRAY_FOR | ( |  | ARRAY,
|  |  | ... )

Value:
LY_ARRAY_SELECT(__VA_ARGS__, LY_ARRAY_FOR_ITER, LY_ARRAY_FOR_INDEX, LY_UNDEF)(ARRAY, __VA_ARGS__)
LY_ARRAY_SELECT
#define LY_ARRAY_SELECT(_1, _2, NAME,...)
Macro selector for other LY_ARRAY_* macros, do not use directly!
Definition tree.h:114
LY_ARRAY_FOR_ITER
#define LY_ARRAY_FOR_ITER(ARRAY, TYPE, ITER)
Helper macro to go through sized-arrays with a pointer iterator.
Definition tree.h:125
LY_ARRAY_FOR_INDEX
#define LY_ARRAY_FOR_INDEX(ARRAY, INDEX)
Helper macro to go through sized-arrays with a numeric iterator.
Definition tree.h:140

Sized-array iterator (for-loop).

Use with opening curly bracket ({).

There are 2 variants:

    LY_ARRAY_FOR(ARRAY, TYPE, ITER)

Where ARRAY is a sized-array to go through, TYPE is the type of the items in the ARRAY and ITER is a pointer variable providing the items of the ARRAY in the loops. This functionality is provided by LY_ARRAY_FOR_ITER macro

    LY_ARRAY_FOR(ARRAY, INDEX)

The ARRAY is again a sized-array to go through, the INDEX is a variable (LY_ARRAY_COUNT_TYPE) for storing iterating ARRAY's index to access the items of ARRAY in the loops. This functionality is provided by LY_ARRAY_FOR_INDEX macro.

Definition at line 167 of file tree.h.

## LY_ARRAY_FOR_INDEX

#define LY_ARRAY_FOR_INDEX | ( |  | ARRAY,
|  |  | INDEX )

Value:
for (INDEX = 0; \
INDEX < LY_ARRAY_COUNT(ARRAY); \
++INDEX)
LY_ARRAY_COUNT
#define LY_ARRAY_COUNT(ARRAY)
Get the number of records in the ARRAY.
Definition tree.h:148

Helper macro to go through sized-arrays with a numeric iterator.

Use with opening curly bracket ({).

The item on the current INDEX in the ARRAY can be accessed in a standard C way as ARRAY[INDEX].

Parameters

  [in] | ARRAY | Array to go through
  [out] | INDEX | Variable for the iterating index of the item being processed in each loop

Definition at line 140 of file tree.h.

## LY_ARRAY_FOR_ITER

#define LY_ARRAY_FOR_ITER | ( |  | ARRAY,
|  |  | TYPE,
|  |  | ITER )

Value:
for (ITER = ARRAY; \
(ARRAY) && ((char *)ITER - (char *)ARRAY)/(sizeof(TYPE)) < (*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1)); \
ITER = (TYPE*)ITER + 1)

Helper macro to go through sized-arrays with a pointer iterator.

Use with opening curly bracket ({).

Parameters

  [in] | ARRAY | Array to go through
  [in] | TYPE | Type of the records in the ARRAY
  [out] | ITER | Iterating pointer to the item being processed in each loop

Definition at line 125 of file tree.h.

## LY_ARRAY_SELECT

#define LY_ARRAY_SELECT | ( |  | _1,
|  |  | _2,
|  |  | NAME,
|  |  | ... )

Value:
NAME

Macro selector for other LY_ARRAY_* macros, do not use directly!

Definition at line 114 of file tree.h.

## LY_DATA_TYPE_COUNT

#define LY_DATA_TYPE_COUNT 20

Number of different types

Definition at line 224 of file tree.h.

## LY_LIST_FOR

#define LY_LIST_FOR | ( |  | START,
|  |  | ELEM )

Value:
for ((ELEM) = (START); \
(ELEM); \
(ELEM) = (ELEM)->next)

Macro to iterate via all sibling elements without affecting the list itself.

Works for all types of nodes despite it is data or schema tree, but all the parameters must be pointers to the same type.

Use with opening curly bracket ({). All parameters must be of the same type.

Parameters

  START | Pointer to the starting element.
  ELEM | Iterator.

Definition at line 180 of file tree.h.

## LY_LIST_FOR_SAFE

#define LY_LIST_FOR_SAFE | ( |  | START,
|  |  | NEXT,
|  |  | ELEM )

Value:
for ((ELEM) = (START); \
(ELEM) ? (NEXT = (ELEM)->next, 1) : 0; \
(ELEM) = (NEXT))

Macro to iterate via all sibling elements allowing to modify the list itself (e.g. removing elements).

Use with opening curly bracket ({). All parameters must be of the same type.

Parameters

  START | Pointer to the starting element.
  NEXT | Temporary storage to allow removing of the current iterator content.
  ELEM | Iterator.

Definition at line 194 of file tree.h.

## LY_PRI_ARRAY_COUNT_TYPE

#define LY_PRI_ARRAY_COUNT_TYPE PRIu64

Printing format specifier macro for LY_ARRAY_SIZE_TYPE values.

Definition at line 109 of file tree.h.

## Enumeration Type Documentation

## LY_DATA_TYPE

enum LY_DATA_TYPE

YANG built-in types.

Enumerator
LY_TYPE_UNKNOWN | Unknown type
LY_TYPE_BINARY | Any binary data (RFC 6020 sec 9.8)
LY_TYPE_UINT8 | 8-bit unsigned integer (RFC 6020 sec 9.2)
LY_TYPE_UINT16 | 16-bit unsigned integer (RFC 6020 sec 9.2)
LY_TYPE_UINT32 | 32-bit unsigned integer (RFC 6020 sec 9.2)
LY_TYPE_UINT64 | 64-bit unsigned integer (RFC 6020 sec 9.2)
LY_TYPE_STRING | Human-readable string (RFC 6020 sec 9.4)
LY_TYPE_BITS | A set of bits or flags (RFC 6020 sec 9.7)
LY_TYPE_BOOL | "true" or "false" (RFC 6020 sec 9.5)
LY_TYPE_DEC64 | 64-bit signed decimal number (RFC 6020 sec 9.3)
LY_TYPE_EMPTY | A leaf that does not have any value (RFC 6020 sec 9.11)
LY_TYPE_ENUM | Enumerated strings (RFC 6020 sec 9.6)
LY_TYPE_IDENT | A reference to an abstract identity (RFC 6020 sec 9.10)
LY_TYPE_INST | References a data tree node (RFC 6020 sec 9.13)
LY_TYPE_LEAFREF | A reference to a leaf instance (RFC 6020 sec 9.9)
LY_TYPE_UNION | Choice of member types (RFC 6020 sec 9.12)
LY_TYPE_INT8 | 8-bit signed integer (RFC 6020 sec 9.2)
LY_TYPE_INT16 | 16-bit signed integer (RFC 6020 sec 9.2)
LY_TYPE_INT32 | 32-bit signed integer (RFC 6020 sec 9.2)
LY_TYPE_INT64 | 64-bit signed integer (RFC 6020 sec 9.2)

Definition at line 202 of file tree.h.

## LY_VALUE_FORMAT

enum LY_VALUE_FORMAT

All kinds of supported value formats and prefix mappings to modules.

Enumerator
LY_VALUE_CANON | canonical value, prefix mapping is type-specific
LY_VALUE_SCHEMA | YANG schema value, prefixes map to YANG import prefixes
LY_VALUE_SCHEMA_RESOLVED | resolved YANG schema value, prefixes map to module structures directly
LY_VALUE_XML | XML data value, prefixes map to XML namespace prefixes
LY_VALUE_JSON | JSON data value, prefixes map to module names
LY_VALUE_LYB | LYB data binary value, prefix mapping is type-specific (but usually like JSON)
LY_VALUE_STR_NS | any data format value, prefixes map to XML namespace prefixes

Definition at line 234 of file tree.h.

## Variable Documentation

## ly_data_type2str

const char* ly_data_type2str[20]

extern

Stringfield YANG built-in data types.