blob: aa19506bc643ba47d5c323e56c2ee17c903edba3 [file] [log] [blame]
David Sedlák2b626ee2019-06-03 16:40:18 +02001
2
3#ifndef LY_PARSER_YIN_H_
4#define LY_PARSER_YIN_H_
5
6#include <stdio.h>
7#include "log.h"
8#include "xml.h"
9#include "stdlib.h"
10
11enum YIN_ARGUMENT {
12 YIN_ARG_UNKNOWN = 0, /**< parsed argument can not be matched with any known yin argument keyword */
13 YIN_ARG_NAME, /**< argument name */
14 YIN_ARG_TARGET_NODE, /**< argument target-node */
15 YIN_ARG_MODULE, /**< argument module */
16 YIN_ARG_VALUE, /**< argument value */
17 YIN_ARG_TEXT, /**< argument text */
18 YIN_ARG_CONDITION, /**< argument condition */
19 YIN_ARG_URI, /**< argument uri */
20 YIN_ARG_DATE, /**< argument data */
21 YIN_ARG_TAG, /**< argument tag */
22 YIN_ARG_XMLNS, /**< argument xmlns */
23 YIN_ARG_NONE, /**< special value to specify no valid argument except xmlns, do not confuse with YIN_ARG_NONE */
24};
25
26/**
27 * @brief Match argument name.
28 *
29 * @param[in] name String representing name.
30 * @param[in] len Lenght of the name.
31 *
32 * @reurn YIN_ARGUMENT value.
33 */
34enum YIN_ARGUMENT match_argument_name(const char *name, size_t len);
35
36/**
37 * @brief Parse content of whole element as text.
38 *
39 * @param[in] xml_ctx Xml context.
40 * @param[in] data Data to read from.
41 * @param[out] value Where content of element should be stored.
42 */
43LY_ERR parse_text_element(struct lyxml_context *xml_ctx, const char **data, const char **value);
44
David Sedlákd9d3a312019-06-04 09:47:10 +020045/**
46 * @brief Parse namespace statement.
47 *
48 * @param[in] xml_ctx xml context.
49 * @param[in, out] data Data to read from.
50 * @param[in, out] namespace Where namespace value should be stored.
51 *
52 * @return LY_ERR values.
53 */
David Sedlákda63c082019-06-04 13:52:23 +020054LY_ERR parse_namespace(struct lyxml_context *xml_ctx, const char **data, const char **namespace);
55
56/**
57 * @brief Parse import element
58 *
59 * @param[in] xml_ctx Xml context.
60 * @param[in] module_prefix Prefix of the module to check prefix collisions.
61 * @param[in, out] data Dta to read from.
62 *
63 */
64LY_ERR yin_parse_import(struct lyxml_context *xml_ctx, const char *module_prefix, const char **data, struct lysp_import **imports);
David Sedlák2b626ee2019-06-03 16:40:18 +020065
66#endif /* LY_PARSER_YIN_H_*/