+struct argpar_opt_descr;
+
+/*!
+@name Item API
+@{
+*/
+
+/*!
+@brief
+ Type of a parsing item, as returned by argpar_item_type().
+*/
+enum argpar_item_type {
+ /// Option
+ ARGPAR_ITEM_TYPE_OPT,
+
+ /// Non-option
+ ARGPAR_ITEM_TYPE_NON_OPT,
+};
+
+/*!
+@struct argpar_item
+
+@brief
+ Opaque parsing item type
+
+argpar_iter_next() sets a pointer to such a type.
+*/
+struct argpar_item;
+
+/*!
+@brief
+ Returns the type of the parsing item \p item.
+
+@param[in] item
+ Parsing item of which to get the type.
+
+@returns
+ Type of \p item.
+
+@pre
+ \p item is not \c NULL.
+*/
+/// @cond hidden_macro
+ARGPAR_HIDDEN
+/// @endcond
+enum argpar_item_type argpar_item_type(const struct argpar_item *item);
+
+/*!
+@brief
+ Returns the option descriptor of the option parsing item \p item.
+
+@param[in] item
+ Option parsing item of which to get the option descriptor.
+
+@returns
+ Option descriptor of \p item.
+
+@pre
+ \p item is not \c NULL.
+@pre
+ \p item has the type #ARGPAR_ITEM_TYPE_OPT.
+*/
+/// @cond hidden_macro
+ARGPAR_HIDDEN
+/// @endcond
+const struct argpar_opt_descr *argpar_item_opt_descr(
+ const struct argpar_item *item);
+
+/*!
+@brief
+ Returns the argument of the option parsing item \p item, or
+ \c NULL if none.
+
+@param[in] item
+ Option parsing item of which to get the argument.
+
+@returns
+ Argument of \p item, or \c NULL if none.
+
+@pre
+ \p item is not \c NULL.
+@pre
+ \p item has the type #ARGPAR_ITEM_TYPE_OPT.
+*/
+/// @cond hidden_macro
+ARGPAR_HIDDEN
+/// @endcond
+const char *argpar_item_opt_arg(const struct argpar_item *item);
+
+/*!
+@brief
+ Returns the complete original argument, pointing to one of the
+ entries of the original arguments (in \p argv, as passed to
+ argpar_iter_create()), of the non-option parsing item \p item.
+
+@param[in] item
+ Non-option parsing item of which to get the complete original
+ argument.
+
+@returns
+ Complete original argument of \p item.
+
+@pre
+ \p item is not \c NULL.
+@pre
+ \p item has the type #ARGPAR_ITEM_TYPE_NON_OPT.
+*/
+/// @cond hidden_macro
+ARGPAR_HIDDEN
+/// @endcond
+const char *argpar_item_non_opt_arg(const struct argpar_item *item);
+
+/*!
+@brief
+ Returns the index, within \em all the original arguments (in
+ \p argv, as passed to argpar_iter_create()), of the non-option
+ parsing item \p item.
+
+For example, with the following command line (all options have no
+argument):
+
+@code{.unparsed}
+-f -m meow --jus mix --kilo
+@endcode
+
+The original argument index of \c meow is 2 while the original
+argument index of \c mix is 4.
+
+@param[in] item
+ Non-option parsing item of which to get the original argument index.
+
+@returns
+ Original argument index of \p item.
+
+@pre
+ \p item is not \c NULL.
+@pre
+ \p item has the type #ARGPAR_ITEM_TYPE_NON_OPT.
+
+@sa
+ argpar_item_non_opt_non_opt_index() -- Returns the non-option index
+ of a non-option parsing item.
+*/
+/// @cond hidden_macro
+ARGPAR_HIDDEN
+/// @endcond
+unsigned int argpar_item_non_opt_orig_index(const struct argpar_item *item);
+
+/*!
+@brief
+ Returns the index, within the parsed non-option parsing items, of
+ the non-option parsing item \p item.
+
+For example, with the following command line (all options have no
+argument):
+
+@code{.unparsed}
+-f -m meow --jus mix --kilo
+@endcode
+
+The non-option index of \c meow is 0 while the original
+argument index of \c mix is 1.
+
+@param[in] item
+ Non-option parsing item of which to get the non-option index.
+
+@returns
+ Non-option index of \p item.
+
+@pre
+ \p item is not \c NULL.
+@pre
+ \p item has the type #ARGPAR_ITEM_TYPE_NON_OPT.
+
+@sa
+ argpar_item_non_opt_orig_index() -- Returns the original argument
+ index of a non-option parsing item.
+*/
+/// @cond hidden_macro
+ARGPAR_HIDDEN
+/// @endcond
+unsigned int argpar_item_non_opt_non_opt_index(const struct argpar_item *item);
+
+/*!
+@brief
+ Destroys the parsing item \p item.
+
+@param[in] item
+ Parsing item to destroy (may be \c NULL).
+*/
+/// @cond hidden_macro
+ARGPAR_HIDDEN
+/// @endcond
+void argpar_item_destroy(const struct argpar_item *item);
+
+/*!
+@def ARGPAR_ITEM_DESTROY_AND_RESET(_item)
+
+@brief
+ Calls argpar_item_destroy() with \p _item, and then sets \p _item
+ to \c NULL.
+
+@param[in] _item
+ Item to destroy and variable to reset
+ (<code>const struct argpar_item *</code> type).
+*/
+#define ARGPAR_ITEM_DESTROY_AND_RESET(_item) \
+ { \
+ argpar_item_destroy(_item); \
+ _item = NULL; \
+ }
+
+/// @}
+
+/*!
+@name Error API
+@{
+*/
+
+/*!
+@struct argpar_error
+
+@brief
+ Opaque parsing error type
+*/
+struct argpar_error;
+
+/*!
+@brief
+ Returns the index of the original argument (in \p argv, as passed to
+ argpar_iter_create()) for which the parsing error described by
+ \p error occurred.
+
+@param[in] error
+ Parsing error of which to get the original argument index.
+
+@returns
+ Original argument index of \p error.
+
+@pre
+ \p error is not \c NULL.
+*/
+/// @cond hidden_macro
+ARGPAR_HIDDEN
+/// @endcond
+unsigned int argpar_error_orig_index(const struct argpar_error *error);
+
+/*!
+@brief
+ Returns the name of the unknown option for which the parsing error
+ described by \p error occurred.
+
+The returned name includes any <code>-</code> or <code>\--</code>
+prefix.
+
+With the long option with argument form, for example
+<code>\--mireille=deyglun</code>, this function only returns the name
+part (<code>\--mireille</code> in the last example).
+
+You may only call this function if the call to argpar_iter_next() which
+set \p error returned #ARGPAR_ITER_NEXT_STATUS_ERROR_UNKNOWN_OPT.
+
+@param[in] error
+ Parsing error of which to get the name of the unknown option.
+
+@returns
+ Name of the unknown option of \p error.
+
+@pre
+ \p error is not \c NULL.
+@pre
+ The call to argpar_iter_next() which set \p error returned
+ #ARGPAR_ITER_NEXT_STATUS_ERROR_UNKNOWN_OPT.
+*/
+/// @cond hidden_macro
+ARGPAR_HIDDEN
+/// @endcond
+const char *argpar_error_unknown_opt_name(const struct argpar_error *error);
+
+/*!
+@brief
+ Returns the descriptor of the option for which the parsing error
+ described by \p error occurred.
+
+You may only call this function if the call to argpar_iter_next() which
+set \p error returned #ARGPAR_ITER_NEXT_STATUS_ERROR_MISSING_OPT_ARG or
+#ARGPAR_ITER_NEXT_STATUS_ERROR_UNEXPECTED_OPG_ARG.
+
+@param[in] error
+ Parsing error of which to get the option descriptor.
+@param[out] is_short
+ @parblock
+ If not \c NULL, this function sets \p *is_short to:
+
+ - \c true if the option for which \p error occurred is a short
+ option.
+
+ - \c false if the option for which \p error occurred is a long
+ option.
+ @endparblock
+
+@returns
+ Descriptor of the option of \p error.
+
+@pre
+ \p error is not \c NULL.
+@pre
+ The call to argpar_iter_next() which set \p error returned
+ #ARGPAR_ITER_NEXT_STATUS_ERROR_MISSING_OPT_ARG or
+ #ARGPAR_ITER_NEXT_STATUS_ERROR_UNEXPECTED_OPG_ARG.
+*/
+/// @cond hidden_macro
+ARGPAR_HIDDEN
+/// @endcond
+const struct argpar_opt_descr *argpar_error_opt_descr(
+ const struct argpar_error *error, bool *is_short);
+
+/*!
+@brief
+ Destroys the parsing error \p error.
+
+@param[in] error
+ Parsing error to destroy (may be \c NULL).
+*/
+/// @cond hidden_macro
+ARGPAR_HIDDEN
+/// @endcond
+void argpar_error_destroy(const struct argpar_error *error);
+
+/// @}
+
+/*!
+@name Iterator API
+@{
+*/
+
+/*!
+@brief
+ Option descriptor
+
+argpar_iter_create() accepts an array of instances of such a type,
+terminated with #ARGPAR_OPT_DESCR_SENTINEL, as its \p descrs parameter.
+
+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
+*/
+struct argpar_opt_descr {
+ /// Numeric ID, to uniquely identify this descriptor