*** empty log message ***

This commit is contained in:
David Rose 2001-01-25 23:34:55 +00:00
parent b8aaaf95a8
commit f075f7311d
5 changed files with 76 additions and 2 deletions

View File

@ -35,11 +35,18 @@
#include <orthoProjection.h>
#include <appTraverser.h>
#include <collisionTraverser.h>
#include <get_config_path.h>
ConfigureDef(config_showbase);
ConfigureFn(config_showbase) {
}
DSearchPath &
get_particle_path() {
static DSearchPath *particle_path = NULL;
return get_config_path("particle-path", particle_path);
}
static CollisionTraverser *collision_traverser = NULL;
// Default channel config

View File

@ -16,6 +16,7 @@
#include <pointerTo.h>
#include <nodePath.h>
#include <dconfig.h>
#include <dSearchPath.h>
ConfigureDecl(config_showbase, EXPCL_DIRECT, EXPTP_DIRECT);
typedef Config::Config<ConfigureGetConfig_config_showbase> ConfigShowbase;
@ -25,6 +26,8 @@ class Camera;
BEGIN_PUBLISH
EXPCL_DIRECT DSearchPath &get_particle_path();
EXPCL_DIRECT PT(GraphicsPipe) make_graphics_pipe();
EXPCL_DIRECT PT(GraphicsWindow)
make_graphics_window(GraphicsPipe *pipe,

View File

@ -53,6 +53,66 @@ ExecutionEnvironment() {
read_args();
}
////////////////////////////////////////////////////////////////////
// Function: ExecutionEnviroment::expand_string
// Access: Public, Static
// Description: 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.
////////////////////////////////////////////////////////////////////
string ExecutionEnvironment::
expand_string(const string &str) {
string result;
size_t last = 0;
size_t dollar = str.find('$');
while (dollar != string::npos && dollar + 1 < str.length()) {
size_t start = dollar + 1;
if (str[start] == '$') {
// A double dollar sign maps to a single dollar sign.
result += str.substr(last, start - last);
last = start + 1;
} else {
string varname;
size_t end = start;
if (str[start] == '{') {
// Curly braces delimit the variable name explicitly.
end = str.find('}', start + 1);
if (end != string::npos) {
varname = str.substr(start + 1, end - (start + 1));
end++;
}
}
if (end == start) {
// Scan for the end of the variable name.
while (end < str.length() && (isalnum(str[end]) || str[end] == '_')) {
end++;
}
varname = str.substr(start, end - start);
}
string subst =
result += str.substr(last, dollar - last);
result += get_environment_variable(varname);
last = end;
}
dollar = str.find('$', last);
}
result += str.substr(last);
cerr << "Expanding " << str << " to " << result << "\n";
return result;
}
////////////////////////////////////////////////////////////////////
// Function: ExecutionEnviroment::get_cwd
// Access: Public, Static

View File

@ -29,6 +29,8 @@ public:
INLINE static bool has_environment_variable(const string &var);
INLINE static string get_environment_variable(const string &var);
static string expand_string(const string &str);
INLINE static int get_num_args();
INLINE static string get_arg(int n);

View File

@ -6,6 +6,8 @@
#include "get_config_path.h"
#include "config_express.h"
#include <executionEnvironment.h>
////////////////////////////////////////////////////////////////////
// Function: get_config_path
@ -35,10 +37,10 @@ get_config_path(const string &config_var_name, DSearchPath *&static_ptr) {
if (!all_defs.empty()) {
Config::ConfigTable::Symbol::reverse_iterator si =
all_defs.rbegin();
(*static_ptr).append_path((*si).Val());
(*static_ptr).append_path(ExecutionEnvironment::expand_string((*si).Val()));
++si;
while (si != all_defs.rend()) {
(*static_ptr).append_path((*si).Val());
(*static_ptr).append_path(ExecutionEnvironment::expand_string((*si).Val()));
++si;
}
}