OpenTTD Source 20241224-master-gf74b0cf984
GetOptData Struct Reference

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

#include <getoptdata.h>

Public Types

using OptionSpan = std::span< const OptionData >
 
using ArgumentSpan = std::span< char *const >
 

Public Member Functions

 GetOptData (ArgumentSpan arguments, OptionSpan options)
 Constructor of the data store.
 
int GetOpt ()
 Find the next option.
 
int GetOpt (const OptionData &option)
 

Data Fields

ArgumentSpan arguments
 Remaining command line arguments.
 
const OptionSpan options
 Command line option descriptions.
 
const char * opt = nullptr
 Option value, if available (else nullptr).
 
const char * cont = nullptr
 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 29 of file getoptdata.h.

Member Typedef Documentation

◆ ArgumentSpan

using GetOptData::ArgumentSpan = std::span<char * const>

Definition at line 31 of file getoptdata.h.

◆ OptionSpan

using GetOptData::OptionSpan = std::span<const OptionData>

Definition at line 30 of file getoptdata.h.

Constructor & Destructor Documentation

◆ GetOptData()

GetOptData::GetOptData ( ArgumentSpan  arguments,
OptionSpan  options 
)
inline

Constructor of the data store.

Parameters
argumentThe command line arguments, excluding the program name.
optionsCommand line option descriptions.

Definition at line 43 of file getoptdata.h.

Member Function Documentation

◆ GetOpt() [1/2]

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 arguments, cont, GetOpt(), and options.

Referenced by GetOpt(), main(), and openttd_main().

◆ GetOpt() [2/2]

int GetOptData::GetOpt ( const OptionData option)

Definition at line 55 of file getoptdata.cpp.

Field Documentation

◆ arguments

ArgumentSpan GetOptData::arguments

Remaining command line arguments.

Definition at line 33 of file getoptdata.h.

Referenced by GetOpt(), main(), and openttd_main().

◆ cont

const char* GetOptData::cont = nullptr

Next call to GetOpt should start here (in the middle of an argument).

Definition at line 36 of file getoptdata.h.

Referenced by GetOpt().

◆ opt

const char* GetOptData::opt = nullptr

Option value, if available (else nullptr).

Definition at line 35 of file getoptdata.h.

Referenced by main(), and openttd_main().

◆ options

const OptionSpan GetOptData::options

Command line option descriptions.

Definition at line 34 of file getoptdata.h.

Referenced by GetOpt().


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