diff --git a/engine/NamedList.cpp b/engine/NamedList.cpp index 91c5b972..31448371 100644 --- a/engine/NamedList.cpp +++ b/engine/NamedList.cpp @@ -195,6 +195,12 @@ NamedString* NamedList::getParam(unsigned int index) const return static_cast(m_params[index]); } +const String& NamedList::operator[](const String& name) const +{ + const String* s = getParam(name); + return s ? *s : String::empty(); +} + const char* NamedList::getValue(const String& name, const char* defvalue) const { XDebug(DebugInfo,"NamedList::getValue(\"%s\",\"%s\")",name.c_str(),defvalue); diff --git a/yateclass.h b/yateclass.h index 21da21da..6ac447aa 100644 --- a/yateclass.h +++ b/yateclass.h @@ -3008,6 +3008,13 @@ public: */ NamedString* getParam(unsigned int index) const; + /** + * Parameter access operator + * @param name Name of the parameter to return + * @return String value of the parameter, @ref String::empty() if missing + */ + const String& operator[](const String& name) const; + /** * Retrive the value of a named parameter. * @param name Name of parameter to locate