diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2013-08-08 14:39:32 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2013-08-08 14:39:32 +0200 |
commit | eba7399251cfa95d9346b9b41ca78dc5d43a840d (patch) | |
tree | 60c186b774d8ee0f1130e043366a33edcb0ec5dc /include/git2/sys | |
parent | 4efa32903adf131631d283c914e0a5bf29c49e4d (diff) | |
download | libgit2-eba7399251cfa95d9346b9b41ca78dc5d43a840d.tar.gz |
config: move next() and free() into the iterator
Like we have in the references iterator, next and free belong in the
iterator itself.
Diffstat (limited to 'include/git2/sys')
-rw-r--r-- | include/git2/sys/config.h | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/include/git2/sys/config.h b/include/git2/sys/config.h index 09c79638a..45599dc69 100644 --- a/include/git2/sys/config.h +++ b/include/git2/sys/config.h @@ -21,6 +21,32 @@ GIT_BEGIN_DECL /** + * Every iterator must have this struct as its first element, so the + * API can talk to it. You'd define your iterator as + * + * struct my_iterator { + * git_config_iterator parent; + * ... + * } + * + * and assign `iter->parent.backend` to your `git_config_backend`. + */ +struct git_config_iterator { + git_config_backend *backend; + unsigned int flags; + + /** + * Return the current entry and advance the iterator + */ + int (*next)(git_config_entry *entry, git_config_iterator *iter); + + /** + * Free the iterator + */ + void (*free)(git_config_iterator *iter); +}; + +/** * Generic backend that implements the interface to * access a configuration file */ @@ -35,9 +61,7 @@ struct git_config_backend { int (*set)(struct git_config_backend *, const char *key, const char *value); int (*set_multivar)(git_config_backend *cfg, const char *name, const char *regexp, const char *value); int (*del)(struct git_config_backend *, const char *key); - int (*iterator_new)(git_config_backend_iter **, struct git_config_backend *); - void (*iterator_free)(git_config_backend_iter *); - int (*next)(git_config_entry *, git_config_backend_iter *); + int (*iterator)(git_config_iterator **, struct git_config_backend *); int (*refresh)(struct git_config_backend *); void (*free)(struct git_config_backend *); }; |