MCPcopy Create free account
hub / github.com/cinder/Cinder / setup

Method setup

test/XMLTest/src/XMLTestApp.cpp:42–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42void XMLTestApp::setup()
43{
44 XmlTree doc( loadFile( getAssetPath( "library.xml" ) ) );
45 XmlTree musicLibrary( doc.getChild( "library" ) );
46 for( XmlTree::ConstIter item = doc.begin("library/album"); item != doc.end(); ++item ) {
47 console() << "Node: " << item->getTag() << " Value: " << item->getValue() << endl;
48 }
49
50 for( XmlTree::ConstIter track = doc.begin("library/album/track"); track != doc.end(); ++track )
51 console() << track->getValue() << endl;
52
53 assert( (musicLibrary / "album")["musician"] == "John Coltrane" );
54
55 // test that /one/two is equivalent to one/two
56 vector<string> noLeadingSeparator, leadingSeparator;
57 for( XmlTree::ConstIter track = doc.begin("library/album/track"); track != doc.end(); ++track )
58 noLeadingSeparator.push_back( track->getValue() );
59 for( XmlTree::ConstIter track = doc.begin("/library/album/track"); track != doc.end(); ++track )
60 leadingSeparator.push_back( track->getValue() );
61 assert( noLeadingSeparator == leadingSeparator );
62
63 XmlTree firstAlbum = doc.getChild( "library/album" );
64 for( XmlTree::Iter child = firstAlbum.begin(); child != firstAlbum.end(); ++child ) {
65 console() << "Tag: " << child->getTag() << " Value: " << child->getValue() << endl;
66 }
67 console() << doc.getChild( "library/owner/city" );
68 XmlTree ownerCity = doc.getChild( "///library/////owner/city" );
69 console() << "Path: " << ownerCity.getPath() << " Value: " << ownerCity.getValue() << std::endl;
70 console() << doc;
71
72 console() << findTrackNamed( doc.getChild( "library" ), "Wolf" );
73
74 // Whoops - assignment by value doesn't modifying the original XmlTree
75 XmlTree firstTrackCopy = doc.getChild( "/library/album/track" );
76 firstTrackCopy.setValue( "Replacement name" );
77 console() << doc.getChild( "/library/album/track" ) << std::endl;
78
79 XmlTree &firstTrackRef = doc.getChild( "/library/album/track" );
80 firstTrackRef.setValue( "Replacement name" );
81 console() << doc.getChild( "/library/album/track" ) << std::endl;
82
83 XmlTree albumCopy = copyFirstAlbum( doc / "library" );
84 console() << ( albumCopy / "track" ).getPath() << std::endl; // should print 'newRoot/track'
85
86 // This code only works in VC2010
87/* std::for_each( doc.begin( "library/album" ), doc.end(), []( const XmlTree &child ) {
88 app::console() << child.getChild( "title" ).getValue() << std::endl;
89 } );*/
90}
91
92void XMLTestApp::mouseDown( MouseEvent event )
93{

Callers

nothing calls this directly

Calls 10

loadFileFunction · 0.85
getAssetPathFunction · 0.85
assertFunction · 0.85
copyFirstAlbumFunction · 0.85
getValueMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
getPathMethod · 0.45
setValueMethod · 0.45

Tested by

no test coverage detected