From b53c016877c515357179e2b78e8cb86607852197 Mon Sep 17 00:00:00 2001 From: Stanley Pinchak Date: Tue, 8 Jan 2019 13:12:40 -0600 Subject: [PATCH] Add helper function for arrays New function for read only access to the internal nelem member of toml_array_t structs --- toml.c | 5 +++++ toml.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/toml.c b/toml.c index fde2122..24f4f69 100644 --- a/toml.c +++ b/toml.c @@ -1610,6 +1610,11 @@ char toml_array_kind(toml_array_t* arr) } +int toml_array_nelem(toml_array_t* arr) +{ + return arr->nelem; +} + int toml_table_nkval(toml_table_t* tab) { return tab->nkval; diff --git a/toml.h b/toml.h index 58c3194..9d33397 100644 --- a/toml.h +++ b/toml.h @@ -63,6 +63,9 @@ TOML_EXTERN toml_table_t* toml_table_in(toml_table_t* tab, const char* key); /* Return the array kind: 't'able, 'a'rray, 'v'alue */ TOML_EXTERN char toml_array_kind(toml_array_t* arr); +/* Return the number of elements in the array */ +TOML_EXTERN int toml_array_nelem(toml_array_t* arr); + /* Return the number of key-values in a table */ TOML_EXTERN int toml_table_nkval(toml_table_t* tab);