\doxysection{Qore\+::Single\+Value\+Iterator Class Reference}
\hypertarget{class_qore_1_1_single_value_iterator}{}\label{class_qore_1_1_single_value_iterator}\index{Qore::SingleValueIterator@{Qore::SingleValueIterator}}


This class defines a simple iterator to be used to iterate single values (or complex objects where no iterator has been implemented yet)  




{\ttfamily \#include $<$QC\+\_\+\+Single\+Value\+Iterator.\+dox.\+h$>$}



Inheritance diagram for Qore\+::Single\+Value\+Iterator\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=219pt]{class_qore_1_1_single_value_iterator__inherit__graph}
\end{center}
\end{figure}
\doxysubsubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{class_qore_1_1_single_value_iterator_a7991e0509145e7c02eb7220ec068e0c0}{constructor}} (\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{auto}} \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{v}})
\begin{DoxyCompactList}\small\item\em creates the single value iterator with the value passed as an argument \end{DoxyCompactList}\item 
\mbox{\hyperlink{class_qore_1_1_single_value_iterator_af8bfa7e66fd73c0de1c4f05c03a9fc78}{copy}} ()
\begin{DoxyCompactList}\small\item\em Creates a copy of the \doxylink{class_qore_1_1_single_value_iterator}{Single\+Value\+Iterator} object, iterating the same object as the original and in the same position. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{auto}} \mbox{\hyperlink{class_qore_1_1_single_value_iterator_a4f8553281a347e9e10077ab154a1190a}{get\+Value}} ()
\begin{DoxyCompactList}\small\item\em returns the current value or throws an {\ttfamily INVALID-\/\+ITERATOR} exception if the iterator is invalid \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} \mbox{\hyperlink{class_qore_1_1_single_value_iterator_a2923e45802fc98a2fb9207989710de1d}{next}} ()
\begin{DoxyCompactList}\small\item\em This method returns \doxysectlink{basic_data_types_True}{True}{2} and \doxysectlink{basic_data_types_False}{False}{2} alternately unless it has no value to iterate, in which case it returns only \doxysectlink{basic_data_types_False}{False}{2}. \end{DoxyCompactList}\item 
\mbox{\hyperlink{class_qore_1_1_single_value_iterator_a7e96e7dbea4e7e680b74ab605db403cc}{reset}} ()
\begin{DoxyCompactList}\small\item\em Reset the iterator instance to its initial state. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} \mbox{\hyperlink{class_qore_1_1_single_value_iterator_aafb8a835f5535484dc1a1fb97b8a1328}{valid}} ()
\begin{DoxyCompactList}\small\item\em returns \doxysectlink{basic_data_types_True}{True}{2} if the iterator is currently pointing at a valid element, \doxysectlink{basic_data_types_False}{False}{2} if not \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Public Member Functions inherited from \mbox{\hyperlink{class_qore_1_1_abstract_iterator}{Qore\+::\+Abstract\+Iterator}}}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{abstract}} \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{auto}} \mbox{\hyperlink{class_qore_1_1_abstract_iterator_aa01374b285003faa21b045082063ac12}{get\+Value}} ()
\begin{DoxyCompactList}\small\item\em returns the current value \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{abstract}} \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} \mbox{\hyperlink{class_qore_1_1_abstract_iterator_ab10d5694cc2fcd3b6689ea7494da79de}{next}} ()
\begin{DoxyCompactList}\small\item\em Moves the current position to the next element; returns \doxysectlink{basic_data_types_False}{False}{2} if there are no more elements. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{abstract}} \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} \mbox{\hyperlink{class_qore_1_1_abstract_iterator_aee1def5d872b487b8917a166d9b263e8}{valid}} ()
\begin{DoxyCompactList}\small\item\em returns \doxysectlink{basic_data_types_True}{True}{2} if the iterator is currently pointing at a valid element, \doxysectlink{basic_data_types_False}{False}{2} if not \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
This class defines a simple iterator to be used to iterate single values (or complex objects where no iterator has been implemented yet) 

\begin{DoxySince}{Since}
Qore 0.\+8.\+6
\end{DoxySince}
\begin{DoxyParagraph}{Example\+: Single\+Value\+Iterator basic usage}

