diff options
Diffstat (limited to 'plugins/yaml/node.c')
-rw-r--r-- | plugins/yaml/node.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/plugins/yaml/node.c b/plugins/yaml/node.c index 3dc6ec0..e2abeca 100644 --- a/plugins/yaml/node.c +++ b/plugins/yaml/node.c @@ -392,3 +392,44 @@ void g_yaml_node_find_by_path(GYamlNode *node, const char *path, GYamlNode ***no _g_yaml_node_find_by_path(node, path, nodes, count); } + + +/****************************************************************************** +* * +* Paramètres : node = noeud d'arborescence Yaml à consulter. * +* path = chemin d'accès à parcourir. * +* * +* Description : Recherche l'unique noeud correspondant à un chemin. * +* * +* Retour : Noeud avec correspondance établie ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GYamlNode *g_yaml_node_find_one_by_path(GYamlNode *node, const char *path) +{ + GYamlNode *result; /* Trouvaille unique à renvoyer*/ + GYamlNode **nodes; /* Liste de noeuds trouvés */ + size_t count; /* Taille de cette liste */ + size_t i; /* Boucle de parcours */ + + g_yaml_node_find_by_path(node, path, &nodes, &count); + + if (count == 1) + { + result = nodes[0]; + g_object_ref(G_OBJECT(result)); + } + else + result = NULL; + + for (i = 0; i < count; i++) + g_object_unref(G_OBJECT(nodes[i])); + + if (nodes != NULL) + free(nodes); + + return result; + +} |