//_______________________________________________________________________________ static void test1(Sxmlelement elt) { cerr << "test1: iterate thru the tree" << endl; ctree<xmlelement>::iterator iter = elt->begin(); cerr << "=> test1: iterate thru the tree" << endl; while (iter != elt->end()) { Sxmlelement xml = *iter; if (xml) cerr << " element type " << xml->getType() << " - " << xml->getName() << " - size: " << xml->size() << endl; else cerr << "iterate thru unknown element type " << endl; iter++; } }
//_______________________________________________________________________________ static void test3(Sxmlelement elt) { cerr << "test3: insert a note before the par notes" << endl; ctree<xmlelement>::iterator next, iter = elt->begin(); int note=1; while (iter != elt->end()) { Sxmlelement xml = *iter; assert (xml); if (xml->getType() == k_note) { if (!(note & 1)) { Sxmlelement note = factory::instance().create(k_note); iter = elt->insert(iter, note); iter++; } note++; } iter++; } }
//_______________________________________________________________________________ static void test2(Sxmlelement elt) { cerr << "test2: erasing all the par measures" << endl; ctree<xmlelement>::iterator next, iter = elt->begin(); int measure=1; while (iter != elt->end()) { Sxmlelement xml = *iter; next = iter; next++; assert (xml); if (xml->getType() == k_software) { next = elt->erase(iter); } else if (xml->getType() == k_measure) { if (!(measure & 1)) { next = elt->erase(iter); } measure++; } iter = next; } }
//_______________________________________________________________________________ static void count(Sxmlelement elt, int type) { predicate p(type); cerr << " count of type " << type << " elements: " << count_if(elt->begin(), elt->end(), p) << endl; }