VirtualBox

Changeset 96729 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Sep 14, 2022 9:14:53 AM (2 years ago)
Author:
vboxsync
Message:

IPRT/getopt: Added index variant with 0 or 1 and optionally and w/ implicit dash. Thought I needed for converting some options to use indexes, but here it is anyways.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/getopt.h

    r96407 r96729  
    130130/** The index value is attached to the argument - only valid for long arguments. */
    131131#define RTGETOPT_FLAG_INDEX                     RT_BIT(19)
     132/** Used with RTGETOPT_FLAG_INDEX, setting index to zero if none given.
     133 * (The default is to fail with VERR_GETOPT_INDEX_MISSING.)  */
     134#define RTGETOPT_FLAG_INDEX_DEF_0               RT_BIT(20)
     135/** Used with RTGETOPT_FLAG_INDEX, setting index to one if none given.
     136 * (The default is to fail with VERR_GETOPT_INDEX_MISSING.)  */
     137#define RTGETOPT_FLAG_INDEX_DEF_1               RT_BIT(21)
     138/** For simplicity. */
     139#define RTGETOPT_FLAG_INDEX_DEF_MASK            (RT_BIT(20) | RT_BIT(21))
     140/** For simple conversion. */
     141#define RTGETOPT_FLAG_INDEX_DEF_SHIFT           20
     142/** For use with RTGETOPT_FLAG_INDEX_DEF_0 or RTGETOPT_FLAG_INDEX_DEF_1 to
     143 *  imply a dash before the index when a digit is specified.
     144 * This is for transitioning from options without index to optionally allow
     145 * index options, i.e. "--long" defaults to either index 1 or 1 using the above
     146 * flags, while "--long-1" explicitly gives the index ("--long-" is not valid).
     147 * This flag matches an "-" separating the "--long" string
     148 * (RTGETOPTDEFS::pszLong) from the index value.  */
     149#define RTGETOPT_FLAG_INDEX_DEF_DASH            RT_BIT(22)
    132150/** Treat the long option as case insensitive. */
    133 #define RTGETOPT_FLAG_ICASE                     RT_BIT(20)
     151#define RTGETOPT_FLAG_ICASE                     RT_BIT(23)
    134152/** Mask of valid bits - for validation. */
    135153#define RTGETOPT_VALID_MASK                     (  RTGETOPT_REQ_MASK \
     
    138156                                                 | RTGETOPT_FLAG_DEC \
    139157                                                 | RTGETOPT_FLAG_INDEX \
    140                                                  | RTGETOPT_FLAG_ICASE)
     158                                                 | RTGETOPT_FLAG_INDEX_DEF_0 \
     159                                                 | RTGETOPT_FLAG_INDEX_DEF_1 \
     160                                                 | RTGETOPT_FLAG_INDEX_DEF_DASH \
     161                                                 | RTGETOPT_FLAG_ICASE )
    141162/** @} */
    142163
     
    165186 *
    166187 * What ends up here depends on argument format in the option definition.
    167  *
    168  * @remarks Integers will bet put in the \a i and \a u members and sign/zero extended
    169  *          according to the signedness indicated by the \a fFlags. So, you can choose
    170  *          use which ever of the integer members for accessing the value regardless
    171  *          of restrictions indicated in the \a fFlags.
    172188 */
    173189typedef union RTGETOPTUNION
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette