add toml_array_type() api

This commit is contained in:
CK Tan 2019-02-27 11:31:49 -08:00
parent 0ce0c0d9d0
commit c4325a38fb
2 changed files with 18 additions and 0 deletions

11
toml.c
View File

@ -1609,6 +1609,17 @@ char toml_array_kind(toml_array_t* arr)
return arr->kind;
}
char toml_array_type(toml_array_t* arr)
{
if (arr->kind != 'v')
return 0;
if (arr->nelem == 0)
return 0;
return arr->type;
}
int toml_array_nelem(toml_array_t* arr)
{

7
toml.h
View File

@ -68,6 +68,13 @@ 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);
/* For array kind 'v'alue, return the type of values
i:int, d:double, b:bool, s:string, t:time, D:date, T:timestamp
0 if unknown
*/
TOML_EXTERN char toml_array_type(toml_array_t* arr);
/* Return the number of elements in the array */
TOML_EXTERN int toml_array_nelem(toml_array_t* arr);