MRTKLIB 0.7.14
Modernized GNSS Positioning Library
Loading...
Searching...
No Matches
toml.h File Reference
#include <stdint.h>
#include <stdio.h>
Include dependency graph for toml.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  toml_timestamp_t
struct  toml_datum_t

Macros

#define TOML_EXTERN   extern

Typedefs

typedef struct toml_timestamp_t toml_timestamp_t
typedef struct toml_table_t toml_table_t
typedef struct toml_array_t toml_array_t
typedef struct toml_datum_t toml_datum_t
typedef const char * toml_raw_t

Functions

toml_table_t * toml_parse_file (FILE *fp, char *errbuf, int errbufsz)
toml_table_t * toml_parse (char *conf, char *errbuf, int errbufsz)
void toml_free (toml_table_t *tab)
int toml_array_nelem (const toml_array_t *arr)
toml_datum_t toml_string_at (const toml_array_t *arr, int idx)
toml_datum_t toml_bool_at (const toml_array_t *arr, int idx)
toml_datum_t toml_int_at (const toml_array_t *arr, int idx)
toml_datum_t toml_double_at (const toml_array_t *arr, int idx)
toml_datum_t toml_timestamp_at (const toml_array_t *arr, int idx)
toml_array_t * toml_array_at (const toml_array_t *arr, int idx)
toml_table_t * toml_table_at (const toml_array_t *arr, int idx)
const char * toml_key_in (const toml_table_t *tab, int keyidx)
int toml_key_exists (const toml_table_t *tab, const char *key)
toml_datum_t toml_string_in (const toml_table_t *arr, const char *key)
toml_datum_t toml_bool_in (const toml_table_t *arr, const char *key)
toml_datum_t toml_int_in (const toml_table_t *arr, const char *key)
toml_datum_t toml_double_in (const toml_table_t *arr, const char *key)
toml_datum_t toml_timestamp_in (const toml_table_t *arr, const char *key)
toml_array_t * toml_array_in (const toml_table_t *tab, const char *key)
toml_table_t * toml_table_in (const toml_table_t *tab, const char *key)
char toml_array_kind (const toml_array_t *arr)
char toml_array_type (const toml_array_t *arr)
const char * toml_array_key (const toml_array_t *arr)
int toml_table_nkval (const toml_table_t *tab)
int toml_table_narr (const toml_table_t *tab)
int toml_table_ntab (const toml_table_t *tab)
const char * toml_table_key (const toml_table_t *tab)
int toml_utf8_to_ucs (const char *orig, int len, int64_t *ret)
int toml_ucs_to_utf8 (int64_t code, char buf[6])
void toml_set_memutil (void *(*xxmalloc)(size_t), void(*xxfree)(void *))
toml_raw_t toml_raw_in (const toml_table_t *tab, const char *key)
toml_raw_t toml_raw_at (const toml_array_t *arr, int idx)
int toml_rtos (toml_raw_t s, char **ret)
int toml_rtob (toml_raw_t s, int *ret)
int toml_rtoi (toml_raw_t s, int64_t *ret)
int toml_rtod (toml_raw_t s, double *ret)
int toml_rtod_ex (toml_raw_t s, double *ret, char *buf, int buflen)
int toml_rtots (toml_raw_t s, toml_timestamp_t *ret)

Macro Definition Documentation

◆ TOML_EXTERN

#define TOML_EXTERN   extern

Definition at line 38 of file toml.h.

Typedef Documentation

◆ toml_array_t

typedef struct toml_array_t toml_array_t

Definition at line 43 of file toml.h.

◆ toml_datum_t

typedef struct toml_datum_t toml_datum_t

Definition at line 44 of file toml.h.

◆ toml_raw_t

typedef const char* toml_raw_t

Definition at line 165 of file toml.h.

◆ toml_table_t

typedef struct toml_table_t toml_table_t

Definition at line 42 of file toml.h.

◆ toml_timestamp_t

typedef struct toml_timestamp_t toml_timestamp_t

Definition at line 41 of file toml.h.

Function Documentation