\begin{DoxyCode}{0}
\DoxyCodeLine{auto\ val\ =\ 1;}
\DoxyCodeLine{SingleValueIterator\ it(val);}
\DoxyCodeLine{\textcolor{keywordflow}{while}\ (it.next())\ \{}
\DoxyCodeLine{\ \ \ \ printf(\textcolor{stringliteral}{"{}iter:\ \%n\(\backslash\)n"{}},\ it.getValue());}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{iter:\ 1}

\end{DoxyCode}

\end{DoxyParagraph}
Remember that input value is taken as a single token so result of the code above for a list as an input argument will be like this\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{auto\ val\ =\ (1,\ 2,\ 3);}
\DoxyCodeLine{iter:\ list:\ (1,\ 2,\ 3)}

\end{DoxyCode}
 

\doxysubsection{Member Function Documentation}
\Hypertarget{class_qore_1_1_single_value_iterator_a7991e0509145e7c02eb7220ec068e0c0}\label{class_qore_1_1_single_value_iterator_a7991e0509145e7c02eb7220ec068e0c0} 
\index{Qore::SingleValueIterator@{Qore::SingleValueIterator}!constructor@{constructor}}
\index{constructor@{constructor}!Qore::SingleValueIterator@{Qore::SingleValueIterator}}
\doxysubsubsection{\texorpdfstring{constructor()}{constructor()}}
{\footnotesize\ttfamily Qore\+::\+Single\+Value\+Iterator\+::constructor (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{auto}}}]{v }\end{DoxyParamCaption})}



creates the single value iterator with the value passed as an argument 


\begin{DoxyParams}{Parameters}
{\em v} & the value to iterate\\
\hline
\end{DoxyParams}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{SingleValueIterator\ i(v);}

\end{DoxyCode}
 
