2 * Copyright (c) 2007-2012, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
13 #ifndef LIBSOLV_DATAITERATOR_H
14 #define LIBSOLV_DATAITERATOR_H
16 #include "pooltypes.h"
21 typedef struct _KeyValue {
27 int entry; /* array entry, starts with 0 */
28 int eof; /* last entry reached */
30 struct _KeyValue *parent;
33 /* search matcher flags */
34 #define SEARCH_STRINGMASK 15
35 #define SEARCH_STRING 1
36 #define SEARCH_STRINGSTART 2
37 #define SEARCH_STRINGEND 3
38 #define SEARCH_SUBSTRING 4
40 #define SEARCH_REGEX 6
41 #define SEARCH_ERROR 15
42 #define SEARCH_NOCASE (1<<7)
44 /* iterator control */
45 #define SEARCH_NO_STORAGE_SOLVABLE (1<<8)
46 #define SEARCH_SUB (1<<9)
47 #define SEARCH_ARRAYSENTINEL (1<<10)
48 #define SEARCH_DISABLED_REPOS (1<<11)
49 #define SEARCH_COMPLETE_FILELIST (1<<12)
51 /* stringification flags */
52 #define SEARCH_SKIP_KIND (1<<16)
53 /* By default we stringify just to the basename of a file because
54 the construction of the full filename is costly. Specify this
55 flag if you want to match full filenames */
56 #define SEARCH_FILES (1<<17)
57 #define SEARCH_CHECKSUMS (1<<18)
59 /* dataiterator internal */
60 #define SEARCH_THISSOLVID (1<<31)
62 typedef struct _Datamatcher {
69 typedef struct _Dataiterator
76 struct _Repodata *data;
91 /* iterators/filters */
111 int datamatcher_init(Datamatcher *ma, const char *match, int flags);
112 void datamatcher_free(Datamatcher *ma);
113 int datamatcher_match(Datamatcher *ma, const char *str);
118 * Iterator like interface to 'search' functionality
120 * Dataiterator is per-pool, additional filters can be applied
121 * to limit the search domain. See dataiterator_init below.
125 * dataiterator_init(&di, repo->pool, repo, 0, 0, "bla", SEARCH_SUBSTRING);
126 * while (dataiterator_step(&di))
127 * dosomething(di.solvid, di.key, di.kv);
128 * dataiterator_free(&di);
132 * Initialize dataiterator
134 * di: Pointer to Dataiterator to be initialized
135 * pool: Search domain for the iterator
136 * repo: if non-null, limit search to this repo
137 * solvid: if non-null, limit search to this solvable
138 * keyname: if non-null, limit search to this keyname
139 * match: if non-null, limit search to this match
141 int dataiterator_init(Dataiterator *di, Pool *pool, struct _Repo *repo, Id p, Id keyname, const char *match, int flags);
142 void dataiterator_init_clone(Dataiterator *di, Dataiterator *from);
143 void dataiterator_set_search(Dataiterator *di, struct _Repo *repo, Id p);
144 void dataiterator_set_keyname(Dataiterator *di, Id keyname);
145 int dataiterator_set_match(Dataiterator *di, const char *match, int flags);
147 void dataiterator_prepend_keyname(Dataiterator *di, Id keyname);
148 void dataiterator_free(Dataiterator *di);
149 int dataiterator_step(Dataiterator *di);
150 void dataiterator_setpos(Dataiterator *di);
151 void dataiterator_setpos_parent(Dataiterator *di);
152 int dataiterator_match(Dataiterator *di, Datamatcher *ma);
153 void dataiterator_skip_attribute(Dataiterator *di);
154 void dataiterator_skip_solvable(Dataiterator *di);
155 void dataiterator_skip_repo(Dataiterator *di);
156 void dataiterator_jump_to_solvid(Dataiterator *di, Id solvid);
157 void dataiterator_jump_to_repo(Dataiterator *di, struct _Repo *repo);
158 void dataiterator_entersub(Dataiterator *di);
159 void dataiterator_clonepos(Dataiterator *di, Dataiterator *from);
160 void dataiterator_seek(Dataiterator *di, int whence);
162 #define DI_SEEK_STAY (1 << 16)
163 #define DI_SEEK_CHILD 1
164 #define DI_SEEK_PARENT 2
165 #define DI_SEEK_REWIND 3
167 #endif /* LIBSOLV_DATAITERATOR_H */