◆ toml_array_at()

toml_array_t * toml_array_at ( const toml_array_t * arr,
int idx )
extern

Definition at line 1956 of file toml.c.

References toml_arritem_t::arr, toml_array_t::item, and nitem().

Here is the call graph for this function:

◆ toml_array_in()

toml_array_t * toml_array_in ( const toml_table_t * tab,
const char * key )
extern

Definition at line 1906 of file toml.c.

References toml_table_t::arr, toml_array_t::key, and toml_table_t::narr.

Referenced by loadopts_toml(), parse_select(), and toml_val_to_str().

Here is the caller graph for this function:

◆ toml_array_key()

const char * toml_array_key ( const toml_array_t * arr)
extern

Definition at line 1942 of file toml.c.

References toml_array_t::key.

◆ toml_array_kind()

char toml_array_kind ( const toml_array_t * arr)
extern

Definition at line 1928 of file toml.c.

References toml_array_t::kind.

◆ toml_array_nelem()

int toml_array_nelem ( const toml_array_t * arr)
extern

Definition at line 1940 of file toml.c.

References toml_array_t::nitem.

Referenced by loadopts_toml(), and toml_val_to_str().

Here is the caller graph for this function:

◆ toml_array_type()

char toml_array_type ( const toml_array_t * arr)
extern

Definition at line 1930 of file toml.c.

References toml_array_t::kind, toml_array_t::nitem, and toml_array_t::type.

◆ toml_bool_at()

toml_datum_t toml_bool_at ( const toml_array_t * arr,
int idx )
extern

Definition at line 2272 of file toml.c.

References toml_datum_t::b, toml_datum_t::ok, toml_raw_at(), toml_rtob(), and toml_datum_t::u.

Here is the call graph for this function:

◆ toml_bool_in()

toml_datum_t toml_bool_in ( const toml_table_t * arr,
const char * key )
extern

Definition at line 2333 of file toml.c.

References toml_datum_t::b, toml_datum_t::ok, toml_raw_in(), toml_rtob(), and toml_datum_t::u.

Referenced by toml_val_to_str().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_double_at()

toml_datum_t toml_double_at ( const toml_array_t * arr,
int idx )
extern

Definition at line 2286 of file toml.c.

References toml_datum_t::d, toml_datum_t::ok, toml_raw_at(), toml_rtod(), and toml_datum_t::u.

Referenced by toml_val_to_str().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_double_in()

toml_datum_t toml_double_in ( const toml_table_t * arr,
const char * key )
extern

Definition at line 2347 of file toml.c.

References toml_datum_t::d, toml_datum_t::ok, toml_raw_in(), toml_rtod(), and toml_datum_t::u.

Referenced by toml_val_to_str().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_free()

void toml_free ( toml_table_t * tab)
extern

Definition at line 1583 of file toml.c.

References xfree_tab().

Referenced by loadopts_toml(), and toml_parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_int_at()

toml_datum_t toml_int_at ( const toml_array_t * arr,
int idx )
extern

Definition at line 2279 of file toml.c.

References toml_datum_t::i, toml_datum_t::ok, toml_raw_at(), toml_rtoi(), and toml_datum_t::u.

Referenced by toml_val_to_str().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_int_in()

toml_datum_t toml_int_in ( const toml_table_t * arr,
const char * key )
extern

Definition at line 2340 of file toml.c.

References toml_datum_t::i, toml_datum_t::ok, toml_raw_in(), toml_rtoi(), and toml_datum_t::u.

Referenced by toml_val_to_str().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_key_exists()

int toml_key_exists ( const toml_table_t * tab,
const char * key )
extern

Definition at line 1880 of file toml.c.

References toml_table_t::arr, toml_array_t::key, toml_keyval_t::key, toml_table_t::key, toml_table_t::kval, toml_table_t::narr, toml_table_t::nkval, toml_table_t::ntab, and toml_table_t::tab.

Referenced by loadopts_toml().

Here is the caller graph for this function:

◆ toml_key_in()

const char * toml_key_in ( const toml_table_t * tab,
int keyidx )
extern

