Michal Vasko | d59035b | 2020-07-08 12:00:06 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @file diff.h |
| 3 | * @author Michal Vasko <mvasko@cesnet.cz> |
| 4 | * @brief internal diff header |
| 5 | * |
| 6 | * Copyright (c) 2020 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_DIFF_H_ |
| 16 | #define LY_DIFF_H_ |
| 17 | |
| 18 | #include <stdint.h> |
| 19 | |
| 20 | #include "log.h" |
| 21 | |
| 22 | struct lyd_node; |
| 23 | |
| 24 | /** |
| 25 | * @brief Internal structure for storing current (virtual) user-ordered instances order. |
| 26 | */ |
| 27 | struct lyd_diff_userord { |
| 28 | const struct lysc_node *schema; /**< User-ordered list/leaf-list schema node. */ |
| 29 | uint64_t pos; /**< Current position in the second tree. */ |
| 30 | const struct lyd_node **inst; /**< Sized array of current instance order. */ |
| 31 | }; |
| 32 | |
| 33 | /** |
| 34 | * @brief Diff operations. |
| 35 | */ |
| 36 | enum lyd_diff_op { |
| 37 | LYD_DIFF_OP_CREATE, /**< Subtree created. */ |
| 38 | LYD_DIFF_OP_DELETE, /**< Subtree deleted. */ |
| 39 | LYD_DIFF_OP_REPLACE, /**< Node value changed or (leaf-)list instance moved. */ |
Michal Vasko | 6973015 | 2020-10-09 16:30:07 +0200 | [diff] [blame] | 40 | LYD_DIFF_OP_NONE /**< No change of an existing inner node or default flag change of a term node. */ |
Michal Vasko | d59035b | 2020-07-08 12:00:06 +0200 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | /** |
| 44 | * @brief Add a new change into diff. |
| 45 | * |
| 46 | * @param[in] node Node (subtree) to add into diff. |
| 47 | * @param[in] op Operation to set. |
| 48 | * @param[in] orig_default Original default metadata to set. |
| 49 | * @param[in] orig_value Original value metadata to set. |
| 50 | * @param[in] key Key metadata to set. |
| 51 | * @param[in] value Value metadata to set. |
Michal Vasko | e78faec | 2021-04-08 17:24:43 +0200 | [diff] [blame] | 52 | * @param[in] position Position metadata to set. |
Michal Vasko | d59035b | 2020-07-08 12:00:06 +0200 | [diff] [blame] | 53 | * @param[in] orig_key Original key metadata to set. |
Michal Vasko | e78faec | 2021-04-08 17:24:43 +0200 | [diff] [blame] | 54 | * @param[in] orig_position Original position metadata to set. |
Michal Vasko | d59035b | 2020-07-08 12:00:06 +0200 | [diff] [blame] | 55 | * @param[in,out] diff Diff to append to. |
| 56 | * @return LY_ERR value. |
| 57 | */ |
Jan Kundrát | c6e39de | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 58 | LIBYANG_API_DECL LY_ERR lyd_diff_add(const struct lyd_node *node, enum lyd_diff_op op, const char *orig_default, const char *orig_value, |
Michal Vasko | e78faec | 2021-04-08 17:24:43 +0200 | [diff] [blame] | 59 | const char *key, const char *value, const char *position, const char *orig_key, const char *orig_position, |
| 60 | struct lyd_node **diff); |
Michal Vasko | d59035b | 2020-07-08 12:00:06 +0200 | [diff] [blame] | 61 | |
| 62 | #endif /* LY_DIFF_H_ */ |