Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterator API #8

Open
tomeksowi opened this issue Jul 3, 2017 · 0 comments
Open

Iterator API #8

tomeksowi opened this issue Jul 3, 2017 · 0 comments

Comments

@tomeksowi
Copy link

tomeksowi commented Jul 3, 2017

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);

Example of use:

struct ini_iter it;
for (ini_iteropen(&it, "test.ini"); ini_iternext(&it); ) {
	printf("[%s] %s = %s\n", it.section, it.key, it.value);
}
ini_iterclose(&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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant