OpenTTD Source: GetOptData Struct Reference

OpenTTD Source 14.0-RC3

Public Member Functions | Data Fields
GetOptData Struct Reference

Data storage for parsing command line options. More...

`#include <getoptdata.h>`

## Public Member Functions
| GetOptData (int argc, char **argv, const OptionData *options)
| Constructor of the data store. More...
int | GetOpt ()
| Find the next option. More...

## Data Fields
char * | opt
| Option value, if available (else `nullptr`).
int | numleft
| Number of arguments left in argv.
char ** | argv
| Remaining command line arguments.
const OptionData * | options
| Command line option descriptions.
char * | cont
| Next call to GetOpt should start here (in the middle of an argument).

## Detailed Description

Data storage for parsing command line options.

Definition at line 30 of file getoptdata.h.

## Constructor & Destructor Documentation

## ◆ GetOptData()

GetOptData::GetOptData | ( | int | argc,
|  | char ** | argv,
|  | const OptionData * | options
| ) |  |
| inline

Constructor of the data store.

Parameters

  argc | Number of command line arguments, excluding the program name.
  argv | Command line arguments, excluding the program name.
  options | Command line option descriptions.

Definition at line 43 of file getoptdata.h.

## Member Function Documentation

## ◆ GetOpt()

int GetOptData::GetOpt | ( |  | ) |

Find the next option.

Returns
  Function returns one
  - An option letter if it found another option.
  - -1 if option processing is finished. Inspect argv and numleft to find the command line arguments.
  - -2 if an error was encountered.

Definition at line 22 of file getoptdata.cpp.

References argv, cont, OptionData::flags, OptionData::id, OptionData::longname, numleft, ODF_END, ODF_HAS_VALUE, ODF_NO_VALUE, ODF_OPTIONAL_VALUE, opt, options, and OptionData::shortname.

Referenced by main().

The documentation for this struct was generated from the following files:

- src/misc/getoptdata.h
- src/misc/getoptdata.cpp