Panda3D
Static Public Member Functions | List of all members
ExecutionEnvironment Class Reference

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. More...
 
static string expand_string (const string &str)
 Reads the string, looking for environment variable names marked by a $. More...
 
static string get_arg (int n)
 Returns the nth command-line argument. More...
 
static string get_binary_name ()
 Returns the name of the binary executable that started this program, if it can be determined. More...
 
static Filename get_cwd ()
 Returns the name of the current working directory. More...
 
static string get_dtool_name ()
 Returns the name of the libdtool DLL that is used in this program, if it can be determined. More...
 
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. More...
 
static int get_num_args ()
 Returns the number of command-line arguments available, not counting arg 0, the binary name. More...
 
static bool has_environment_variable (const string &var)
 Returns true if the indicated environment variable is defined. More...
 
static void set_binary_name (const string &name)
 Do not use. More...
 
static void set_dtool_name (const string &name)
 Do not use. More...
 
static void set_environment_variable (const string &var, const string &value)
 Changes the definition of the indicated environment variable. More...
 
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. More...
 

Detailed Description

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.

Member Function Documentation

◆ clear_shadow()

void ExecutionEnvironment::clear_shadow ( const string &  var)
inlinestatic

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.

References get_num_args().

Referenced by shadow_environment_variable().

◆ expand_string()

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 120 of file executionEnvironment.cxx.

References get_cwd(), and get_environment_variable().

Referenced by DCFile::clear(), Filename::expand_from(), and VirtualFileSystem::get_global_ptr().

◆ get_arg()

string ExecutionEnvironment::get_arg ( int  n)
inlinestatic

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.

References get_binary_name().

Referenced by get_num_args().

◆ get_binary_name()

string ExecutionEnvironment::get_binary_name ( )
inlinestatic

Returns the name of the binary executable that started this program, if it can be determined.

Definition at line 108 of file executionEnvironment.I.

References get_dtool_name().

Referenced by get_arg().

◆ get_cwd()

Filename ExecutionEnvironment::get_cwd ( )
static

◆ get_dtool_name()

string ExecutionEnvironment::get_dtool_name ( )
inlinestatic

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.

References set_binary_name().

Referenced by get_binary_name().

◆ get_environment_variable()

string ExecutionEnvironment::get_environment_variable ( const string &  var)
inlinestatic

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.

References set_environment_variable().

Referenced by expand_string(), has_environment_variable(), and ConfigPageManager::reload_implicit_pages().

◆ get_num_args()

int ExecutionEnvironment::get_num_args ( )
inlinestatic

Returns the number of command-line arguments available, not counting arg 0, the binary name.

Definition at line 84 of file executionEnvironment.I.

References get_arg().

Referenced by clear_shadow().

◆ has_environment_variable()

bool ExecutionEnvironment::has_environment_variable ( const string &  var)
inlinestatic

Returns true if the indicated environment variable is defined.

Definition at line 23 of file executionEnvironment.I.

References get_environment_variable().

◆ set_binary_name()

void ExecutionEnvironment::set_binary_name ( const string &  name)
inlinestatic

Do not use.

Definition at line 129 of file executionEnvironment.I.

References set_dtool_name().

Referenced by get_dtool_name().

◆ set_dtool_name()

void ExecutionEnvironment::set_dtool_name ( const string &  name)
inlinestatic

Do not use.

Definition at line 139 of file executionEnvironment.I.

Referenced by set_binary_name().

◆ set_environment_variable()

void ExecutionEnvironment::set_environment_variable ( const string &  var,
const string &  value 
)
inlinestatic

Changes the definition of the indicated environment variable.

Definition at line 46 of file executionEnvironment.I.

References shadow_environment_variable().

Referenced by get_environment_variable().

◆ shadow_environment_variable()

void ExecutionEnvironment::shadow_environment_variable ( const string &  var,
const string &  value 
)
inlinestatic

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.

References clear_shadow().

Referenced by set_environment_variable().


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