Definition at line 1865 of file toml.c.

References toml_table_t::arr, toml_array_t::key, toml_keyval_t::key, toml_table_t::key, toml_table_t::kval, toml_table_t::narr, toml_table_t::nkval, and toml_table_t::tab.

Referenced by check_unknown_keys().

Here is the caller graph for this function:

◆ toml_parse()

toml_table_t * toml_parse ( char * conf,
char * errbuf,
int errbufsz )
extern

Definition at line 1402 of file toml.c.

References CALLOC(), context_t::curtab, e_outofmemory(), e_syntax(), eat_token(), token_t::eof, context_t::errbuf, context_t::errbufsz, FLINE, context_t::key, LBRACKET, token_t::len, token_t::lineno, NEWLINE, next_token(), parse_keyval(), parse_select(), token_t::ptr, context_t::root, context_t::start, context_t::stop, STRING, context_t::tok, token_t::tok, toml_free(), context_t::top, context_t::tpath, and xfree().

Referenced by toml_parse_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_parse_file()

toml_table_t * toml_parse_file ( FILE * fp,
char * errbuf,
int errbufsz )
extern

Definition at line 1480 of file toml.c.

References expand(), toml_parse(), and xfree().

Referenced by loadopts_toml().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_raw_at()

toml_raw_t toml_raw_at ( const toml_array_t * arr,
int idx )
extern

Definition at line 1924 of file toml.c.

References toml_array_t::item, nitem(), and toml_arritem_t::val.

Referenced by toml_bool_at(), toml_double_at(), toml_int_at(), toml_string_at(), and toml_timestamp_at().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_raw_in()

toml_raw_t toml_raw_in ( const toml_table_t * tab,
const char * key )
extern

Definition at line 1897 of file toml.c.

References toml_keyval_t::key, toml_table_t::kval, toml_table_t::nkval, and toml_keyval_t::val.

Referenced by toml_bool_in(), toml_double_in(), toml_int_in(), toml_string_in(), and toml_timestamp_in().

Here is the caller graph for this function:

◆ toml_rtob()

int toml_rtob ( toml_raw_t s,
int * ret )
extern

Definition at line 2055 of file toml.c.

Referenced by toml_bool_at(), toml_bool_in(), and valtype().

Here is the caller graph for this function:

◆ toml_rtod()

int toml_rtod ( toml_raw_t s,
double * ret )
extern

Definition at line 2205 of file toml.c.

References toml_rtod_ex().

Referenced by toml_double_at(), toml_double_in(), and valtype().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_rtod_ex()

int toml_rtod_ex ( toml_raw_t s,
double * ret,
char * buf,
int buflen )
extern

Definition at line 2146 of file toml.c.

References dot().

Referenced by toml_rtod().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_rtoi()

int toml_rtoi ( toml_raw_t s,
int64_t * ret )
extern

Definition at line 2073 of file toml.c.

Referenced by toml_int_at(), toml_int_in(), and valtype().

Here is the caller graph for this function:

◆ toml_rtos()

int toml_rtos ( toml_raw_t s,
char ** ret )
extern

Definition at line 2210 of file toml.c.

References norm_basic_str(), and norm_lit_str().

Referenced by toml_string_at(), and toml_string_in().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_rtots()

int toml_rtots ( toml_raw_t s,
toml_timestamp_t * ret )
extern

Definition at line 1966 of file toml.c.

References toml_timestamp_t::__buffer, toml_timestamp_t::day, toml_timestamp_t::hour, toml_timestamp_t::millisec, toml_timestamp_t::minute, toml_timestamp_t::month, parse_millisec(), scan_date(), scan_time(), toml_timestamp_t::second, toml_timestamp_t::year, and toml_timestamp_t::z.

Referenced by toml_timestamp_at(), toml_timestamp_in(), and valtype().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_set_memutil()

void toml_set_memutil ( void *(* xxmalloc )(size_t),
void(* xxfree )(void *) )
extern

Definition at line 41 of file toml.c.

References ppfree, and ppmalloc.

◆ toml_string_at()

