Added replaceParams() to XML fragment, document, element and text.
git-svn-id: http://voip.null.ro/svn/yate@6305 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
035a758980
commit
131f8ca07c
|
@ -1455,6 +1455,13 @@ XmlElement* XmlFragment::findElement(ObjList* list, const String* name, const St
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replaces all ${paramname} in fragment's children with the corresponding parameters
|
||||||
|
void XmlFragment::replaceParams(const NamedList& params)
|
||||||
|
{
|
||||||
|
for (ObjList* o = m_list.skipNull(); o; o = o->skipNext())
|
||||||
|
static_cast<XmlChild*>(o->get())->replaceParams(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XmlDocument
|
* XmlDocument
|
||||||
|
@ -1663,6 +1670,15 @@ int XmlDocument::saveFile(const char* file, bool esc, const String& indent,
|
||||||
return f.error();
|
return f.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replaces all ${paramname} in document's components with the corresponding parameters
|
||||||
|
void XmlDocument::replaceParams(const NamedList& params)
|
||||||
|
{
|
||||||
|
if (m_root)
|
||||||
|
m_root->replaceParams(params);
|
||||||
|
m_beforeRoot.replaceParams(params);
|
||||||
|
m_afterRoot.replaceParams(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XmlChild
|
* XmlChild
|
||||||
|
@ -1994,6 +2010,15 @@ bool XmlElement::setXmlns(const String& name, bool addAttr, const String& value)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replaces all ${paramname} in element's attributes and children with the
|
||||||
|
// corresponding parameters
|
||||||
|
void XmlElement::replaceParams(const NamedList& params)
|
||||||
|
{
|
||||||
|
m_children.replaceParams(params);
|
||||||
|
for (ObjList* o = m_element.paramList()->skipNull(); o; o = o->skipNext())
|
||||||
|
params.replaceParams(*static_cast<String*>(o->get()));
|
||||||
|
}
|
||||||
|
|
||||||
// Build an XML element from a list parameter
|
// Build an XML element from a list parameter
|
||||||
XmlElement* XmlElement::param2xml(NamedString* param, const String& tag, bool copyXml)
|
XmlElement* XmlElement::param2xml(NamedString* param, const String& tag, bool copyXml)
|
||||||
{
|
{
|
||||||
|
@ -2203,6 +2228,13 @@ bool XmlText::onlySpaces()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replaces all ${paramname} in text with the corresponding parameters
|
||||||
|
void XmlText::replaceParams(const NamedList& params)
|
||||||
|
{
|
||||||
|
params.replaceParams(m_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XmlDoctype
|
* XmlDoctype
|
||||||
*/
|
*/
|
||||||
|
|
33
yatexml.h
33
yatexml.h
|
@ -777,6 +777,13 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual XmlDoctype* xmlDoctype()
|
virtual XmlDoctype* xmlDoctype()
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces all ${paramname} with the corresponding parameters
|
||||||
|
* @param params List of parameters
|
||||||
|
*/
|
||||||
|
virtual void replaceParams(const NamedList& params)
|
||||||
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -938,6 +945,12 @@ public:
|
||||||
const String& origIndent = String::empty(), bool completeOnly = true,
|
const String& origIndent = String::empty(), bool completeOnly = true,
|
||||||
const String* auth = 0, const XmlElement* parent = 0) const;
|
const String* auth = 0, const XmlElement* parent = 0) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces all ${paramname} in fragment's children with the corresponding parameters
|
||||||
|
* @param params List of parameters
|
||||||
|
*/
|
||||||
|
void replaceParams(const NamedList& params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a completed xml element in a list
|
* Find a completed xml element in a list
|
||||||
* @param list The list to search for the element
|
* @param list The list to search for the element
|
||||||
|
@ -1086,6 +1099,12 @@ public:
|
||||||
void toString(String& dump, bool escape = true, const String& indent = String::empty(),
|
void toString(String& dump, bool escape = true, const String& indent = String::empty(),
|
||||||
const String& origIndent = String::empty()) const;
|
const String& origIndent = String::empty()) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces all ${paramname} in document's components with the corresponding parameters
|
||||||
|
* @param params List of parameters
|
||||||
|
*/
|
||||||
|
void replaceParams(const NamedList& params);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XmlElement* m_root; // The root element
|
XmlElement* m_root; // The root element
|
||||||
XmlFragment m_beforeRoot; // XML children before root (declaration ...)
|
XmlFragment m_beforeRoot; // XML children before root (declaration ...)
|
||||||
|
@ -1537,6 +1556,13 @@ public:
|
||||||
bool setXmlns(const String& name = String::empty(), bool addAttr = false,
|
bool setXmlns(const String& name = String::empty(), bool addAttr = false,
|
||||||
const String& value = String::empty());
|
const String& value = String::empty());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces all ${paramname} in element's attributes and children with the
|
||||||
|
* corresponding parameters
|
||||||
|
* @param params List of parameters
|
||||||
|
*/
|
||||||
|
virtual void replaceParams(const NamedList& params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a string represents a namespace attribute name
|
* Check if a string represents a namespace attribute name
|
||||||
* @param str The string to check
|
* @param str The string to check
|
||||||
|
@ -1782,6 +1808,13 @@ public:
|
||||||
* @return False if the text contains non space characters.
|
* @return False if the text contains non space characters.
|
||||||
*/
|
*/
|
||||||
bool onlySpaces();
|
bool onlySpaces();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces all ${paramname} in text with the corresponding parameters
|
||||||
|
* @param params List of parameters
|
||||||
|
*/
|
||||||
|
virtual void replaceParams(const NamedList& params);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_text; // The text
|
String m_text; // The text
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue