void Vars::append(Variable *arg) { Variable *t = findVarByName(arg->name); if(t){ qDebug()<<"try override variable "<<arg->name<<endl; EXCEPTION(true,Vars::append); } QList<Variable *>::append(arg); }
UserConfigVar* UserConfig::createVar(const std::string& name, const std::string& defaultValue) { if (findVarByName(name)) return NULL; UserConfigVar *var = new UserConfigVar; var->Name = name; var->DefaultValue = var->Value = defaultValue; mVars.push_back(var); return var; }
std::string UserConfig::getValue(const std::string& name) { UserConfigVar *var = findVarByName(name); if (!var) { std::cerr << "Warning: impossible to get value of " << "unknown configuration variable " << name << std::endl; return ""; } return var->Value; }
void UserConfig::setValue(const std::string& name, const std::string& value) { UserConfigVar *var = findVarByName(name); if (!var) { std::cerr << "Warning: impossible to set value of " << "unknown configuration variable " << name << "\n Creating new variable" << std::endl; var = createVar(name, value); mChangeFlag = true; return; } if (var->Value != value) mChangeFlag = true; var->Value = value; }
Decl_AST* findVarById(Env* p, IdExpr_AST* Id) { std::string name_Str(Id->Addr()); return findVarByName(p, name_Str); }