当前位置: 首页>>代码示例>>C++>>正文


C++ MeiDocument::setRootElement方法代码示例

本文整理汇总了C++中MeiDocument::setRootElement方法的典型用法代码示例。如果您正苦于以下问题:C++ MeiDocument::setRootElement方法的具体用法?C++ MeiDocument::setRootElement怎么用?C++ MeiDocument::setRootElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MeiDocument的用法示例。


在下文中一共展示了MeiDocument::setRootElement方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MeiDocument

TEST(TestMeiDocument, RootElement) {
    MeiDocument *doc = new MeiDocument();
    Mei *m = new Mei();
    doc->setRootElement(m);

    ASSERT_EQ(m, doc->getRootElement());
}
开发者ID:Breakend,项目名称:libmei,代码行数:7,代码来源:test_meidocument.cpp

示例2: MeiElement

TEST(TestMeiElement, GetPositionInDocument) {
    MeiElement* m = new MeiElement("mei");
    MeiElement *m1 = new MeiElement("music");
    string musicId = m1->getId();
    MeiElement *b1 = new MeiElement("body");
    MeiElement *s1 = new MeiElement("staff");
    MeiElement *n1 = new MeiElement("note");
    string nId = n1->getId();
    MeiElement *n2 = new MeiElement("note");
    MeiElement *n3 = new MeiElement("note");
    MeiElement *n4 = new MeiElement("note");    
    string n4Id = n4->getId();
    
    m->addChild(m1);
    m1->addChild(b1);
    b1->addChild(s1);
    s1->addChild(n1);
    s1->addChild(n2);
    s1->addChild(n3);
    
    MeiDocument* doc = new MeiDocument();
    doc->setRootElement(m);
    
    ASSERT_EQ(4, n1->getPositionInDocument());
    ASSERT_EQ(-1, n4->getPositionInDocument());
    
}
开发者ID:annplaksin,项目名称:libmei,代码行数:27,代码来源:test_meielement.cpp

示例3: Mei

TEST(TestMeiDocument, FlattenedDocTree) {
    Mei *mei = new Mei();
    Music *mus = new Music();
    Body *body = new Body();
    Staff *staff = new Staff();
    Staff *s2 = new Staff();
    Note *n1 = new Note();
    Note *n2 = new Note();
    Note *n3 = new Note();
    
    MeiDocument *doc = new MeiDocument();

    mei->addChild(mus);
    // empty since mei not added as document root yet
    ASSERT_TRUE(doc->getFlattenedTree().empty());

    doc->setRootElement(mei);
    ASSERT_EQ(2, doc->getFlattenedTree().size());

    mus->addChild(body);    
    body->addChild(staff);
    body->addChild(s2);
    staff->addChild(n1);
    staff->addChild(n2);
    s2->addChild(n3);

    
    doc->lookBack(n2, "mei");
    ASSERT_EQ(8, doc->getFlattenedTree().size());

    staff->removeChild(n2);
    ASSERT_EQ(7, doc->getFlattenedTree().size());
    ASSERT_EQ(s2, doc->getFlattenedTree()[5]);
    
    staff->removeChildrenWithName("note");
    ASSERT_EQ(6, doc->getFlattenedTree().size());
    
    body->deleteAllChildren();
    ASSERT_EQ(3, doc->getFlattenedTree().size());

    std::vector<MeiElement*> newChildren;
    Staff *newStaff1 = new Staff();
    Staff *newStaff2 = new Staff();
    newChildren.push_back(newStaff1);
    newChildren.push_back(newStaff2);
    body->setChildren(newChildren);
    ASSERT_EQ(5, doc->getFlattenedTree().size());

    // check contents
    MeiElement* elements[] = { mei, mus, body, newStaff1, newStaff2 };
    std::vector<MeiElement*> rightOrder (elements, elements + sizeof(elements) / sizeof(MeiElement));

    for (int i = 0; i < rightOrder.size(); i++) {
        // check don't overshoot memory allocation
        ASSERT_LT(i, doc->getFlattenedTree().size());
        ASSERT_EQ(rightOrder[i], doc->getFlattenedTree()[i]);
    }
        
}
开发者ID:Breakend,项目名称:libmei,代码行数:59,代码来源:test_meidocument.cpp

示例4: MeiDocument

TEST(TestMeiDocument, SetsDefaultNamespace) {
    MeiDocument *doc = new MeiDocument();
    MeiElement *root = new MeiElement("mei");
    
    doc->setRootElement(root);
    
    ASSERT_TRUE(root->hasAttribute("xmlns"));
    ASSERT_EQ(root->getAttribute("xmlns")->getValue(), MEI_NS);
}
开发者ID:annplaksin,项目名称:libmei,代码行数:9,代码来源:test_meidocument.cpp

示例5: init

void XmlImportImpl::init() {
    // get mei version from document
    xmlAttrPtr meiversAttr = xmlHasProp(this->rootXmlNode, (const xmlChar*)"meiversion");
    string meiVersion = string((const char*)meiversAttr->children->content);
    
    MeiDocument *doc = new MeiDocument(meiVersion);
    this->meiDocument = doc;

    this->rootMeiElement = this->xmlNodeToMeiElement(this->rootXmlNode);
    doc->setRootElement(this->rootMeiElement);
}
开发者ID:Breakend,项目名称:libmei,代码行数:11,代码来源:xmlimport.cpp

示例6: MeiDocument

TEST(TestMeiElement, TestRemoveManyChildren) {
    MeiDocument *doc = new MeiDocument();
    MeiElement *mei = new MeiElement("mei");
    MeiElement *sd1 = new MeiElement("staffDef");
    MeiElement *sd2 = new MeiElement("staffDef");
    MeiElement *sd3 = new MeiElement("staffDef");
    MeiElement *sd4 = new MeiElement("staffDef");
    MeiElement *sd5 = new MeiElement("staffDef");
    MeiElement *sd6 = new MeiElement("staffDef");
    
    doc->setRootElement(mei);
    
    MeiElement *music = new mei::MeiElement("music");
    MeiElement *scoreDef = new mei::MeiElement("scoreDef");
    
    mei->addChild(music);
    music->addChild(scoreDef);
    scoreDef->addChild(sd1);
    scoreDef->addChild(sd2);
    scoreDef->addChild(sd3);
    scoreDef->addChild(sd4);
    scoreDef->addChild(sd5);
    scoreDef->addChild(sd6);
    
    sd1->addAttribute("n", "1");
    sd2->addAttribute("n", "2");
    sd3->addAttribute("n", "3");
    sd4->addAttribute("n", "4");
    sd5->addAttribute("n", "5");
    sd6->addAttribute("n", "6");
    
    vector<MeiElement*> scoreDefs = doc->getRootElement()->getDescendantsByName("scoreDef");
    vector<MeiElement*> staffDefs = doc->getRootElement()->getDescendantsByName("staffDef");
    
    for (vector<MeiElement*>::iterator iter = staffDefs.begin(); iter != staffDefs.end(); ++iter) {
        if ((*iter)->getAttribute("n")->getValue() == "3" || (*iter)->getAttribute("n")->getValue() == "6") {
            (*iter)->getParent()->removeChild((*iter));
        }
    }
    ASSERT_EQ(4, music->getDescendantsByName("staffDef").size());
    
}
开发者ID:annplaksin,项目名称:libmei,代码行数:42,代码来源:test_meielement.cpp


注:本文中的MeiDocument::setRootElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。