FlightGear next
|
#include <options.hxx>
Classes | |
class | OptionsPrivate |
Public Member Functions | |
~Options () | |
OptionResult | init (int argc, char *argv[], const SGPath &appDataPath) |
pass command line arguments, read default config files | |
void | readConfig (const SGPath &path) |
parse a config file (eg, .fgfsrc) | |
std::string | valueForOption (const std::string &key, const std::string &defValue=std::string()) const |
read the value for an option, if it has been set | |
string_list | valuesForOption (const std::string &key) const |
return all values for a multi-valued option | |
bool | isOptionSet (const std::string &key) const |
Check if a particular option has been set (so far). | |
std::optional< bool > | checkBoolOptionSet (const std::string &key) const |
Check if the user has specified a given boolean option. | |
bool | isBoolOptionEnable (const std::string &key) const |
An overlay on checkBoolOptionSet, except that when the user has not used the option at all then false is returned. | |
bool | isBoolOptionDisable (const std::string &key) const |
An overlay on checkBoolOptionSet, to check whether user used the option with explicitly disable it. | |
int | addOption (const std::string &key, const std::string &value) |
set an option value, assuming it is not already set (or multiple values are permitted) This can be used to inject option values, eg based upon environment variables | |
int | setOption (const std::string &key, const std::string &value) |
set an option, overwriting any existing value which might be set | |
void | clearOption (const std::string &key) |
OptionResult | processOptions () |
apply option values to the simulation state (set properties, etc). | |
void | initPaths () |
process command line options relating to scenery / aircraft / data paths | |
OptionResult | initAircraft () |
init the aircraft options | |
bool | shouldLoadDefaultConfig () const |
should defualt configuration files be loaded and processed or not? | |
void | setShouldLoadDefaultConfig (bool load) |
when using the built-in launcher, we disable the default config files. | |
SGPath | platformDefaultRoot () const |
string_list | extractOptions () const |
extractOptions - extract the currently set options as a string array. | |
SGPath | actualDownloadDir () |
the actual download dir in use, which may be the default or a user-supplied value | |
Static Public Member Functions | |
static Options * | sharedInstance () |
static void | reset () |
Delete the entire options object. | |
static bool | checkForArg (int argc, char *argv[], const char *arg) |
Check if the arguments array contains a particular string (with a '–' or '-' prefix). | |
static std::optional< bool > | checkForBoolArg (int argc, char *argv[], const std::string &checkArg) |
Check if the user has specified a given boolean option. | |
static bool | checkForArgEnable (int argc, char *argv[], const std::string &checkArg) |
Return true when user explicitly enabled boolean option, otherwise false. | |
static bool | checkForArgDisable (int argc, char *argv[], const std::string &checkArg) |
Return true when user explicitly disabled boolean option by set false value. | |
static std::string | getArgValue (int argc, char *argv[], const char *checkArg) |
getArgValue - get the value of an argument if it exists, or an empty string otherwise | |
static bool | paramToBool (const std::string ¶m) |
Convert string to bool for boolean options. | |
Definition at line 64 of file options.hxx.
flightgear::Options::~Options | ( | ) |
Definition at line 2377 of file options.cxx.
SGPath flightgear::Options::actualDownloadDir | ( | ) |
the actual download dir in use, which may be the default or a user-supplied value
Definition at line 3010 of file options.cxx.
int flightgear::Options::addOption | ( | const std::string & | key, |
const std::string & | value ) |
set an option value, assuming it is not already set (or multiple values are permitted) This can be used to inject option values, eg based upon environment variables
Definition at line 2859 of file options.cxx.
std::optional< bool > flightgear::Options::checkBoolOptionSet | ( | const std::string & | key | ) | const |
Check if the user has specified a given boolean option.
We need to return 3 states:
User provided options => Using the method => Result –enable-fullscreen => checkBoolOptionSet("fullscreen") => true –disable-fullscreen => checkBoolOptionSet("fullscreen") => false –fullscreen => checkBoolOptionSet("fullscreen") => true –fullscreen true => checkBoolOptionSet("fullscreen") => true –fullscreen false => checkBoolOptionSet("fullscreen") => false –fullscreen 1 => checkBoolOptionSet("fullscreen") => true –fullscreen 0 => checkBoolOptionSet("fullscreen") => false –fullscreen yes => checkBoolOptionSet("fullscreen") => true –fullscreen no => checkBoolOptionSet("fullscreen") => false {none of the above} => checkBoolOptionSet("fullscreen") => no value
Definition at line 2961 of file options.cxx.
|
static |
Check if the arguments array contains a particular string (with a '–' or '-' prefix).
Used by early startup code before Options object is created. For boolean option please use checkForBoolArg or checkForArgEnable/checkForArgDisable.
Definition at line 3603 of file options.cxx.
|
static |
Return true when user explicitly disabled boolean option by set false value.
Used by early startup code before Options object is created.
Definition at line 3687 of file options.cxx.
|
static |
Return true when user explicitly enabled boolean option, otherwise false.
Used by early startup code before Options object is created.
Definition at line 3681 of file options.cxx.
|
static |
Check if the user has specified a given boolean option.
Used by early startup code before Options object is created. We need to return 3 states:
User provided options => Using the method => Result –enable-fullscreen => checkForBoolArg(argc, argv, "fullscreen") => true –disable-fullscreen => checkForBoolArg(argc, argv, "fullscreen") => false –fullscreen => checkForBoolArg(argc, argv, "fullscreen") => true –fullscreen true => checkForBoolArg(argc, argv, "fullscreen") => true –fullscreen false => checkForBoolArg(argc, argv, "fullscreen") => false –fullscreen 1 => checkForBoolArg(argc, argv, "fullscreen") => true –fullscreen 0 => checkForBoolArg(argc, argv, "fullscreen") => false –fullscreen yes => checkForBoolArg(argc, argv, "fullscreen") => true –fullscreen no => checkForBoolArg(argc, argv, "fullscreen") => false {none of the above} => checkForBoolArg(argc, argv, "fullscreen") => no value
Definition at line 3628 of file options.cxx.
void flightgear::Options::clearOption | ( | const std::string & | key | ) |
Definition at line 2916 of file options.cxx.
string_list flightgear::Options::extractOptions | ( | ) | const |
extractOptions - extract the currently set options as a string array.
This can be used to examine what options were requested / set so far.
Definition at line 3490 of file options.cxx.
|
static |
getArgValue - get the value of an argument if it exists, or an empty string otherwise
argc | |
argv | |
checkArg | : arg to look for, with '–' prefix |
Definition at line 3693 of file options.cxx.
OptionResult flightgear::Options::init | ( | int | argc, |
char * | argv[], | ||
const SGPath & | appDataPath ) |
pass command line arguments, read default config files
Definition at line 2381 of file options.cxx.
OptionResult flightgear::Options::initAircraft | ( | ) |
init the aircraft options
Definition at line 2583 of file options.cxx.
void flightgear::Options::initPaths | ( | ) |
process command line options relating to scenery / aircraft / data paths
Definition at line 2569 of file options.cxx.
bool flightgear::Options::isBoolOptionDisable | ( | const std::string & | key | ) | const |
An overlay on checkBoolOptionSet, to check whether user used the option with explicitly disable it.
For non-boolean option please use isOptionSet.
Definition at line 2995 of file options.cxx.
bool flightgear::Options::isBoolOptionEnable | ( | const std::string & | key | ) | const |
An overlay on checkBoolOptionSet, except that when the user has not used the option at all then false is returned.
For non-boolean option please use isOptionSet.
Definition at line 2989 of file options.cxx.
bool flightgear::Options::isOptionSet | ( | const std::string & | key | ) | const |
Check if a particular option has been set (so far).
For boolean option please use isBoolOptionEnable or isBoolOptionDisable.
Definition at line 2924 of file options.cxx.
|
static |
Convert string to bool for boolean options.
When param cannot be recognized as bool then the true is returned.
Definition at line 2738 of file options.cxx.
SGPath flightgear::Options::platformDefaultRoot | ( | ) | const |
Definition at line 3483 of file options.cxx.
OptionResult flightgear::Options::processOptions | ( | ) |
apply option values to the simulation state (set properties, etc).
Definition at line 3025 of file options.cxx.
void flightgear::Options::readConfig | ( | const SGPath & | path | ) |
parse a config file (eg, .fgfsrc)
Definition at line 2691 of file options.cxx.
|
static |
Delete the entire options object.
Use with a degree of care, no code should ever be caching the Options pointer but this has not actually been checked across the whole code :)
Definition at line 2354 of file options.cxx.
int flightgear::Options::setOption | ( | const std::string & | key, |
const std::string & | value ) |
set an option, overwriting any existing value which might be set
Definition at line 2896 of file options.cxx.
void flightgear::Options::setShouldLoadDefaultConfig | ( | bool | load | ) |
when using the built-in launcher, we disable the default config files.
explicitly loaded confg files are still permitted.
Definition at line 3598 of file options.cxx.
|
static |
Definition at line 2345 of file options.cxx.
bool flightgear::Options::shouldLoadDefaultConfig | ( | ) | const |
should defualt configuration files be loaded and processed or not?
There's many configuration files we have historically read by default on startup - fgfs.rc in various places and so on. –no-default-config allows this behaviour to be changed, so only expicitly listed files are read Expose the value of the option here.
Definition at line 3593 of file options.cxx.
string flightgear::Options::valueForOption | ( | const std::string & | key, |
const std::string & | defValue = std::string() ) const |
read the value for an option, if it has been set
Definition at line 2934 of file options.cxx.
string_list flightgear::Options::valuesForOption | ( | const std::string & | key | ) | const |
return all values for a multi-valued option
Definition at line 2944 of file options.cxx.