Iterators & collections
[COMMON]

OpenScap iterators concept. More...

Defines

#define OSCAP_FOREACH_GENERIC(itype, vtype, val, init_val, code)
 Iterate over an array, given an iterator.
#define OSCAP_FOREACH(type, val, init_val, code)   OSCAP_FOREACH_GENERIC(type, struct type *, val, init_val, code)
 Iterate over an array, given an iterator.
#define OSCAP_FOREACH_STR(val, init_val, code)   OSCAP_FOREACH_GENERIC(oscap_string, const char *, val, init_val, code)
 Iterate over an array of strings, given an iterator.

Detailed Description

OpenScap iterators concept.

Any iterator name takes a form of struct OBJECT_iterator, where OBJECT is a name of particular datatype the iterator iterates over.

Each iterator type defines several manipulation functions, namely:

You can also use OSCAP_FOREACH convience macro.


Define Documentation

#define OSCAP_FOREACH ( type,
val,
init_val,
code   )     OSCAP_FOREACH_GENERIC(type, struct type *, val, init_val, code)

Iterate over an array, given an iterator.

Parameters:
type type of array elements (w/o the struct keyword)
val name of an variable the member will be sequentially stored in
init_val initial member value (i.e. an iterator pointing to the start element)
code code to be executed for each element the iterator hits
See also:
OSCAP_FOREACH_GENERIC
#define OSCAP_FOREACH_GENERIC ( itype,
vtype,
val,
init_val,
code   ) 
Value:
{                                                            \
        struct itype##_iterator *val##_iter = (init_val);        \
        vtype val;                                               \
        while (itype##_iterator_has_more(val##_iter)) {          \
            val = itype##_iterator_next(val##_iter);             \
            code                                                 \
        }                                                        \
        itype##_iterator_free(val##_iter);                       \
    }

Iterate over an array, given an iterator.

Execute code for each array member stored in val.

#define OSCAP_FOREACH_STR ( val,
init_val,
code   )     OSCAP_FOREACH_GENERIC(oscap_string, const char *, val, init_val, code)

Iterate over an array of strings, given an iterator.

Parameters:
val name of an variable the string will be sequentially stored in
init_val initial member value (i.e. an iterator pointing to the start element)
code code to be executed for each string the iterator hits
See also:
OSCAP_FOREACH_GENERIC

Generated on 24 Mar 2010 for Open SCAP Library by  doxygen 1.6.1