From a1ff7646ce6f829dd192e2e2246def2ea583e93b Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Wed, 26 Apr 2023 21:58:45 +0200 Subject: Provide access to the first node of a collection. --- plugins/yaml/collection.c | 30 ++++++++++++++++++++++++++++++ plugins/yaml/collection.h | 3 +++ 2 files changed, 33 insertions(+) diff --git a/plugins/yaml/collection.c b/plugins/yaml/collection.c index 376e894..03c3992 100644 --- a/plugins/yaml/collection.c +++ b/plugins/yaml/collection.c @@ -275,6 +275,36 @@ GYamlNode **g_yaml_collection_get_nodes(const GYamlCollection *collec, size_t *c /****************************************************************************** * * +* Paramètres : collec = noeud d'arborescence Yaml à consulter. * +* * +* Description : Fournit le premier noeud intégré dans une collection. * +* * +* Retour : Noeud issu d'une collection Yaml. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GYamlNode *g_yaml_collection_get_first_node(const GYamlCollection *collec) +{ + GYamlNode *result; /* Elément à retourner */ + + if (collec->count == 0) + result = NULL; + + else + { + result = collec->nodes[0]; + g_object_ref(G_OBJECT(result)); + } + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : node = noeud d'arborescence Yaml à consulter. * * path = chemin d'accès à parcourir. * * prepare = indication sur une préparation d'un prochain appel.* diff --git a/plugins/yaml/collection.h b/plugins/yaml/collection.h index 4d74d29..4bf0f2d 100644 --- a/plugins/yaml/collection.h +++ b/plugins/yaml/collection.h @@ -63,6 +63,9 @@ void g_yaml_collection_add_node(GYamlCollection *, GYamlNode *); /* Fournit la liste des noeuds intégrés dans une collection. */ GYamlNode **g_yaml_collection_get_nodes(const GYamlCollection *, size_t *); +/* Fournit le premier noeud intégré dans une collection. */ +GYamlNode *g_yaml_collection_get_first_node(const GYamlCollection *); + #endif /* PLUGINS_YAML_COLLECTION_H */ -- cgit v0.11.2-87-g4458