Panda3D
Static Public Member Functions | Public Attributes | 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 std::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 std::string expand_string (const std::string &str)
 Reads the string, looking for environment variable names marked by a $. More...
 
static std::string get_arg (size_t n)
 
static std::string get_binary_name ()
 
static Filename get_cwd ()
 
static std::string get_dtool_name ()
 
static std::string get_environment_variable (const std::string &var)
 
static size_t get_num_args ()
 
static bool has_environment_variable (const std::string &var)
 
static void set_binary_name (const std::string &name)
 
static void set_dtool_name (const std::string &name)
 
static void set_environment_variable (const std::string &var, const std::string &value)
 
static void shadow_environment_variable (const std::string &var, const std::string &value)
 Changes the apparent definition of the indicated environment variable by masking it within this class with a new value. More...
 

Public Attributes

 get_arg
 Returns the nth command-line argument. More...
 
 get_binary_name
 Returns the name of the binary executable that started this program, if it can be determined. More...
 
 get_cwd
 Returns the name of the current working directory. More...
 
 get_dtool_name
 Returns the name of the libdtool DLL that is used in this program, if it can be determined. More...
 
 get_environment_variable
 Returns the definition of the indicated environment variable, or the empty string if the variable is undefined. More...
 
 get_num_args
 Returns the number of command-line arguments available, not counting arg 0, the binary name. More...
 
 has_environment_variable
 Returns true if the indicated environment variable is defined. More...
 
 set_binary_name
 Do not use. More...
 
 set_dtool_name
 Do not use. More...
 
 set_environment_variable
 Changes the definition of the indicated environment variable. 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 29 of file executionEnvironment.h.

Member Function Documentation

◆ clear_shadow()

void ExecutionEnvironment::clear_shadow ( const std::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 55 of file executionEnvironment.I.

Referenced by ConfigDeclaration::get_filename_value().

◆ expand_string()

string ExecutionEnvironment::expand_string ( const std::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 112 of file executionEnvironment.cxx.

References get_environment_variable.

Referenced by Filename::expand_from(), and ConfigDeclaration::get_filename_value().

◆ shadow_environment_variable()

void ExecutionEnvironment::shadow_environment_variable ( const std::string &  var,
const std::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 46 of file executionEnvironment.I.

Referenced by ConfigDeclaration::get_filename_value().

Member Data Documentation

◆ get_arg

std::string ExecutionEnvironment::get_arg
inline

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 58 of file executionEnvironment.h.

◆ get_binary_name

std::string ExecutionEnvironment::get_binary_name
inline

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

Definition at line 59 of file executionEnvironment.h.

◆ get_cwd

Filename ExecutionEnvironment::get_cwd

Returns the name of the current working directory.

Definition at line 61 of file executionEnvironment.h.

◆ get_dtool_name

std::string ExecutionEnvironment::get_dtool_name
inline

Returns the name of the libdtool DLL that is used in this program, if it can be determined.

Definition at line 60 of file executionEnvironment.h.

◆ get_environment_variable

std::string ExecutionEnvironment::get_environment_variable
inline

Returns the definition of the indicated environment variable, or the empty string if the variable is undefined.

Definition at line 56 of file executionEnvironment.h.

Referenced by expand_string().

◆ get_num_args

size_t ExecutionEnvironment::get_num_args
inline

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

Definition at line 58 of file executionEnvironment.h.

◆ has_environment_variable

bool ExecutionEnvironment::has_environment_variable
inline

Returns true if the indicated environment variable is defined.

Definition at line 56 of file executionEnvironment.h.

◆ set_binary_name

void ExecutionEnvironment::set_binary_name
inline

Do not use.

Definition at line 59 of file executionEnvironment.h.

◆ set_dtool_name

void ExecutionEnvironment::set_dtool_name
inline

Do not use.

Definition at line 60 of file executionEnvironment.h.

◆ set_environment_variable

void ExecutionEnvironment::set_environment_variable
inline

Changes the definition of the indicated environment variable.

Definition at line 56 of file executionEnvironment.h.


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