+ /// Long option name (without the <code>\--</code> prefix), or \c NULL
+ const char *const long_name;
+
+ /// \c true if this option has an argument
+ const bool with_arg;
+};
+
+/*!
+@brief
+ Sentinel for an option descriptor array
+
+The typical usage is, for example:
+
+@code
+const struct argpar_opt_descr descrs[] = {
+ { 0, 'd', NULL, false },
+ { 1, '\0', "squeeze", true },
+ { 2, 'm', "meow", true },
+ ARGPAR_OPT_DESCR_SENTINEL,
+};
+@endcode
+*/
+#define ARGPAR_OPT_DESCR_SENTINEL \
+ { \
+ -1, '\0', NULL, false \
+ }
+
+/*!
+@struct argpar_iter
+
+@brief
+ Opaque argpar iterator type
+
+argpar_iter_create() returns a pointer to such a type.
+*/
+struct argpar_iter;
+
+/*!
+@brief
+ Creates and returns an argument parsing iterator to parse the
+ original arguments \p argv of which the count is \p argc using the
+ option descriptors \p descrs.
+
+This function initializes the returned structure, but doesn't actually
+start parsing the arguments.
+
+argpar considers \em all the elements of \p argv, including the first
+one, so that you would typically pass <code>(argc - 1)</code> as \p argc
+and <code>\&argv[1]</code> as \p argv from what <code>main()</code>
+receives, or ignore the parsing item of the first call to
+argpar_iter_next().
+
+\p *argv and \p *descrs must \em not change for all of:
+
+- The lifetime of the returned iterator (until you call
+ argpar_iter_destroy()).
+
+- The lifetime of any parsing item (until you call
+ argpar_item_destroy()) which argpar_iter_next() creates from the
+ returned iterator.
+
+- The lifetime of any parsing error (until you call
+ argpar_error_destroy()) which argpar_iter_next() creates from the
+ returned iterator.
+
+@param[in] argc
+ Number of original arguments to parse in \p argv.
+@param[in] argv
+ Original arguments to parse, of which the count is \p argc.
+@param[in] descrs
+ @parblock
+ Option descriptor array, terminated with #ARGPAR_OPT_DESCR_SENTINEL.
+
+ May contain duplicate entries.
+ @endparblock
+
+@returns
+ New argument parsing iterator, or \c NULL on memory error.
+
+@pre
+ \p argc is greater than 0.
+@pre
+ \p argv is not \c NULL.
+@pre
+ The first \p argc elements of \p argv are not \c NULL.
+@pre
+ \p descrs is not \c NULL.
+
+@sa
+ argpar_iter_destroy() -- Destroys an argument parsing iterator.
+*/
+/// @cond hidden_macro
+ARGPAR_HIDDEN
+/// @endcond
+struct argpar_iter *argpar_iter_create(unsigned int argc,
+ const char *const *argv,
+ const struct argpar_opt_descr *descrs);
+
+/*!
+@brief
+ Destroys the argument parsing iterator \p iter.
+
+@param[in] iter
+ Argument parsing iterator to destroy (may be \c NULL).
+
+@sa
+ argpar_iter_create() -- Creates an argument parsing iterator.
+*/
+/// @cond hidden_macro
+ARGPAR_HIDDEN
+/// @endcond
+void argpar_iter_destroy(struct argpar_iter *iter);
+
+/*!
+@brief
+ Return type of argpar_iter_next().
+
+Error status enumerators have a negative value.
+*/
+enum argpar_iter_next_status {
+ /// Success
+ ARGPAR_ITER_NEXT_STATUS_OK,
+
+ /// End of iteration (no more original arguments to parse)
+ ARGPAR_ITER_NEXT_STATUS_END,
+
+ /// Parsing error
+ ARGPAR_ITER_NEXT_STATUS_ERROR = -1,
+
+ /// Memory error
+ ARGPAR_ITER_NEXT_STATUS_ERROR_MEMORY = -12,
+};
+
+/*!
+@brief
+ Sets \p *item to the next item of the argument parsing iterator
+ \p iter and advances \p iter.
+
+If there are no more original arguments to parse, this function returns
+#ARGPAR_ITER_NEXT_STATUS_END.
+
+@param[in] iter
+ Argument parsing iterator from which to get the next parsing item.
+@param[out] item
+ @parblock
+ On success, \p *item is the next parsing item of \p iter.
+
+ Destroy \p *item with argpar_item_destroy().
+ @endparblock
+@param[out] error
+ @parblock
+ When this function returns #ARGPAR_ITER_NEXT_STATUS_ERROR,
+ if this parameter is not \c NULL, \p *error contains details about
+ the error.
+
+ Destroy \p *error with argpar_error_destroy().
+ @endparblock
+
+@returns
+ Status code.
+
+@pre
+ \p iter is not \c NULL.
+@pre
+ \p item is not \c NULL.
+*/
+/// @cond hidden_macro