本文整理汇总了C++中MeiDocument::lookBack方法的典型用法代码示例。如果您正苦于以下问题:C++ MeiDocument::lookBack方法的具体用法?C++ MeiDocument::lookBack怎么用?C++ MeiDocument::lookBack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeiDocument
的用法示例。
在下文中一共展示了MeiDocument::lookBack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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]);
}
}