OpenTTD Source: src/misc/getoptdata.h File Reference

OpenTTD Source 1.11.0-RC1

Data Structures | Macros | Enumerations
getoptdata.h File Reference

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. More...
#define | GETOPT_NOVAL(shortname, longname) GETOPT_GENERAL(shortname, shortname, longname, ODF_NO_VALUE)
| Short option without value. More...
#define | GETOPT_VALUE(shortname, longname) GETOPT_GENERAL(shortname, shortname, longname, ODF_HAS_VALUE)
| Short option with value. More...
#define | GETOPT_OPTVAL(shortname, longname) GETOPT_GENERAL(shortname, shortname, longname, ODF_OPTIONAL_VALUE)
| Short option with optional value. More...
#define | GETOPT_SHORT_NOVAL(shortname) GETOPT_NOVAL(shortname, nullptr)
| Short option without value. More...
#define | GETOPT_SHORT_VALUE(shortname) GETOPT_VALUE(shortname, nullptr)
| Short option with value. More...
#define | GETOPT_SHORT_OPTVAL(shortname) GETOPT_OPTVAL(shortname, nullptr)
| Short option with optional value. More...
#define | GETOPT_END() { '\0', '\0', ODF_END, nullptr}
| 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

## ◆ GETOPT_GENERAL

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

General macro for creating an option.

Parameters

  id | Identification of the option.
  shortname | Short option name. Use `'\0'` if not used.
  longname | Long option name including leading '-' or '–'. Use `nullptr` if not used.
  flags | Flags of the option.

Definition at line 62 of file getoptdata.h.

## ◆ GETOPT_NOVAL

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

Short option without value.

Parameters

  shortname | Short option name. Use `'\0'` if not used.
  longname | Long option name including leading '-' or '–'. Use `nullptr` if not used.

Definition at line 69 of file getoptdata.h.

## ◆ GETOPT_OPTVAL

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

Short option with optional value.

Parameters

  shortname | Short option name. Use `'\0'` if not used.
  longname | Long option name including leading '-' or '–'. Use `nullptr` if not used.

Note
  Options with optional values are hopelessly ambiguous, eg "-opt -value", avoid them.

Definition at line 84 of file getoptdata.h.

## ◆ GETOPT_SHORT_NOVAL

#define GETOPT_SHORT_NOVAL | ( |  | shortname | ) | GETOPT_NOVAL(shortname, nullptr)

Short option without value.

Parameters

  shortname | Short option name. Use `'\0'` if not used.

Definition at line 91 of file getoptdata.h.

## ◆ GETOPT_SHORT_OPTVAL

#define GETOPT_SHORT_OPTVAL | ( |  | shortname | ) | GETOPT_OPTVAL(shortname, nullptr)

Short option with optional value.

Parameters

  shortname | Short option name. Use `'\0'` if not used.

Note
  Options with optional values are hopelessly ambiguous, eg "-opt -value", avoid them.

Definition at line 104 of file getoptdata.h.

## ◆ GETOPT_SHORT_VALUE

#define GETOPT_SHORT_VALUE | ( |  | shortname | ) | GETOPT_VALUE(shortname, nullptr)

Short option with value.

Parameters

  shortname | Short option name. Use `'\0'` if not used.

Definition at line 97 of file getoptdata.h.

## ◆ GETOPT_VALUE

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

Short option with value.

Parameters

  shortname | Short option name. Use `'\0'` if not used.
  longname | Long option name including leading '-' or '–'. Use `nullptr` if not used.

Definition at line 76 of file getoptdata.h.

## Enumeration Type Documentation

## ◆ OptionDataFlags

enum OptionDataFlags

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 14 of file getoptdata.h.