Add helper functions for tables
New functions for read only access to internal nkval, narr and ntab members of toml_table_t structs.
This commit is contained in:
parent
f06bf3a5cc
commit
88eacb3fe0
14
toml.c
14
toml.c
|
@ -1610,6 +1610,20 @@ char toml_array_kind(toml_array_t* arr)
|
|||
}
|
||||
|
||||
|
||||
int toml_table_nkval(toml_table_t* tab)
|
||||
{
|
||||
return tab->nkval;
|
||||
}
|
||||
|
||||
int toml_table_narr(toml_table_t* tab)
|
||||
{
|
||||
return tab->narr;
|
||||
}
|
||||
|
||||
int toml_table_ntab(toml_table_t* tab)
|
||||
{
|
||||
return tab->ntab;
|
||||
}
|
||||
|
||||
toml_array_t* toml_array_at(toml_array_t* arr, int idx)
|
||||
{
|
||||
|
|
9
toml.h
9
toml.h
|
@ -63,6 +63,15 @@ 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 key-values in a table */
|
||||
TOML_EXTERN int toml_table_nkval(toml_table_t* tab);
|
||||
|
||||
/* Return the number of arrays in a table */
|
||||
TOML_EXTERN int toml_table_narr(toml_table_t* tab);
|
||||
|
||||
/* Return the number of sub-tables in a table */
|
||||
TOML_EXTERN int toml_table_ntab(toml_table_t* tab);
|
||||
|
||||
/* Deref array by index. Return the element at idx or 0 if out of range. */
|
||||
TOML_EXTERN const char* toml_raw_at(toml_array_t* arr, int idx);
|
||||
TOML_EXTERN toml_array_t* toml_array_at(toml_array_t* arr, int idx);
|
||||
|
|
Loading…
Reference in New Issue