void Xml::insertTopLevelNodeBefore(const Xml::node_iterator& beforeThis, Xml::Node insertThis) { const char* method = "Xml::insertTopLevelNodeBefore()"; // Check that the supplied Node is OK. SimTK_ERRCHK_ALWAYS(insertThis.isValid(), method, "The supplied Node handle was empty."); SimTK_ERRCHK_ALWAYS(insertThis.isOrphan(), method, "The Node was not an orphan so can't be inserted."); SimTK_ERRCHK1_ALWAYS(Comment::isA(insertThis) || Unknown::isA(insertThis), method, "The Node had NodeType %s, but only Comment and Unknown nodes" " can be inserted at the topmost document level.", insertThis.getNodeTypeAsString().c_str()); // If no iterator, add the Node to the end and we're done. if (beforeThis == node_end()) { updImpl().m_tixml.LinkEndChild(insertThis.updTiNodePtr()); return; } // There is an iterator, make sure it's a top-level one. SimTK_ERRCHK_ALWAYS(beforeThis->isTopLevelNode(), method, "The node_iterator did not refer to a top-level Node."); updImpl().m_tixml.LinkBeforeChild(beforeThis->updTiNodePtr(), insertThis.updTiNodePtr()); }
/*static*/ bool Xml::Text::isA(const Xml::Node& node) { if (!node.isValid()) return false; return node.getTiNode().ToText() != 0; }
/*static*/ bool Xml::Unknown::isA(const Xml::Node& node) { if (!node.isValid()) return false; return node.getTiNode().ToUnknown() != 0; }