Add helper function for arrays

New function for read only access to the internal nelem member of
toml_array_t structs
This commit is contained in:
Stanley Pinchak 2019-01-08 13:12:40 -06:00
parent 88eacb3fe0
commit b53c016877
2 changed files with 8 additions and 0 deletions

5
toml.c
View File

@ -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) int toml_table_nkval(toml_table_t* tab)
{ {
return tab->nkval; return tab->nkval;

3
toml.h
View File

@ -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 */ /* Return the array kind: 't'able, 'a'rray, 'v'alue */
TOML_EXTERN char toml_array_kind(toml_array_t* arr); 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 */ /* Return the number of key-values in a table */
TOML_EXTERN int toml_table_nkval(toml_table_t* tab); TOML_EXTERN int toml_table_nkval(toml_table_t* tab);