Esempio n. 1
0
File: Xml.cpp Progetto: Lemm/simbody
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());
}
Esempio n. 2
0
File: Xml.cpp Progetto: Lemm/simbody
void Xml::eraseTopLevelNode(const Xml::node_iterator& deleteThis) {
    const char* method = "Xml::eraseTopLevelNode()";

    // Check that the supplied iterator points to something.
    SimTK_ERRCHK_ALWAYS(deleteThis != node_end(), method,
        "The node_iterator is at node_end() so doesn't refer to a Node.");
    // There is an iterator, make sure it's a top-level one.
    SimTK_ERRCHK_ALWAYS(deleteThis->isTopLevelNode(), method,
        "The node_iterator did not refer to a top-level Node.");
    SimTK_ERRCHK1_ALWAYS(Comment::isA(*deleteThis) || Unknown::isA(*deleteThis),
        method, "The Node had NodeType %s, but only Comment and Unknown nodes"
        " can be erased at the topmost document level.",
        deleteThis->getNodeTypeAsString().c_str());

    updImpl().m_tixml.RemoveChild(deleteThis->updTiNodePtr());
}