toml_datum_t toml_string_at ( const toml_array_t * arr,
int idx )
extern

Definition at line 2265 of file toml.c.

References toml_datum_t::ok, toml_datum_t::s, toml_raw_at(), toml_rtos(), and toml_datum_t::u.

Referenced by loadopts_toml(), and toml_val_to_str().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_string_in()

toml_datum_t toml_string_in ( const toml_table_t * arr,
const char * key )
extern

Definition at line 2323 of file toml.c.

References toml_datum_t::ok, toml_datum_t::s, toml_raw_in(), toml_rtos(), and toml_datum_t::u.

Referenced by toml_val_to_str().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toml_table_at()

toml_table_t * toml_table_at ( const toml_array_t * arr,
int idx )
extern

Definition at line 1960 of file toml.c.

References toml_array_t::item, nitem(), and toml_arritem_t::tab.

Here is the call graph for this function:

◆ toml_table_in()

toml_table_t * toml_table_in ( const toml_table_t * tab,
const char * key )
extern

Definition at line 1915 of file toml.c.

References toml_table_t::key, toml_table_t::ntab, and toml_table_t::tab.

Referenced by check_unknown_keys(), navigate_table(), and parse_keyval().

Here is the caller graph for this function:

◆ toml_table_key()

const char * toml_table_key ( const toml_table_t * tab)
extern

Definition at line 1952 of file toml.c.

References toml_table_t::key.

◆ toml_table_narr()

int toml_table_narr ( const toml_table_t * tab)
extern

Definition at line 1948 of file toml.c.

References toml_table_t::narr.

Referenced by check_unknown_keys().

Here is the caller graph for this function:

◆ toml_table_nkval()

int toml_table_nkval ( const toml_table_t * tab)
extern

Definition at line 1946 of file toml.c.

References toml_table_t::nkval.

Referenced by check_unknown_keys().

Here is the caller graph for this function:

◆ toml_table_ntab()

int toml_table_ntab ( const toml_table_t * tab)
extern

Definition at line 1950 of file toml.c.

References toml_table_t::ntab.

Referenced by check_unknown_keys().

Here is the caller graph for this function:

◆ toml_timestamp_at()

toml_datum_t toml_timestamp_at ( const toml_array_t * arr,
int idx )
extern

Definition at line 2293 of file toml.c.

References toml_timestamp_t::__buffer, toml_timestamp_t::day, toml_timestamp_t::hour, MALLOC, toml_timestamp_t::millisec, toml_timestamp_t::minute, toml_timestamp_t::month, toml_datum_t::ok, toml_timestamp_t::second, toml_raw_at(), toml_rtots(), toml_datum_t::ts, toml_datum_t::u, toml_timestamp_t::year, and toml_timestamp_t::z.

Here is the call graph for this function:

◆ toml_timestamp_in()

toml_datum_t toml_timestamp_in ( const toml_table_t * arr,
const char * key )
extern

Definition at line 2354 of file toml.c.

References toml_timestamp_t::__buffer, toml_timestamp_t::day, toml_timestamp_t::hour, MALLOC, toml_timestamp_t::millisec, toml_timestamp_t::minute, toml_timestamp_t::month, toml_datum_t::ok, toml_timestamp_t::second, toml_raw_in(), toml_rtots(), toml_datum_t::ts, toml_datum_t::u, toml_timestamp_t::year, and toml_timestamp_t::z.

Here is the call graph for this function:

◆ toml_ucs_to_utf8()

int toml_ucs_to_utf8 ( int64_t code,
char buf[6] )
extern

Convert a UCS char to utf8 code, and return it in buf. Return #bytes used in buf to encode the char, or -1 on error.

Definition at line 198 of file toml.c.

Referenced by norm_basic_str().

Here is the caller graph for this function:

◆ toml_utf8_to_ucs()

int toml_utf8_to_ucs ( const char * orig,
int len,
int64_t * ret )
extern

Convert a char in utf8 into UCS, and store it in *ret. Return #bytes consumed or -1 on failure.

Definition at line 97 of file toml.c.