1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
\hypertarget{group__ITER}{
\section{ITER}
\label{group__ITER}\index{ITER@{ITER}}
}
Iterators concept.
\subsection*{Defines}
\begin{DoxyCompactItemize}
\item
\#define \hyperlink{group__ITER_gaea98dedf8ff9418609496bb11ff8c66c}{OSCAP\_\-FOREACH\_\-GENERIC}(itype, vtype, val, init\_\-val, code)
\begin{DoxyCompactList}\small\item\em Iterate over an array, given an iterator. \item\end{DoxyCompactList}\item
\#define \hyperlink{group__ITER_ga252a13d8be22bb101a8732987eb4e828}{OSCAP\_\-FOREACH}(type, val, init\_\-val, code)~OSCAP\_\-FOREACH\_\-GENERIC(type, struct type $\ast$, val, init\_\-val, code)
\begin{DoxyCompactList}\small\item\em Iterate over an array, given an iterator. \item\end{DoxyCompactList}\item
\#define \hyperlink{group__ITER_gafdd9cc9b1ae693c07dd4ff9727cfb019}{OSCAP\_\-FOREACH\_\-STR}(val, init\_\-val, code)~OSCAP\_\-FOREACH\_\-GENERIC(oscap\_\-string, const char $\ast$, val, init\_\-val, code)
\begin{DoxyCompactList}\small\item\em Iterate over an array of strings, given an iterator. \item\end{DoxyCompactList}\item
\#define \hyperlink{group__ITER_gae94ba5c82c04c4119b11bbf8be56ed69}{OSCAP\_\-FOR\_\-GENERIC}(itype, vtype, val, init\_\-val)
\begin{DoxyCompactList}\small\item\em Iterate over an array, given an iterator. \item\end{DoxyCompactList}\item
\#define \hyperlink{group__ITER_ga4531eed65f8744afef6718920525395c}{OSCAP\_\-FOR}(type, val, init\_\-val)~OSCAP\_\-FOR\_\-GENERIC(type, struct type $\ast$, val, init\_\-val)
\begin{DoxyCompactList}\small\item\em Iterate over an array, given an iterator. \item\end{DoxyCompactList}\item
\#define \hyperlink{group__ITER_ga9f9c24f232e5ad2aeeeed602b7b0008c}{OSCAP\_\-FOR\_\-STR}(val, init\_\-val)~OSCAP\_\-FOR\_\-GENERIC(oscap\_\-string, const char $\ast$, val, init\_\-val)
\begin{DoxyCompactList}\small\item\em Iterate over an array of strings, given an iterator. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection{Detailed Description}
Iterators concept. Any iterator name takes a form of {\ttfamily struct OBJECT\_\-iterator}, where {\ttfamily OBJECT} is a name of particular datatype the iterator iterates over.
Each iterator type defines several manipulation functions, namely:
\begin{DoxyItemize}
\item {\ttfamily OBJECT\_\-iterator\_\-has\_\-more} -\/ returns true if there is anything left to iterate over
\item {\ttfamily OBJECT\_\-iterator\_\-next} -\/ returns next item in the collection
\item {\ttfamily OBJECT\_\-iterator\_\-free} -\/ destroys the iterator
\end{DoxyItemize}
You can also use \hyperlink{group__ITER_ga252a13d8be22bb101a8732987eb4e828}{OSCAP\_\-FOREACH} convience macro.
\subsection{Define Documentation}
\hypertarget{group__ITER_ga4531eed65f8744afef6718920525395c}{
\index{ITER@{ITER}!OSCAP\_\-FOR@{OSCAP\_\-FOR}}
\index{OSCAP\_\-FOR@{OSCAP\_\-FOR}!ITER@{ITER}}
\subsubsection[{OSCAP\_\-FOR}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-FOR(type, \/ val, \/ init\_\-val)~OSCAP\_\-FOR\_\-GENERIC(type, struct type $\ast$, val, init\_\-val)}}
\label{group__ITER_ga4531eed65f8744afef6718920525395c}
Iterate over an array, given an iterator.
\begin{DoxyParams}{Parameters}
\item[{\em type}]type of array elements (w/o the struct keyword) \item[{\em val}]name of an variable the member will be sequentially stored in \item[{\em init\_\-val}]initial member value (i.e. an iterator pointing to the start element) \end{DoxyParams}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__ITER_gae94ba5c82c04c4119b11bbf8be56ed69}{OSCAP\_\-FOR\_\-GENERIC}
\end{DoxySeeAlso}
\hypertarget{group__ITER_gae94ba5c82c04c4119b11bbf8be56ed69}{
\index{ITER@{ITER}!OSCAP\_\-FOR\_\-GENERIC@{OSCAP\_\-FOR\_\-GENERIC}}
\index{OSCAP\_\-FOR\_\-GENERIC@{OSCAP\_\-FOR\_\-GENERIC}!ITER@{ITER}}
\subsubsection[{OSCAP\_\-FOR\_\-GENERIC}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-FOR\_\-GENERIC(itype, \/ vtype, \/ val, \/ init\_\-val)}}
\label{group__ITER_gae94ba5c82c04c4119b11bbf8be56ed69}
{\bfseries Value:}
\begin{DoxyCode}
vtype val = NULL; struct itype##_iterator *val##_iter = (init_val); \
while (itype##_iterator_has_more(val##_iter) \
? (val = itype##_iterator_next(val##_iter), true) \
: (itype##_iterator_free(val##_iter), val##_iter = NULL, false))
\end{DoxyCode}
Iterate over an array, given an iterator. It is generally not safe to use break, return or goto inside the loop (iterator wouldn't be properly freed otherwise). Two variables, named VAL and VAL\_\-iter (substitute VAL for actual macro argument) will be added to current variable scope. You can free the iterator explicitly after previous unusual escape from the loop (e.g. using break).
\begin{DoxyParams}{Parameters}
\item[{\em val}]name of an variable the string will be sequentially stored in \item[{\em init\_\-val}]initial member value (i.e. an iterator pointing to the start element) \item[{\em code}]code to be executed for each string the iterator hits \end{DoxyParams}
\hypertarget{group__ITER_ga9f9c24f232e5ad2aeeeed602b7b0008c}{
\index{ITER@{ITER}!OSCAP\_\-FOR\_\-STR@{OSCAP\_\-FOR\_\-STR}}
\index{OSCAP\_\-FOR\_\-STR@{OSCAP\_\-FOR\_\-STR}!ITER@{ITER}}
\subsubsection[{OSCAP\_\-FOR\_\-STR}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-FOR\_\-STR(val, \/ init\_\-val)~OSCAP\_\-FOR\_\-GENERIC(oscap\_\-string, const char $\ast$, val, init\_\-val)}}
\label{group__ITER_ga9f9c24f232e5ad2aeeeed602b7b0008c}
Iterate over an array of strings, given an iterator.
\begin{DoxyParams}{Parameters}
\item[{\em val}]name of an variable the member will be sequentially stored in \item[{\em init\_\-val}]initial member value (i.e. an iterator pointing to the start element) \end{DoxyParams}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__ITER_gae94ba5c82c04c4119b11bbf8be56ed69}{OSCAP\_\-FOR\_\-GENERIC}
\end{DoxySeeAlso}
\hypertarget{group__ITER_ga252a13d8be22bb101a8732987eb4e828}{
\index{ITER@{ITER}!OSCAP\_\-FOREACH@{OSCAP\_\-FOREACH}}
\index{OSCAP\_\-FOREACH@{OSCAP\_\-FOREACH}!ITER@{ITER}}
\subsubsection[{OSCAP\_\-FOREACH}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-FOREACH(type, \/ val, \/ init\_\-val, \/ code)~OSCAP\_\-FOREACH\_\-GENERIC(type, struct type $\ast$, val, init\_\-val, code)}}
\label{group__ITER_ga252a13d8be22bb101a8732987eb4e828}
Iterate over an array, given an iterator.
\begin{DoxyParams}{Parameters}
\item[{\em type}]type of array elements (w/o the struct keyword) \item[{\em val}]name of an variable the member will be sequentially stored in \item[{\em init\_\-val}]initial member value (i.e. an iterator pointing to the start element) \item[{\em code}]code to be executed for each element the iterator hits \end{DoxyParams}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__ITER_gaea98dedf8ff9418609496bb11ff8c66c}{OSCAP\_\-FOREACH\_\-GENERIC}
\end{DoxySeeAlso}
\hypertarget{group__ITER_gaea98dedf8ff9418609496bb11ff8c66c}{
\index{ITER@{ITER}!OSCAP\_\-FOREACH\_\-GENERIC@{OSCAP\_\-FOREACH\_\-GENERIC}}
\index{OSCAP\_\-FOREACH\_\-GENERIC@{OSCAP\_\-FOREACH\_\-GENERIC}!ITER@{ITER}}
\subsubsection[{OSCAP\_\-FOREACH\_\-GENERIC}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-FOREACH\_\-GENERIC(itype, \/ vtype, \/ val, \/ init\_\-val, \/ code)}}
\label{group__ITER_gaea98dedf8ff9418609496bb11ff8c66c}
{\bfseries Value:}
\begin{DoxyCode}
{ \
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); \
}
\end{DoxyCode}
Iterate over an array, given an iterator. Execute {\itshape code\/} for each array member stored in {\itshape val\/}. It is NOT safe to use return or goto inside of the {\itshape code\/} or iterator will not be freed properly. \hypertarget{group__ITER_gafdd9cc9b1ae693c07dd4ff9727cfb019}{
\index{ITER@{ITER}!OSCAP\_\-FOREACH\_\-STR@{OSCAP\_\-FOREACH\_\-STR}}
\index{OSCAP\_\-FOREACH\_\-STR@{OSCAP\_\-FOREACH\_\-STR}!ITER@{ITER}}
\subsubsection[{OSCAP\_\-FOREACH\_\-STR}]{\setlength{\rightskip}{0pt plus 5cm}\#define OSCAP\_\-FOREACH\_\-STR(val, \/ init\_\-val, \/ code)~OSCAP\_\-FOREACH\_\-GENERIC(oscap\_\-string, const char $\ast$, val, init\_\-val, code)}}
\label{group__ITER_gafdd9cc9b1ae693c07dd4ff9727cfb019}
Iterate over an array of strings, given an iterator.
\begin{DoxyParams}{Parameters}
\item[{\em val}]name of an variable the string will be sequentially stored in \item[{\em init\_\-val}]initial member value (i.e. an iterator pointing to the start element) \item[{\em code}]code to be executed for each string the iterator hits \end{DoxyParams}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__ITER_gaea98dedf8ff9418609496bb11ff8c66c}{OSCAP\_\-FOREACH\_\-GENERIC}
\end{DoxySeeAlso}
|