Currently the only pull parsing APIs are ini_get* which are suboptimal as they open, re-parse, and close the file on each invocation. ini_browse is efficient but offers only push-style API which requires caller to define a function and often an artificial context struct. Adding iterator-based API would give both -- efficiency and pull parsing which results in more natural caller code.
Proposed outline of the API:
struct ini_iter;
int ini_iteropen(struct ini_iter* it, const char* filename);
int ini_iternext(struct ini_iter* it);
int ini_iterclose(struct ini_iter* it);
I already looked at minini code and know how it could be implemented. I can take the effort but wanted to know first if such a design is welcome at all.
Currently the only pull parsing APIs are ini_get* which are suboptimal as they open, re-parse, and close the file on each invocation. ini_browse is efficient but offers only push-style API which requires caller to define a function and often an artificial context struct. Adding iterator-based API would give both -- efficiency and pull parsing which results in more natural caller code.
Proposed outline of the API:
Example of use:
I already looked at minini code and know how it could be implemented. I can take the effort but wanted to know first if such a design is welcome at all.