-
Notifications
You must be signed in to change notification settings - Fork 23
Code Examples (C )
ifkarp edited this page May 22, 2015
·
2 revisions
Some code examples to illustrate how to use the Libmei in C++:
#include <mei/xmlimport.h>
mei::XMLImportResult res = mei::documentFromFile("beethoven.mei", mei::MEI_STRICT_IMPORT);
mei::MeiDocument *doc = res.getMeiDocument();
#include <mei/mei.h>
#include <mei/shared.h>
#include <mei/cmn.h>
#include <mei/xmlexport.h>
//create a very basic document structure
mei::MeiDocument *doc = new mei::MeiDocument();
mei::MeiElement *m1 = new mei::MeiElement("mei");
doc->setRootElement(m1);
//create a new note with an attribute
mei::MeiAttribute *att = new mei::MeiAttribute("accid", "s");
mei::Note *n = new mei::Note();
n->addAttribute(att);
m1->addChild(n);
//This will return True if it was successful
bool status = mei::documentToFile(doc, "outputfile.mei")
You can also look at the C++ unit tests code for more examples.