Added functions used to set/add a list of parameters in configuration and section.
git-svn-id: http://yate.null.ro/svn/yate/trunk@6532 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
2bcacf9525
commit
0e019e9d35
|
@ -752,6 +752,8 @@ public:
|
||||||
params().addParam(new ExpFunction("getBoolValue"));
|
params().addParam(new ExpFunction("getBoolValue"));
|
||||||
params().addParam(new ExpFunction("setValue"));
|
params().addParam(new ExpFunction("setValue"));
|
||||||
params().addParam(new ExpFunction("addValue"));
|
params().addParam(new ExpFunction("addValue"));
|
||||||
|
params().addParam(new ExpFunction("setValues"));
|
||||||
|
params().addParam(new ExpFunction("addValues"));
|
||||||
params().addParam(new ExpFunction("clearSection"));
|
params().addParam(new ExpFunction("clearSection"));
|
||||||
params().addParam(new ExpFunction("clearKey"));
|
params().addParam(new ExpFunction("clearKey"));
|
||||||
params().addParam(new ExpFunction("keys"));
|
params().addParam(new ExpFunction("keys"));
|
||||||
|
@ -791,6 +793,8 @@ protected:
|
||||||
params().addParam(new ExpFunction("getBoolValue"));
|
params().addParam(new ExpFunction("getBoolValue"));
|
||||||
params().addParam(new ExpFunction("setValue"));
|
params().addParam(new ExpFunction("setValue"));
|
||||||
params().addParam(new ExpFunction("addValue"));
|
params().addParam(new ExpFunction("addValue"));
|
||||||
|
params().addParam(new ExpFunction("setValues"));
|
||||||
|
params().addParam(new ExpFunction("addValues"));
|
||||||
params().addParam(new ExpFunction("clearKey"));
|
params().addParam(new ExpFunction("clearKey"));
|
||||||
params().addParam(new ExpFunction("keys"));
|
params().addParam(new ExpFunction("keys"));
|
||||||
}
|
}
|
||||||
|
@ -3689,6 +3693,33 @@ void* JsConfigFile::getObject(const String& name) const
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handleCfgSetValues(bool set, Configuration& cfg, const String& sName,
|
||||||
|
GenObject* params, const String* prefix)
|
||||||
|
{
|
||||||
|
const NamedList* pList = sName ? getReplaceParams(params) : 0;
|
||||||
|
if (!pList)
|
||||||
|
return;
|
||||||
|
NamedList* sect = cfg.createSection(sName);
|
||||||
|
if (TelEngine::null(prefix))
|
||||||
|
prefix = 0;
|
||||||
|
for (ObjList* o = pList->paramList()->skipNull(); o; o = o->skipNext()) {
|
||||||
|
NamedString* ns = static_cast<NamedString*>(o->get());
|
||||||
|
JsObject* jso = YOBJECT(JsObject,ns);
|
||||||
|
if (jso || ns->name() == JsObject::protoName())
|
||||||
|
continue;
|
||||||
|
if (set) {
|
||||||
|
if (prefix)
|
||||||
|
sect->setParam(*prefix + ns->name(),*ns);
|
||||||
|
else
|
||||||
|
sect->setParam(ns->name(),*ns);
|
||||||
|
}
|
||||||
|
else if (prefix)
|
||||||
|
sect->addParam(*prefix + ns->name(),*ns);
|
||||||
|
else
|
||||||
|
sect->addParam(ns->name(),*ns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool JsConfigFile::runNative(ObjList& stack, const ExpOperation& oper, GenObject* context)
|
bool JsConfigFile::runNative(ObjList& stack, const ExpOperation& oper, GenObject* context)
|
||||||
{
|
{
|
||||||
XDebug(&__plugin,DebugAll,"JsConfigFile::runNative '%s'(" FMT64 ")",oper.name().c_str(),oper.number());
|
XDebug(&__plugin,DebugAll,"JsConfigFile::runNative '%s'(" FMT64 ")",oper.name().c_str(),oper.number());
|
||||||
|
@ -3829,6 +3860,16 @@ bool JsConfigFile::runNative(ObjList& stack, const ExpOperation& oper, GenObject
|
||||||
m_config.addValue(*static_cast<ExpOperation*>(args[0]),*static_cast<ExpOperation*>(args[1]),
|
m_config.addValue(*static_cast<ExpOperation*>(args[0]),*static_cast<ExpOperation*>(args[1]),
|
||||||
*static_cast<ExpOperation*>(args[2]));
|
*static_cast<ExpOperation*>(args[2]));
|
||||||
}
|
}
|
||||||
|
else if (oper.name() == YSTRING("setValues") || oper.name() == YSTRING("addValues")) {
|
||||||
|
// setValues(sect,params[,prefix])
|
||||||
|
// addValues(sect,params[,prefix])
|
||||||
|
ExpOperation* sName = 0;
|
||||||
|
ExpOperation* params = 0;
|
||||||
|
ExpOperation* prefix = 0;
|
||||||
|
if (!extractStackArgs(2,this,stack,oper,context,args,&sName,¶ms,&prefix))
|
||||||
|
return false;
|
||||||
|
handleCfgSetValues(oper.name() == YSTRING("setValues"),m_config,*sName,params,prefix);
|
||||||
|
}
|
||||||
else if (oper.name() == YSTRING("clearSection")) {
|
else if (oper.name() == YSTRING("clearSection")) {
|
||||||
ExpOperation* op = 0;
|
ExpOperation* op = 0;
|
||||||
switch (extractArgs(stack,oper,context,args)) {
|
switch (extractArgs(stack,oper,context,args)) {
|
||||||
|
@ -4005,6 +4046,15 @@ bool JsConfigSection::runNative(ObjList& stack, const ExpOperation& oper, GenObj
|
||||||
if (sect)
|
if (sect)
|
||||||
sect->addParam(*static_cast<ExpOperation*>(args[0]),*static_cast<ExpOperation*>(args[1]));
|
sect->addParam(*static_cast<ExpOperation*>(args[0]),*static_cast<ExpOperation*>(args[1]));
|
||||||
}
|
}
|
||||||
|
else if (oper.name() == YSTRING("setValues") || oper.name() == YSTRING("addValues")) {
|
||||||
|
// setValues(params[,prefix])
|
||||||
|
// addValues(params[,prefix])
|
||||||
|
ExpOperation* params = 0;
|
||||||
|
ExpOperation* prefix = 0;
|
||||||
|
if (!extractStackArgs(1,this,stack,oper,context,args,¶ms,&prefix))
|
||||||
|
return false;
|
||||||
|
handleCfgSetValues(oper.name() == YSTRING("setValues"),m_owner->config(),toString(),params,prefix);
|
||||||
|
}
|
||||||
else if (oper.name() == YSTRING("clearKey")) {
|
else if (oper.name() == YSTRING("clearKey")) {
|
||||||
if (extractArgs(stack,oper,context,args) != 1)
|
if (extractArgs(stack,oper,context,args) != 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue