Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

ExecutionEnvironment Class Reference

Encapsulates access to the environment variables and command-line arguments at the time of execution. More...

#include <executionEnvironment.h>

List of all members.

Static Public Member Functions

bool has_environment_variable (const string &var)
 Returns true if the indicated environment variable is defined.

string get_environment_variable (const string &var)
 Returns the definition of the indicated environment variable, or the empty string if the variable is undefined.

void set_environment_variable (const string &var, const string &value)
 Changes the definition of the indicated environment variable.

string expand_string (const string &str)
 Reads the string, looking for environment variable names marked by a $.

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

string get_arg (int n)
 Returns the nth command-line argument.

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

Filename get_cwd ()
 Returns the name of the current working directory.


Private Types

typedef map< string, string > EnvironmentVariables
typedef vector_string CommandArguments

Private Member Functions

 ExecutionEnvironment ()
 You shouldn't need to construct one of these; there's only one and it constructs itself.

bool ns_has_environment_variable (const string &var) const
 Returns true if the indicated environment variable is defined.

string ns_get_environment_variable (const string &var) const
 Returns the definition of the indicated environment variable, or the empty string if the variable is undefined.

void ns_set_environment_variable (const string &var, const string &value)
 Changes the definition of the indicated environment variable.

int ns_get_num_args () const
 Returns the number of command-line arguments available, not counting arg 0, the binary name.

string ns_get_arg (int n) const
 Returns the nth command-line argument.

string ns_get_binary_name () const
 Returns the name of the binary executable that started this program, if it can be determined.

void read_environment_variables ()
 Fills up the internal table of existing environment variables, if we are in PREREAD_ENVIRONMENT mode.

void read_args ()
 Reads all the command-line arguments and the name of the binary file, if possible.


Static Private Member Functions

ExecutionEnvironment * get_ptr ()
 Returns a static pointer that may be used to access the global ExecutionEnvironment object.


Private Attributes

EnvironmentVariables _variables
CommandArguments _args
string _binary_name

Static Private Attributes

ExecutionEnvironment * _global_ptr = NULL


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


Member Typedef Documentation

typedef vector_string ExecutionEnvironment::CommandArguments [private]
 

Definition at line 84 of file executionEnvironment.h.

typedef map<string, string> ExecutionEnvironment::EnvironmentVariables [private]
 

Definition at line 81 of file executionEnvironment.h.


Constructor & Destructor Documentation

ExecutionEnvironment::ExecutionEnvironment  )  [private]
 

You shouldn't need to construct one of these; there's only one and it constructs itself.

Definition at line 71 of file executionEnvironment.cxx.

References size_t.


Member Function Documentation

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

References size_t.

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 100 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 115 of file executionEnvironment.I.

Filename ExecutionEnvironment::get_cwd  )  [static]
 

Returns the name of the current working directory.

Definition at line 152 of file executionEnvironment.cxx.

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 51 of file executionEnvironment.I.

Referenced by Config::ConfigTable::ReadConfigFile().

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 81 of file executionEnvironment.I.

References get_ptr(), INLINE, and ns_get_binary_name().

ExecutionEnvironment * ExecutionEnvironment::get_ptr  )  [static, private]
 

Returns a static pointer that may be used to access the global ExecutionEnvironment object.

Definition at line 316 of file executionEnvironment.cxx.

Referenced by get_num_args(), has_environment_variable(), and set_environment_variable().

bool ExecutionEnvironment::has_environment_variable const string &  var  )  [inline, static]
 

Returns true if the indicated environment variable is defined.

Definition at line 34 of file executionEnvironment.I.

References get_ptr(), INLINE, and ns_get_environment_variable().

Referenced by Config::ConfigTable::Defined(), and Config::ConfigTable::ReadConfigFile().

string ExecutionEnvironment::ns_get_arg int  n  )  const [private]
 

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. The nonstatic implementation.

Definition at line 280 of file executionEnvironment.cxx.

Referenced by set_environment_variable().

string ExecutionEnvironment::ns_get_binary_name  )  const [private]
 

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

The nonstatic implementation.

Definition at line 298 of file executionEnvironment.cxx.

Referenced by get_num_args().

string ExecutionEnvironment::ns_get_environment_variable const string &  var  )  const [private]
 

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

The nonstatic implementation.

Definition at line 208 of file executionEnvironment.cxx.

Referenced by has_environment_variable().

int ExecutionEnvironment::ns_get_num_args  )  const [private]
 

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

The nonstatic implementation.

Definition at line 259 of file executionEnvironment.cxx.

References _global_ptr, and NULL.

Referenced by ns_set_environment_variable().

bool ExecutionEnvironment::ns_has_environment_variable const string &  var  )  const [private]
 

Returns true if the indicated environment variable is defined.

The nonstatic implementation.

Definition at line 187 of file executionEnvironment.cxx.

void ExecutionEnvironment::ns_set_environment_variable const string &  var,
const string &  value
[private]
 

Changes the definition of the indicated environment variable.

The nonstatic implementation.

Definition at line 236 of file executionEnvironment.cxx.

References _args, and ns_get_num_args().

void ExecutionEnvironment::read_args  )  [private]
 

Reads all the command-line arguments and the name of the binary file, if possible.

Definition at line 391 of file executionEnvironment.cxx.

void ExecutionEnvironment::read_environment_variables  )  [private]
 

Fills up the internal table of existing environment variables, if we are in PREREAD_ENVIRONMENT mode.

Otherwise, does nothing.

Definition at line 337 of file executionEnvironment.cxx.

References _args.

void ExecutionEnvironment::set_environment_variable const string &  var,
const string &  value
[inline, static]
 

Changes the definition of the indicated environment variable.

Definition at line 66 of file executionEnvironment.I.

References get_ptr(), INLINE, and ns_get_arg().


Member Data Documentation

CommandArguments ExecutionEnvironment::_args [private]
 

Definition at line 85 of file executionEnvironment.h.

Referenced by ns_set_environment_variable(), and read_environment_variables().

string ExecutionEnvironment::_binary_name [private]
 

Definition at line 87 of file executionEnvironment.h.

ExecutionEnvironment * ExecutionEnvironment::_global_ptr = NULL [static, private]
 

Definition at line 57 of file executionEnvironment.cxx.

Referenced by ns_get_num_args().

EnvironmentVariables ExecutionEnvironment::_variables [private]
 

Definition at line 82 of file executionEnvironment.h.


The documentation for this class was generated from the following files:
Generated on Thu May 1 22:13:32 2003 for DTool by doxygen1.3