libyang 5.0.8
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
Loading...
Searching...
No Matches
Data parser options
Collaboration diagram for Data parser options:

Macros

#define LYD_PARSE_ANYDATA_STRICT   0x08000000
#define LYD_PARSE_JSON_NULL   0x02000000
#define LYD_PARSE_JSON_STRING_DATATYPES   0x0400000
#define LYD_PARSE_LYB_SKIP_MODULE_CHECK   0x100000
#define LYD_PARSE_NO_NEW   0x800000
#define LYD_PARSE_NO_STATE   0x080000
#define LYD_PARSE_ONLY   0x010000
#define LYD_PARSE_OPAQ   0x040000
#define LYD_PARSE_OPTS_MASK   0xFFFF0000
#define LYD_PARSE_ORDERED   0x200000
#define LYD_PARSE_STORE_ONLY   0x01010000
#define LYD_PARSE_STRICT   0x020000
#define LYD_PARSE_WHEN_TRUE   0x400000

Detailed Description

Various options to change the data tree parsers behavior.

Default parser behavior:

  • complete input file is always parsed. In case of XML, even not well-formed XML document (multiple top-level elements) is parsed in its entirety,
  • parser silently ignores data without matching schema node definition (for LYB format an error),
  • list instances are checked whether they have all the keys, error is raised if not.

Default parser validation behavior:

  • the provided data are expected to provide complete datastore content (both the configuration and state data) and performs data validation according to all YANG rules, specifics follow,
  • list instances are expected to have all the keys (it is not checked),
  • instantiated (status) obsolete data print a warning,
  • all types are fully resolved (leafref/instance-identifier targets, unions) and must be valid (lists have all the keys, leaf(-lists) correct values),
  • when statements on existing nodes are evaluated, if not satisfied, a validation error is raised,
  • invalid multiple data instances/data from several cases cause a validation error,
  • implicit nodes (NP containers and default values) are added.

Macro Definition Documentation

◆ LYD_PARSE_ANYDATA_STRICT

#define LYD_PARSE_ANYDATA_STRICT   0x08000000

Apply strict parsing (LYD_PARSE_STRICT) also to anydata content. By default, unknown elements in anydata are parsed as opaque nodes. With this flag, an error is raised for any unknown elements within anydata/anyxml subtrees.

Definition at line 175 of file parser_data.h.

◆ LYD_PARSE_JSON_NULL

#define LYD_PARSE_JSON_NULL   0x02000000

Allow using JSON empty value 'null' within JSON input, such nodes are silently skipped and treated as non-existent. By default, such values are invalid.

Definition at line 168 of file parser_data.h.

◆ LYD_PARSE_JSON_STRING_DATATYPES

#define LYD_PARSE_JSON_STRING_DATATYPES   0x0400000

By default, JSON data values are expected to be in the correct format according to RFC 7951 based on their type. Using this option the validation can be softened to accept boolean and number type values enclosed in quotes.

Definition at line 171 of file parser_data.h.

◆ LYD_PARSE_LYB_SKIP_MODULE_CHECK

#define LYD_PARSE_LYB_SKIP_MODULE_CHECK   0x100000

LYB only; only affects data printed without LYD_PRINT_SHRINK. Skip checking of module revisions and set of enabled features when parsing data. Use this flag when the modules in the parser context differ (in revision/features), but the instantiated schema trees exactly match (the module changes conform to RFC 7950, sec. 11).

Definition at line 147 of file parser_data.h.

◆ LYD_PARSE_NO_NEW

#define LYD_PARSE_NO_NEW   0x800000

Do not set LYD_NEW (non-validated node flag) for any nodes. Use when parsing validated data to skip some validation tasks and modify some validation behavior (auto-deletion of cases).

Definition at line 161 of file parser_data.h.

◆ LYD_PARSE_NO_STATE

#define LYD_PARSE_NO_STATE   0x080000

Forbid state data in the parsed data. Usually used with LYD_VALIDATE_NO_STATE.

Definition at line 146 of file parser_data.h.

◆ LYD_PARSE_ONLY

#define LYD_PARSE_ONLY   0x010000

Data will be only parsed and no data validation will be performed but type value restrictions will be checked (unlike LYD_PARSE_STORE_ONLY). When statements are kept unevaluated, union types may not be fully resolved, and default values are not added (only the ones parsed are present).

Definition at line 137 of file parser_data.h.

◆ LYD_PARSE_OPAQ

#define LYD_PARSE_OPAQ   0x040000

Instead of silently ignoring data without definition, parse them into an opaq node. Do not combine with LYD_PARSE_STRICT (except for LYD_LYB).

Definition at line 144 of file parser_data.h.

◆ LYD_PARSE_OPTS_MASK

#define LYD_PARSE_OPTS_MASK   0xFFFF0000

Mask for all the LYD_PARSE_ options.

Definition at line 179 of file parser_data.h.

◆ LYD_PARSE_ORDERED

#define LYD_PARSE_ORDERED   0x200000

Do not search for the correct place of each node but instead expect that the nodes are being parsed in the correct schema-based order, which is always true if the data were printed by libyang and not modified manually. If this flag is used incorrectly (for unordered data), the behavior is undefined and most functions executed with these data will not work correctly.

Definition at line 152 of file parser_data.h.

◆ LYD_PARSE_STORE_ONLY

#define LYD_PARSE_STORE_ONLY   0x01010000

Similar to LYD_PARSE_ONLY but even type value restrictions will not be checked (length, range, pattern, ...) and if a value can be stored, it is. Calling separate validation on these data always checks all the restrictions as well.

Definition at line 164 of file parser_data.h.

◆ LYD_PARSE_STRICT

#define LYD_PARSE_STRICT   0x020000

Instead of silently ignoring data without schema definition raise an error. Do not combine with LYD_PARSE_OPAQ. Always the behavior for LYD_LYB.

Definition at line 142 of file parser_data.h.

◆ LYD_PARSE_WHEN_TRUE

#define LYD_PARSE_WHEN_TRUE   0x400000

Mark all the parsed nodes dependend on a when condition with the flag that means the condition was satisifed before. This allows for auto-deletion of these nodes during validation.

Definition at line 158 of file parser_data.h.