Added to NamedList::copySubParams() the option of not skipping over the matched prefix in parameter names.

git-svn-id: http://yate.null.ro/svn/yate/trunk@4191 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2011-03-17 19:46:26 +00:00
parent cf55dedbd5
commit 7702fd0979
2 changed files with 9 additions and 7 deletions

View File

@ -195,13 +195,14 @@ NamedList& NamedList::copyParams(const NamedList& original, const String& list,
return *this;
}
NamedList& NamedList::copySubParams(const NamedList& original, const String& prefix)
NamedList& NamedList::copySubParams(const NamedList& original, const String& prefix, bool skipPrefix)
{
XDebug(DebugInfo,"NamedList::copySubParams(%p,\"%s\")",&original,prefix.c_str());
XDebug(DebugInfo,"NamedList::copySubParams(%p,\"%s\",%s) [%p]",
&original,prefix.c_str(),String::boolText(skipPrefix),this);
if (prefix) {
unsigned int offs = prefix.length();
for (const ObjList* l = original.m_params.skipNull(); l; l = l->skipNext()) {
const NamedString* s = static_cast<const NamedString*>(l->get());
unsigned int offs = skipPrefix ? prefix.length() : 0;
for (const ObjList* l = original.m_params.skipNull(); l; l = l->skipNext()) {
const NamedString* s = static_cast<const NamedString*>(l->get());
if (s->name().startsWith(prefix)) {
const char* name = s->name().c_str() + offs;
if (*name)

View File

@ -3430,10 +3430,11 @@ public:
/**
* Copy subparameters from another list
* @param original Named list to copy parameters from
* @param prefix Prefix to match and remove from parameter names, must not be NULL
* @param prefix Prefix to match in parameter names, must not be NULL
* @param skipPrefix Skip over the prefix when building new parameter name
* @return Reference to this NamedList
*/
NamedList& copySubParams(const NamedList& original, const String& prefix);
NamedList& copySubParams(const NamedList& original, const String& prefix, bool skipPrefix = true);
/**
* Get the index of a named string in the parameter list.