Added method to check if any parameter in a list starts with a certain prefix.

git-svn-id: http://yate.null.ro/svn/yate/trunk@5318 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
andrei 2012-11-02 13:41:17 +00:00
parent 62bbf17bfc
commit 83234869ad
2 changed files with 20 additions and 0 deletions

View File

@ -216,6 +216,19 @@ NamedList& NamedList::copySubParams(const NamedList& original, const String& pre
return *this;
}
bool NamedList::hasSubParams(const char* prefix) const
{
XDebug(DebugInfo,"NamedList::hasSubParams(\"%s\") [%p]",prefix,this);
if (!TelEngine::null(prefix)) {
for (const ObjList* l = m_params.skipNull(); l; l = l->skipNext()) {
const NamedString* s = static_cast<const NamedString*>(l->get());
if (s->name().startsWith(prefix))
return true;
}
}
return false;
}
void NamedList::dump(String& str, const char* separator, char quote, bool force) const
{
if (force && str.null())

View File

@ -3799,6 +3799,13 @@ public:
*/
NamedList& copySubParams(const NamedList& original, const String& prefix, bool skipPrefix = true);
/**
* Check if we have a parameter that starts with prefix
* @param prefix Prefix to match in parameter name, must not be NULL
* @return True if a parameter starts with prefix
*/
bool hasSubParams(const char* prefix) const;
/**
* Get the index of a named string in the parameter list.
* @param param Pointer to the parameter to locate