diff --git a/engine/NamedList.cpp b/engine/NamedList.cpp index 9d137e84..9f90bfa0 100644 --- a/engine/NamedList.cpp +++ b/engine/NamedList.cpp @@ -172,6 +172,20 @@ NamedList& NamedList::copyParams(const NamedList& original, const String& list, return *this; } +void NamedList::dump(String& str, const char* separator, char quote, bool force) const +{ + if (force && str.null()) + str << separator; + str << quote << *this << quote; + const ObjList *p = m_params.skipNull(); + for (; p; p = p->skipNext()) { + const NamedString* s = static_cast(p->get()); + String tmp; + tmp << quote << s->name() << quote << "=" << quote << *s << quote; + str.append(tmp,separator); + } +} + int NamedList::getIndex(const NamedString* param) const { if (!param) diff --git a/yateclass.h b/yateclass.h index e4b1b0d0..2bf71b0c 100644 --- a/yateclass.h +++ b/yateclass.h @@ -3396,6 +3396,16 @@ public: */ int replaceParams(String& str, bool sqlEsc = false, char extraEsc = 0) const; + /** + * Dumps the name and all parameters to a string in a human readable format. + * No escaping takes place so this method should be used for debugging only + * @param str String to which the name and parameters are appended + * @param separator Separator string to use before each parameter + * @param quote String quoting character, usually single or double quote + * @param force True to insert the separator even in an empty string + */ + void dump(String& str, const char* separator, char quote = 0, bool force = false) const; + /** * A static empty named list * @return Reference to a static empty named list