Added NamedList constructor and method to copy subparameters from another list.
git-svn-id: http://yate.null.ro/svn/yate/trunk@2811 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
6738d7bce0
commit
bdbbbc5076
|
@ -46,6 +46,12 @@ NamedList::NamedList(const NamedList& original)
|
|||
}
|
||||
}
|
||||
|
||||
NamedList::NamedList(const char* name, const NamedList& original, const String& prefix)
|
||||
: String(name)
|
||||
{
|
||||
copySubParams(original,prefix);
|
||||
}
|
||||
|
||||
void* NamedList::getObject(const String& name) const
|
||||
{
|
||||
if (name == "NamedList")
|
||||
|
@ -172,6 +178,24 @@ NamedList& NamedList::copyParams(const NamedList& original, const String& list,
|
|||
return *this;
|
||||
}
|
||||
|
||||
NamedList& NamedList::copySubParams(const NamedList& original, const String& prefix)
|
||||
{
|
||||
XDebug(DebugInfo,"NamedList::copySubParams(%p,\"%s\")",&original,prefix.c_str());
|
||||
if (prefix) {
|
||||
unsigned int offs = prefix.length();
|
||||
unsigned int n = original.length();
|
||||
for (unsigned int i = 0; i < n; i++) {
|
||||
const NamedString* s = original.getParam(i);
|
||||
if (s && s->name().startsWith(prefix)) {
|
||||
const char* name = s->name().c_str() + offs;
|
||||
if (*name)
|
||||
addParam(name,*s);
|
||||
}
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void NamedList::dump(String& str, const char* separator, char quote, bool force) const
|
||||
{
|
||||
if (force && str.null())
|
||||
|
|
15
yateclass.h
15
yateclass.h
|
@ -3240,6 +3240,14 @@ public:
|
|||
*/
|
||||
NamedList(const NamedList& original);
|
||||
|
||||
/**
|
||||
* Creates a named list with subparameters of another list.
|
||||
* @param name Name of the list - must not be NULL or empty
|
||||
* @param original Named list to copy parameters from
|
||||
* @param prefix Prefix to match and remove from parameter names
|
||||
*/
|
||||
NamedList(const char* name, const NamedList& original, const String& prefix);
|
||||
|
||||
/**
|
||||
* Get a pointer to a derived class given that class name
|
||||
* @param name Name of the class we are asking for
|
||||
|
@ -3330,6 +3338,13 @@ public:
|
|||
*/
|
||||
NamedList& copyParams(const NamedList& original, const String& list, char childSep = 0);
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
NamedList& copySubParams(const NamedList& original, const String& prefix);
|
||||
|
||||
/**
|
||||
* Get the index of a named string in the parameter list.
|
||||
* @param param Pointer to the parameter to locate
|
||||
|
|
Loading…
Reference in New Issue