diff options
Diffstat (limited to 'plugins/yaml/tree.c')
-rw-r--r-- | plugins/yaml/tree.c | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/plugins/yaml/tree.c b/plugins/yaml/tree.c index 0494aeb..fd2cd8f 100644 --- a/plugins/yaml/tree.c +++ b/plugins/yaml/tree.c @@ -33,6 +33,7 @@ #include <core/logs.h> +#include "scalar.h" #include "collection.h" @@ -183,10 +184,10 @@ GYamlTree *g_yaml_tree_new(GYamlLine **lines, size_t count) if (count > 0) { - result->root = g_yaml_node_new(NULL); + result->root = G_YAML_NODE(g_yaml_scalar_new(NULL)); collec = g_yaml_collection_new(g_yaml_line_is_list_item(lines[0])); - g_yaml_node_set_collection(result->root, collec); + g_yaml_scalar_set_collection(G_YAML_SCALAR(result->root), collec); indent = g_yaml_line_count_indent(lines[0]); processed = 0; @@ -274,7 +275,7 @@ static bool g_yaml_tree_build_node(GYamlCollection *collec, GYamlLine **lines, s assert(last != NULL); sub = g_yaml_collection_new(is_item); - g_yaml_node_set_collection(last, sub); + g_yaml_scalar_set_collection(G_YAML_SCALAR(last), sub); result = g_yaml_tree_build_node(sub, lines, count, indent, cur); if (!result) goto done; @@ -297,11 +298,11 @@ static bool g_yaml_tree_build_node(GYamlCollection *collec, GYamlLine **lines, s } - glue = g_yaml_node_new(NULL); + glue = G_YAML_NODE(g_yaml_scalar_new(NULL)); g_yaml_collection_add_node(collec, glue); sub = g_yaml_collection_new(false); - g_yaml_node_set_collection(glue, sub); + g_yaml_scalar_set_collection(G_YAML_SCALAR(glue), sub); result = g_yaml_tree_build_node(sub, lines, count, expected + 2 /* 2 == strlen("- ") */, cur); if (!result) goto done; @@ -322,7 +323,7 @@ static bool g_yaml_tree_build_node(GYamlCollection *collec, GYamlLine **lines, s } - last = g_yaml_node_new(line); + last = G_YAML_NODE(g_yaml_scalar_new(line)); g_yaml_collection_add_node(collec, last); (*cur)++; @@ -366,10 +367,11 @@ GYamlNode *g_yaml_tree_get_root(const GYamlTree *tree) /****************************************************************************** * * -* Paramètres : tree = ligne au format Yaml à consulter. * -* path = chemin d'accès à parcourir. * -* nodes = liste de noeuds avec correspondance établie. [OUT] * -* count = quantité de ces noeuds. [OUT] * +* Paramètres : tree = ligne au format Yaml à consulter. * +* path = chemin d'accès à parcourir. * +* prepare = indication sur une préparation d'un prochain appel.* +* nodes = liste de noeuds avec correspondance établie. [OUT] * +* count = quantité de ces noeuds. [OUT] * * * * Description : Recherche les noeuds correspondant à un chemin. * * * @@ -379,8 +381,33 @@ GYamlNode *g_yaml_tree_get_root(const GYamlTree *tree) * * ******************************************************************************/ -void g_yaml_tree_find_by_path(const GYamlTree *tree, const char *path, GYamlNode ***nodes, size_t *count) +void g_yaml_tree_find_by_path(const GYamlTree *tree, const char *path, bool prepare, GYamlNode ***nodes, size_t *count) +{ + g_yaml_node_find_by_path(tree->root, path, prepare, nodes, count); + +} + + +/****************************************************************************** +* * +* Paramètres : tree = ligne au format Yaml à consulter. * +* path = chemin d'accès à parcourir. * +* prepare = indication sur une préparation d'un prochain appel.* +* * +* Description : Recherche l'unique noeud correspondant à un chemin. * +* * +* Retour : Noeud avec correspondance établie ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GYamlNode *g_yaml_tree_find_one_by_path(GYamlTree *tree, const char *path, bool prepare) { - g_yaml_node_find_by_path(tree->root, path, nodes, count); + GYamlNode *result; /* Trouvaille unique à renvoyer*/ + + result = g_yaml_node_find_one_by_path(tree->root, path, prepare); + + return result; } |