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


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

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


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

示例1: createMeiDocument

TEST(CmnModuleTest, TestTieMembership) {
    MeiDocument* doc = createMeiDocument();

    MeiElement* layer = doc->getElementById("id-layer");
    MeiElement* measure = doc->getElementById("id-measure");

    Note* n1 = new Note();
    Note* n2 = new Note();
    Note* n3 = new Note();
    Note* n4 = new Note();

    layer->addChild(n1);
    layer->addChild(n2);
    layer->addChild(n3);
    layer->addChild(n4);

    Tie* t1 = new Tie();
    measure->addChild(t1);

    t1->m_Startid.setStartid(n1->getId());
    t1->m_Startendid.setEndid(n4->getId());
    t1->m_Staffident.setStaff("staffname");
    
    vector<MeiElement*> members = t1->getMembers();
    ASSERT_EQ(4, members.size());
}
开发者ID:Breakend,项目名称:libmei,代码行数:26,代码来源:test_cmn.cpp

示例2: Mei

// after adding a root to a document, you can find an element
TEST(TestMeiDocument, ElementById) {
    Mei *mei = new Mei();
    Music *mus = new Music();
    Body *body = new Body();
    Staff *staff = new Staff();
    Staff *s2 = new Staff();
    Note *n1 = new Note();
    string wantedId = n1->getId();
    Note *n2 = new Note();
    Note *n3 = new Note();
    Note *n4 = new Note();
    MeiDocument *doc = new MeiDocument();

    ASSERT_EQ(NULL, doc->getElementById(wantedId));

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

    doc->setRootElement(mei);

    ASSERT_EQ(n1, doc->getElementById(wantedId));

    ASSERT_EQ(NULL, doc->getElementById("some-unknown-id"));

    // After adding the root element, making a new element works
    Note *n5 = new Note();
    string newid = n5->getId();
    s2->addChild(n5);
    ASSERT_EQ(n5, doc->getElementById(newid));

    // removing the element from the document, clear from document map
    s2->removeChild(n5);
    ASSERT_EQ(NULL, doc->getElementById(newid));
}
开发者ID:Breakend,项目名称:libmei,代码行数:41,代码来源:test_meidocument.cpp


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