+ std::string var = variableName;
+ return getValue(var, exceptionIfMissing);
+}
+
+std::string Environment::getValue(const std::string &variableName, bool exceptionIfMissing) throw(RuntimeException) {
+ std::string result = "";
+ std::map<std::string, std::string>::const_iterator it = a_vars.find(variableName);
+
+ if(it == a_vars.end()) {
+ char *current = getenv(variableName.c_str());
+
+ if(!current) {
+ std::string msg = "The variable '";
+ msg += variableName;
+ msg += "' is not defined in the environment.";
+ LOGDEBUG(Logger::debug(msg, ANNA_FILE_LOCATION));
+
+ if(exceptionIfMissing) throw RuntimeException(msg, ANNA_FILE_LOCATION);
+ } else {
+ // assignment
+ a_vars[variableName] = current;
+ result = current;
+ }
+ } else {
+ result = it->second;
+ }
+
+ return result;
+}