Commit 410b0c2f authored by Pavel Vainerman's avatar Pavel Vainerman

(UniXML): added insertNext() function

parent 9c3a8cb0
......@@ -159,9 +159,12 @@ namespace uniset
// Добавить новый дочерний узел
static xmlNode* createChild(xmlNode* node, const std::string& title, const std::string& text);
// Добавить следующий узел
// Добавить следующий узел (добавление в конец списка узлов на уровне node)
static xmlNode* createNext(xmlNode* node, const std::string& title, const std::string& text);
// Создать новый узел следующим за node
static xmlNode* insertNext(xmlNode* node, const std::string& title, const std::string& text);
// Удалить указанный узел и все вложенные узлы
static void removeNode(xmlNode* node);
......
......@@ -159,10 +159,7 @@ string UniXML::getProp(const xmlNode* node, const string& name) noexcept
xmlChar* text = ::xmlGetProp((xmlNode*)node, (const xmlChar*)name.c_str());
if( text == NULL )
{
xmlFree(text);
return "";
}
try
{
......@@ -224,7 +221,7 @@ xmlNode* UniXML::createChild(xmlNode* node, const string& title, const string& t
return ::xmlNewChild(node, NULL, (const xmlChar*)title.c_str(), (const xmlChar*)text.c_str());
}
// -----------------------------------------------------------------------------
xmlNode* UniXML::createNext(xmlNode* node, const string& title, const string& text)
xmlNode* UniXML::createNext( xmlNode* node, const string& title, const string& text )
{
if( node->parent )
return createChild(node->parent, title, text);
......@@ -232,6 +229,15 @@ xmlNode* UniXML::createNext(xmlNode* node, const string& title, const string& te
return 0;
}
// -----------------------------------------------------------------------------
xmlNode* UniXML::insertNext( xmlNode* node, const string& title, const string& text )
{
xmlNode* newNode = createNext(node,title,text);
if( newNode )
return ::xmlAddNextSibling(node,newNode);
return 0;
}
// -----------------------------------------------------------------------------
/// Удаление указанного узла со всеми вложенными
void UniXML::removeNode(xmlNode* node)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment