Panda3D
|
Encapsulates access to the environment variables and command-line arguments at the time of execution. More...
#include "executionEnvironment.h"
Static Public Member Functions | |
static void | clear_shadow (const string &var) |
Removes a value set by a previous call to shadow_environment_variable(), and lets the actual value of the variable show again. | |
static string | expand_string (const string &str) |
Reads the string, looking for environment variable names marked by a $. | |
static string | get_arg (int n) |
Returns the nth command-line argument. | |
static string | get_binary_name () |
Returns the name of the binary executable that started this program, if it can be determined. | |
static Filename | get_cwd () |
Returns the name of the current working directory. | |
static string | get_dtool_name () |
Returns the name of the libdtool DLL that is used in this program, if it can be determined. | |
static string | get_environment_variable (const string &var) |
Returns the definition of the indicated environment variable, or the empty string if the variable is undefined. | |
static int | get_num_args () |
Returns the number of command-line arguments available, not counting arg 0, the binary name. | |
static bool | has_environment_variable (const string &var) |
Returns true if the indicated environment variable is defined. | |
static void | set_environment_variable (const string &var, const string &value) |
Changes the definition of the indicated environment variable. | |
static void | shadow_environment_variable (const string &var, const string &value) |
Changes the apparent definition of the indicated environment variable by masking it within this class with a new value. |
Encapsulates access to the environment variables and command-line arguments at the time of execution.
This is encapsulated to support accessing these things during static init time, which seems to be risky at best.
Definition at line 33 of file executionEnvironment.h.
void ExecutionEnvironment::clear_shadow | ( | const string & | var | ) | [inline, static] |
Removes a value set by a previous call to shadow_environment_variable(), and lets the actual value of the variable show again.
Definition at line 73 of file executionEnvironment.I.
string ExecutionEnvironment::expand_string | ( | const string & | str | ) | [static] |
Reads the string, looking for environment variable names marked by a $.
Expands all such variable names. A repeated dollar sign ($$) is mapped to a single dollar sign.
Returns the expanded string.
Definition at line 113 of file executionEnvironment.cxx.
References get_environment_variable().
Referenced by VirtualFileSystem::get_global_ptr().
string ExecutionEnvironment::get_arg | ( | int | n | ) | [inline, static] |
Returns the nth command-line argument.
The index n must be in the range [0 .. get_num_args()). The first parameter, n == 0, is the first actual parameter, not the binary name.
Definition at line 97 of file executionEnvironment.I.
string ExecutionEnvironment::get_binary_name | ( | ) | [inline, static] |
Returns the name of the binary executable that started this program, if it can be determined.
Definition at line 108 of file executionEnvironment.I.
Filename ExecutionEnvironment::get_cwd | ( | ) | [static] |
Returns the name of the current working directory.
Definition at line 167 of file executionEnvironment.cxx.
References Filename::from_os_specific().
Referenced by PandaFramework::event_f9(), EggFile::from_command_line(), VirtualFileSystem::get_global_ptr(), FilenameUnifier::make_user_filename(), MayaApi::MayaApi(), and Filename::r_make_canonical().
string ExecutionEnvironment::get_dtool_name | ( | ) | [inline, static] |
Returns the name of the libdtool DLL that is used in this program, if it can be determined.
Definition at line 119 of file executionEnvironment.I.
string ExecutionEnvironment::get_environment_variable | ( | const string & | var | ) | [inline, static] |
Returns the definition of the indicated environment variable, or the empty string if the variable is undefined.
Definition at line 35 of file executionEnvironment.I.
Referenced by expand_string(), and ConfigPageManager::reload_implicit_pages().
int ExecutionEnvironment::get_num_args | ( | ) | [inline, static] |
Returns the number of command-line arguments available, not counting arg 0, the binary name.
Definition at line 84 of file executionEnvironment.I.
bool ExecutionEnvironment::has_environment_variable | ( | const string & | var | ) | [inline, static] |
Returns true if the indicated environment variable is defined.
Definition at line 23 of file executionEnvironment.I.
void ExecutionEnvironment::set_environment_variable | ( | const string & | var, |
const string & | value | ||
) | [inline, static] |
Changes the definition of the indicated environment variable.
Definition at line 46 of file executionEnvironment.I.
void ExecutionEnvironment::shadow_environment_variable | ( | const string & | var, |
const string & | value | ||
) | [inline, static] |
Changes the apparent definition of the indicated environment variable by masking it within this class with a new value.
This does not change the actual environment variable, but future calls to get_environment_variable() will return this new value.
Definition at line 61 of file executionEnvironment.I.