本文整理汇总了C++中Music::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ Music::addChild方法的具体用法?C++ Music::addChild怎么用?C++ Music::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Music
的用法示例。
在下文中一共展示了Music::addChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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]);
}
}
示例2: xml_file_name
void CScribeToNeoScribeXML::SegmentScribe2MEIXML(const CScribeReaderVisitable& scribe_data)
{
std::unordered_set<std::string> rep_no_record;
for (std::vector<scribe_part>::const_iterator part = scribe_data.GetScribeParts().begin(); part != scribe_data.GetScribeParts().end(); part++)
{
int i = 0;
//save record of first part
scribe_part first_part = *part;
//create an instance of XML doc representation, etc.
delete doc;
doc = new MeiDocument();
Mei *mei = new Mei;
doc->setRootElement(mei);
/*
MEI
- <meiHead>
- FileDescription
- EncodingDescription
- Work Description
- Revision Description
*/
//create MEIhead to contain file, encoding, work and revision description
MeiHead* mei_head = new MeiHead;
mei->addChild(mei_head);
AltId* altId = new AltId;
mei_head->addChild(altId);
if (scribe_data.GetType()==scribe_type::trecento)
{
altId->addAttribute("type", "repnum");
altId->setValue(part->rep_num);
} else if (scribe_data.GetType()==scribe_type::trecento)
{
altId->addAttribute("type", "cao");
altId->setValue(std::to_string(part->cao_num));
}
//Create and link fileDesc
FileDesc* fileDesc = Scribe2MEIFileDesc();
mei_head->addChild(fileDesc);
//Create and link encodingDesc
EncodingDesc* encodingDesc = Scribe2MEIEncoderDesc();
mei_head->addChild(encodingDesc);
//Create and link workDesc
WorkDesc* workDesc = Scribe2MEIWorkDesc();
mei_head->addChild(workDesc);
//</meiHead> - not really at this stage - other elements completed in main routine
//music - contains all music data
Music* music = new Music;
mei->addChild(music);
Mdiv* mdiv = new Mdiv; //for chant source this needs to be specified repeatedly, with n and type attributes
music->addChild(mdiv);
Score* score = new Score;
mdiv->addChild(score);
//start adding score definitions - child of score
ScoreDef* scoredef = new ScoreDef;
score->addChild(scoredef);
StaffGrp* staffgrp = new StaffGrp;
scoredef->addChild(staffgrp);
staffgrp->setId("all");
//skip along and collect parts - all have the same REPNUM
std::string xml_file_name("");
if (scribe_data.GetType()==scribe_type::trecento)
{
do
{
++i;
if (i==1)
{
Scribe2MEIXMLFileData(fileDesc, *part);
Scribe2MEIXMLWorkData(workDesc, *part);
}
//add section - child of score
Section* section = new Section;
score->addChild(section);
//handle staff and link to section
Staff* staff = Scribe2MEIXMLStaff(scribe_data, *part, staffgrp, i);
section->addChild(staff); //or TiXmlElement* layer;?
part++;
} while ( part->rep_num==first_part.rep_num && part != scribe_data.GetScribeParts().end());
part--; // step back to last part in piece
xml_file_name = first_part.rep_num;
//.........这里部分代码省略.........
示例3: Section
MeiDocument* CScribeToNeoScribeXML::Scribe2MEIXML(const CScribeReaderVisitable& scribe_data)
{
Mei* mei = new Mei;
doc->setRootElement(mei);
//create MEIhead to contain file, encoding, work and revision description
MeiHead* mei_head = new MeiHead; //"meiHead"
mei->addChild(mei_head);
//Create and link fileDesc
FileDesc* fileDesc = Scribe2MEIFileDesc();
mei_head->addChild(fileDesc);
//Create and link encodingDesc
EncodingDesc* encodingDesc = Scribe2MEIEncoderDesc();
mei_head->addChild(encodingDesc);
//Create and link workDesc
WorkDesc* workDesc = Scribe2MEIWorkDesc();
mei_head->addChild(workDesc);
//</meiHead> - not really at this stage - other elements completed in main routine
//music - contains all music data
Music* music = new Music;
mei->addChild(music);
Mdiv* mdiv = new Mdiv; //for chant source this needs to be specified repeatedly, with n and type attributes
music->addChild(mdiv);
Score* score = new Score;
mdiv->addChild(score);
//start adding score definitions - child of score
ScoreDef* scoredef = new ScoreDef;
score->addChild(scoredef);
StaffGrp* staffgrp = new StaffGrp;
scoredef->addChild(staffgrp);
staffgrp->setId("all");
int i=0;
for (std::vector<scribe_part>::const_iterator partit = scribe_data.GetScribeParts().begin(); partit!=scribe_data.GetScribeParts().end(); partit++)
{
++i;
if (i==1)
{
Scribe2MEIXMLFileData(fileDesc, *partit);
Scribe2MEIXMLWorkData(workDesc, *partit);
}
//add section - child of score
Section* section = new Section();
score->addChild(section);
//handle staff and link to section
Staff* staff = Scribe2MEIXMLStaff(scribe_data, *partit, staffgrp, i);
section->addChild(staff);
}
return doc;
}