Added utility to ScriptContext used to add string fields from a NamedList.

git-svn-id: http://voip.null.ro/svn/yate@6309 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
marian 2018-04-12 12:35:32 +00:00
parent f3a3aa566a
commit 2c241d279f
2 changed files with 19 additions and 0 deletions

View File

@ -182,6 +182,18 @@ bool ScriptContext::copyFields(ObjList& stack, const ScriptContext& original, Ge
return ok;
}
// Add string parameters from list
void ScriptContext::addFields(const NamedList& list, const char* skipPrefix)
{
if (TelEngine::null(skipPrefix))
skipPrefix = 0;
for (const ObjList* o = list.paramList()->skipNull(); o; o = o->skipNext()) {
const NamedString* p = static_cast<const NamedString*>(o->get());
if (!(skipPrefix && p->name().startsWith(skipPrefix)))
m_params.addParam(new ExpOperation(p->c_str(),p->name()));
}
}
void ScriptContext::fillFieldNames(ObjList& names)
{
bool checkDupl = !(YOBJECT(JsObject,this));

View File

@ -1517,6 +1517,13 @@ public:
*/
virtual bool copyFields(ObjList& stack, const ScriptContext& original, GenObject* context);
/**
* Add string parameters from list
* @param list Parameters list
* @param skipPrefix Skip parameters whose name start with specified prefix
*/
virtual void addFields(const NamedList& list, const char* skipPrefix = "__");
/**
* Try to evaluate a single field searching for a matching context
* @param stack Evaluation stack in use, field value must be pushed on it