OpenTTD
Data Structures | Macros | Enumerations
getoptdata.h File Reference

Library for parsing command-line options. More...

Go to the source code of this file.

Data Structures

struct  OptionData
 Data of an option. More...
struct  GetOptData
 Data storage for parsing command line options. More...

Macros

#define GETOPT_GENERAL(id, shortname, longname, flags)   { id, shortname, flags, longname }
 General macro for creating an option.
#define GETOPT_NOVAL(shortname, longname)   GETOPT_GENERAL(shortname, shortname, longname, ODF_NO_VALUE)
 Short option without value.
#define GETOPT_VALUE(shortname, longname)   GETOPT_GENERAL(shortname, shortname, longname, ODF_HAS_VALUE)
 Short option with value.
#define GETOPT_OPTVAL(shortname, longname)   GETOPT_GENERAL(shortname, shortname, longname, ODF_OPTIONAL_VALUE)
 Short option with optional value.
#define GETOPT_SHORT_NOVAL(shortname)   GETOPT_NOVAL(shortname, NULL)
 Short option without value.
#define GETOPT_SHORT_VALUE(shortname)   GETOPT_VALUE(shortname, NULL)
 Short option with value.
#define GETOPT_SHORT_OPTVAL(shortname)   GETOPT_OPTVAL(shortname, NULL)
 Short option with optional value.
#define GETOPT_END()   { '\0', '\0', ODF_END, NULL}
 Option terminator.

Enumerations

enum  OptionDataFlags { ODF_NO_VALUE, ODF_HAS_VALUE, ODF_OPTIONAL_VALUE, ODF_END }
 Flags of an option. More...

Detailed Description

Library for parsing command-line options.

Definition in file getoptdata.h.

Macro Definition Documentation

#define GETOPT_END ( )    { '\0', '\0', ODF_END, NULL}

Option terminator.

Definition at line 109 of file getoptdata.h.

#define GETOPT_GENERAL (   id,
  shortname,
  longname,
  flags 
)    { id, shortname, flags, longname }

General macro for creating an option.

Parameters
idIdentification of the option.
shortnameShort option name. Use '\0' if not used.
longnameLong option name including leading '-' or '–'. Use NULL if not used.
flagsFlags of the option.

Definition at line 64 of file getoptdata.h.

#define GETOPT_NOVAL (   shortname,
  longname 
)    GETOPT_GENERAL(shortname, shortname, longname, ODF_NO_VALUE)

Short option without value.

Parameters
shortnameShort option name. Use '\0' if not used.
longnameLong option name including leading '-' or '–'. Use NULL if not used.

Definition at line 71 of file getoptdata.h.

#define GETOPT_OPTVAL (   shortname,
  longname 
)    GETOPT_GENERAL(shortname, shortname, longname, ODF_OPTIONAL_VALUE)

Short option with optional value.

Parameters
shortnameShort option name. Use '\0' if not used.
longnameLong option name including leading '-' or '–'. Use NULL if not used.
Note
Options with optional values are hopelessly ambiguous, eg "-opt -value", avoid them.

Definition at line 86 of file getoptdata.h.

#define GETOPT_SHORT_NOVAL (   shortname)    GETOPT_NOVAL(shortname, NULL)

Short option without value.

Parameters
shortnameShort option name. Use '\0' if not used.

Definition at line 93 of file getoptdata.h.

#define GETOPT_SHORT_OPTVAL (   shortname)    GETOPT_OPTVAL(shortname, NULL)

Short option with optional value.

Parameters
shortnameShort option name. Use '\0' if not used.
Note
Options with optional values are hopelessly ambiguous, eg "-opt -value", avoid them.

Definition at line 106 of file getoptdata.h.

#define GETOPT_SHORT_VALUE (   shortname)    GETOPT_VALUE(shortname, NULL)

Short option with value.

Parameters
shortnameShort option name. Use '\0' if not used.

Definition at line 99 of file getoptdata.h.

#define GETOPT_VALUE (   shortname,
  longname 
)    GETOPT_GENERAL(shortname, shortname, longname, ODF_HAS_VALUE)

Short option with value.

Parameters
shortnameShort option name. Use '\0' if not used.
longnameLong option name including leading '-' or '–'. Use NULL if not used.

Definition at line 78 of file getoptdata.h.

Enumeration Type Documentation

Flags of an option.

Enumerator:
ODF_NO_VALUE 

A plain option (no value attached to it).

ODF_HAS_VALUE 

An option with a value.

ODF_OPTIONAL_VALUE 

An option with an optional value.

ODF_END 

Terminator (data is not parsed further).

Definition at line 16 of file getoptdata.h.