\end{DoxyParagraph}
\Hypertarget{class_qore_1_1_single_value_iterator_af8bfa7e66fd73c0de1c4f05c03a9fc78}\label{class_qore_1_1_single_value_iterator_af8bfa7e66fd73c0de1c4f05c03a9fc78} 
\index{Qore::SingleValueIterator@{Qore::SingleValueIterator}!copy@{copy}}
\index{copy@{copy}!Qore::SingleValueIterator@{Qore::SingleValueIterator}}
\doxysubsubsection{\texorpdfstring{copy()}{copy()}}
{\footnotesize\ttfamily Qore\+::\+Single\+Value\+Iterator\+::copy (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Creates a copy of the \doxylink{class_qore_1_1_single_value_iterator}{Single\+Value\+Iterator} object, iterating the same object as the original and in the same position. 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{SingleValueIterator\ ni\ =\ i.copy();}

\end{DoxyCode}
 
\end{DoxyParagraph}
\Hypertarget{class_qore_1_1_single_value_iterator_a4f8553281a347e9e10077ab154a1190a}\label{class_qore_1_1_single_value_iterator_a4f8553281a347e9e10077ab154a1190a} 
\index{Qore::SingleValueIterator@{Qore::SingleValueIterator}!getValue@{getValue}}
\index{getValue@{getValue}!Qore::SingleValueIterator@{Qore::SingleValueIterator}}
\doxysubsubsection{\texorpdfstring{getValue()}{getValue()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{auto}} Qore\+::\+Single\+Value\+Iterator\+::get\+Value (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



returns the current value or throws an {\ttfamily INVALID-\/\+ITERATOR} exception if the iterator is invalid 

\begin{DoxyReturn}{Returns}
the current value or throws an {\ttfamily INVALID-\/\+ITERATOR} exception if the iterator is invalid
\end{DoxyReturn}
\begin{DoxyParagraph}{Code Flags\+:}
\doxysectlink{code_flags_RET_VALUE_ONLY}{RET\+\_\+\+VALUE\+\_\+\+ONLY}{1}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keywordflow}{while}\ (i.next())\ \{}
\DoxyCodeLine{\ \ \ \ printf(\textcolor{stringliteral}{"{}+\ \%y\(\backslash\)n"{}},\ i.getValue());}
\DoxyCodeLine{\}}

\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyExceptions}{Exceptions}
{\em INVALID-\/\+ITERATOR} & the iterator is not pointing at a valid element \\
\hline
\end{DoxyExceptions}
\Hypertarget{class_qore_1_1_single_value_iterator_a2923e45802fc98a2fb9207989710de1d}\label{class_qore_1_1_single_value_iterator_a2923e45802fc98a2fb9207989710de1d} 
\index{Qore::SingleValueIterator@{Qore::SingleValueIterator}!next@{next}}
\index{next@{next}!Qore::SingleValueIterator@{Qore::SingleValueIterator}}
\doxysubsubsection{\texorpdfstring{next()}{next()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} Qore\+::\+Single\+Value\+Iterator\+::next (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



This method returns \doxysectlink{basic_data_types_True}{True}{2} and \doxysectlink{basic_data_types_False}{False}{2} alternately unless it has no value to iterate, in which case it returns only \doxysectlink{basic_data_types_False}{False}{2}. 

The iterator object should not be used after this method returns \doxysectlink{basic_data_types_False}{False}{2}

\begin{DoxyReturn}{Returns}
\doxysectlink{basic_data_types_True}{True}{2} and \doxysectlink{basic_data_types_False}{False}{2} alternately unless it has no value to iterate, in which case it returns only \doxysectlink{basic_data_types_False}{False}{2}
\end{DoxyReturn}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keywordflow}{while}\ (i.next())\ \{}
\DoxyCodeLine{\ \ \ \ printf(\textcolor{stringliteral}{"{}value:\ \%y\(\backslash\)n"{}},\ i.getValue());}
\DoxyCodeLine{\}}

\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyExceptions}{Exceptions}
{\em ITERATOR-\/\+THREAD-\/\+ERROR} & this exception is thrown if this method is called from any thread other than the thread that created the object \\
\hline
\end{DoxyExceptions}
\Hypertarget{class_qore_1_1_single_value_iterator_a7e96e7dbea4e7e680b74ab605db403cc}\label{class_qore_1_1_single_value_iterator_a7e96e7dbea4e7e680b74ab605db403cc} 
\index{Qore::SingleValueIterator@{Qore::SingleValueIterator}!reset@{reset}}
\index{reset@{reset}!Qore::SingleValueIterator@{Qore::SingleValueIterator}}
\doxysubsubsection{\texorpdfstring{reset()}{reset()}}
{\footnotesize\ttfamily Qore\+::\+Single\+Value\+Iterator\+::reset (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Reset the iterator instance to its initial state. 

Reset the iterator instance to its initial state

\begin{DoxyParagraph}{Example}

\begin{DoxyCode}{0}
\DoxyCodeLine{i.reset();}

\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyExceptions}{Exceptions}
{\em ITERATOR-\/\+THREAD-\/\+ERROR} & this exception is thrown if this method is called from any thread other than the thread that created the object \\
\hline
\end{DoxyExceptions}
\Hypertarget{class_qore_1_1_single_value_iterator_aafb8a835f5535484dc1a1fb97b8a1328}\label{class_qore_1_1_single_value_iterator_aafb8a835f5535484dc1a1fb97b8a1328} 
\index{Qore::SingleValueIterator@{Qore::SingleValueIterator}!valid@{valid}}
\index{valid@{valid}!Qore::SingleValueIterator@{Qore::SingleValueIterator}}
\doxysubsubsection{\texorpdfstring{valid()}{valid()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} Qore\+::\+Single\+Value\+Iterator\+::valid (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



returns \doxysectlink{basic_data_types_True}{True}{2} if the iterator is currently pointing at a valid element, \doxysectlink{basic_data_types_False}{False}{2} if not 

\begin{DoxyReturn}{Returns}
\doxysectlink{basic_data_types_True}{True}{2} if the iterator is currently pointing at a valid element, \doxysectlink{basic_data_types_False}{False}{2} if not
\end{DoxyReturn}
\begin{DoxyParagraph}{Code Flags\+:}
\doxysectlink{code_flags_CONSTANT}{CONSTANT}{1}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keywordflow}{if}\ (i.valid())}
\DoxyCodeLine{\ \ \ \ printf(\textcolor{stringliteral}{"{}current\ value:\ \%y\(\backslash\)n"{}},\ i.getValue());}

\end{DoxyCode}
 
\end{DoxyParagraph}
