本文整理汇总了C++中XmlTree::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlTree::begin方法的具体用法?C++ XmlTree::begin怎么用?C++ XmlTree::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlTree
的用法示例。
在下文中一共展示了XmlTree::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
void QTimeline::load( fs::path filepath )
{
clear();
XmlTree doc;
try
{
doc = XmlTree( loadFile( filepath ) );
for( XmlTree::Iter nodeIt = doc.begin("QTimeline/tracks/track"); nodeIt != doc.end(); ++nodeIt )
{
string trackName = nodeIt->getAttributeValue<string>("name");
QTimelineTrackRef trackRef = QTimelineTrackRef( new QTimelineTrack( trackName ) );
mTracks.push_back( trackRef );
trackRef->loadXmlNode( *nodeIt );
}
mCueManager->loadXmlNode( doc.getChild( "qTimeline/cueList" ) );
}
catch ( ... )
{
console() << "Error > QTimeline::load(): " << filepath.filename().generic_string() << endl;
return;
}
updateCurrentTime();
}
示例2: parseRecipes
void AppModel::parseRecipes(XmlTree _root){
XmlTree t = _root.getChild("dict/dict");
for( XmlTree::Iter child = t.begin(); child != t.end(); ++child ){
if(child->getTag().compare("key")==0){
// use this value as the name for a new Recipe object
RecipeModel rm;
rm.name = child->getValue();
recipes.push_back(rm);
} else {
XmlTree t2 = *child;
string whichKey;
for( XmlTree::Iter grandchild = t2.begin(); grandchild != t2.end(); ++grandchild ){
if(grandchild->getTag().compare("key")==0){
whichKey = grandchild->getValue();
} else if(grandchild->getTag().compare("dict")==0){
if(whichKey.compare("Steps")==0){
XmlTree t3 = *grandchild;
CookStepModel sm;
for( XmlTree::Iter greatChild = t3.begin(); greatChild != t3.end(); ++greatChild ){
XmlTree t4 = *greatChild;
string stepKey;
if(greatChild->getTag().compare("dict")==0){
for( XmlTree::Iter baby = t4.begin(); baby != t4.end(); ++baby ){
if(baby->getTag().compare("key")==0){
stepKey = baby->getValue();
} else {
if(stepKey.compare("img")==0){
sm.img = baby->getValue();
} else if(stepKey.compare("video")==0){
sm.video = baby->getValue();
} else {
console() << "I got a property of a cookstep that was unexpected: " << stepKey << ", " << baby->getValue();
}
}
}
} else if(greatChild->getTag().compare("key")==0){
if(recipes.size()>0 && sm.name.compare("")!=0){
recipes.at(recipes.size()-1).steps.push_back(sm);
}
sm.name = sm.video = sm.img = "";
sm.name = greatChild->getValue();
}
}
if(sm.name.compare("")!=0){
recipes.at(recipes.size()-1).steps.push_back(sm);
}
}
} else {
// do nothing?
}
}
}
}
}
示例3: trace
void PlistReader::trace(XmlTree t){
for( XmlTree::Iter child = t.begin(); child != t.end(); ++child ){
console() << "Tag: " << child->getTag() << " Value: " << child->getValue() << endl;
if(child->getTag().compare("dict")==0){
trace(*child);
}
}
}
示例4: mNodeType
XmlTree::XmlTree( const XmlTree &rhs )
: mNodeType( rhs.mNodeType ), mTag( rhs.mTag ), mValue( rhs.mValue ), mDocType( rhs.mDocType ),
mParent( 0 ), mAttributes( rhs.mAttributes )
{
for( XmlTree::ConstIter childIt = rhs.begin(); childIt != rhs.end(); ++childIt ) {
mChildren.push_back( unique_ptr<XmlTree>( new XmlTree( *childIt ) ) );
mChildren.back()->mParent = this;
}
}
示例5: loadXML
void ConfigDict::loadXML(DataSourceRef source)
{
XmlTree doc;
try {
doc = XmlTree(source);
} catch(rapidxml::parse_error &e) {
LOG_ERROR("ConfigDict::loadXML - couldnt parse XML data ("<<
"error: "<< e.what() <<" "<<
"file: "<< source->getFilePathHint() <<
")");
}
XmlTree root = *doc.begin();
for(XmlTree::ConstIter setting = root.begin(); setting != root.end(); ++setting)
{
string key = setting->getTag();
string value = setting->getValue();
settings.insert(std::pair<string,string>(key, value) );
}
}
示例6: setup
void FlickrTestApp::setup()
{
glEnable( GL_TEXTURE_2D );
const XmlTree xml( loadUrl( Url( "http://api.flickr.com/services/feeds/[email protected]&lang=en-us&format=rss_200" ) ) );
for( XmlTree::ConstIter item = xml.begin( "rss/channel/item" ); item != xml.end(); ++item ) {
mUrls.push_back( item->getChild( "media:content" ).getAttributeValue<Url>( "url" ) );
}
createTextureFromURL();
lastTime = getElapsedSeconds();
activeTex = 0;
}
示例7: initFromXml
void CanvasComponent::initFromXml(const XmlTree& xml, bool createNodes)
{
id = xml.getAttributeValue<int>("id");
// when loading a patch, update globalID so future
// nodes will be created with a unique id
if (globalComponentID <= id) {
// increment global id so each component will have a unique id
globalComponentID = id+1;
}
setName(xml.getAttributeValue<std::string>("name"));
Vec2f pos = Vec2f(xml.getAttributeValue<float>("position.x"), xml.getAttributeValue<float>("position.y"));
Vec2f size = Vec2f(xml.getAttributeValue<float>("size.x"), xml.getAttributeValue<float>("size.y"));
canvasRect = Rectf(pos, pos+size);
setSize(size);
showInputPlus = xml.getAttributeValue<bool>("showInputPlus");
showOutputPlus = xml.getAttributeValue<bool>("showOutputPlus");
if (createNodes)
{
// add inputs and outputs
XmlTree inputNodesTree = xml.getChild("InputNodes");
for(XmlTree::ConstIter iter = inputNodesTree.begin(); iter != inputNodesTree.end(); ++iter)
{
if (iter->getTag() == "Node") {
addInputNodeFromXml(iter->getChild(""));
}
}
XmlTree outputNodesTree = xml.getChild("OutputNodes");
for(XmlTree::ConstIter iter = outputNodesTree.begin(); iter != outputNodesTree.end(); ++iter)
{
if (iter->getTag() == "Node") {
addOutputNodeFromXml(iter->getChild(""));
}
}
}
}
示例8: parseData
void DataManager::parseData( XmlTree d ){
XmlTree data = d.getChild( "QLT_Genome_Data" );
string dataPath = data.getChild( "datapath" ).getValue();
XmlTree sets = data.getChild( "datasets");
for( XmlTree::Iter dataset = sets.begin(); dataset != sets.end(); ++dataset ){
GenomeDataStructure gds;
gds.id = dataset->getAttributeValue<int>("id");
gds.name = dataset->getChild("title").getValue();
gds.pathMap = dataPath+dataset->getChild("map").getValue();
gds.pathBases = dataPath+dataset->getChild("bases").getValue();
mDataStructure.push_back( gds );
console() << " GenomeDataStructure : " << gds.name << " " << gds.pathMap << " " << gds.pathBases << std::endl;
}
}
示例9: setup
void XMLTestApp::setup()
{
XmlTree doc( loadFile( getAssetPath( "library.xml" ) ) );
XmlTree musicLibrary( doc.getChild( "library" ) );
for( XmlTree::ConstIter item = doc.begin("library/album"); item != doc.end(); ++item ) {
console() << "Node: " << item->getTag() << " Value: " << item->getValue() << endl;
}
for( XmlTree::ConstIter track = doc.begin("library/album/track"); track != doc.end(); ++track )
console() << track->getValue() << endl;
assert( (musicLibrary / "album")["musician"] == "John Coltrane" );
// test that /one/two is equivalent to one/two
vector<string> noLeadingSeparator, leadingSeparator;
for( XmlTree::ConstIter track = doc.begin("library/album/track"); track != doc.end(); ++track )
noLeadingSeparator.push_back( track->getValue() );
for( XmlTree::ConstIter track = doc.begin("/library/album/track"); track != doc.end(); ++track )
leadingSeparator.push_back( track->getValue() );
assert( noLeadingSeparator == leadingSeparator );
XmlTree firstAlbum = doc.getChild( "library/album" );
for( XmlTree::Iter child = firstAlbum.begin(); child != firstAlbum.end(); ++child ) {
console() << "Tag: " << child->getTag() << " Value: " << child->getValue() << endl;
}
console() << doc.getChild( "library/owner/city" );
XmlTree ownerCity = doc.getChild( "///library/////owner/city" );
console() << "Path: " << ownerCity.getPath() << " Value: " << ownerCity.getValue() << std::endl;
console() << doc;
console() << findTrackNamed( doc.getChild( "library" ), "Wolf" );
// Whoops - assignment by value doesn't modifying the original XmlTree
XmlTree firstTrackCopy = doc.getChild( "/library/album/track" );
firstTrackCopy.setValue( "Replacement name" );
console() << doc.getChild( "/library/album/track" ) << std::endl;
XmlTree &firstTrackRef = doc.getChild( "/library/album/track" );
firstTrackRef.setValue( "Replacement name" );
console() << doc.getChild( "/library/album/track" ) << std::endl;
XmlTree albumCopy = copyFirstAlbum( doc / "library" );
console() << ( albumCopy / "track" ).getPath() << std::endl; // should print 'newRoot/track'
// This code only works in VC2010
/* std::for_each( doc.begin( "library/album" ), doc.end(), []( const XmlTree &child ) {
app::console() << child.getChild( "title" ).getValue() << std::endl;
} );*/
}
示例10: fromXml
void WarpPerspectiveBilinear::fromXml(const XmlTree &xml)
{
WarpBilinear::fromXml(xml);
// get corners
unsigned i = 0;
for(XmlTree::ConstIter child=xml.begin("corner");child!=xml.end();++child) {
float x = child->getAttributeValue<float>("x", 0.0f);
float y = child->getAttributeValue<float>("y", 0.0f);
mWarp->setControlPoint(i, Vec2f(x, y));
i++;
}
}
示例11: readSettings
WarpList Warp::readSettings( const DataSourceRef &source )
{
XmlTree doc;
WarpList warps;
// try to load the specified xml file
try {
doc = XmlTree( source );
}
catch( ... ) {
return warps;
}
// check if this is a valid file
bool isWarp = doc.hasChild( "warpconfig" );
if( !isWarp ) return warps;
//
if( isWarp ) {
// get first profile
XmlTree profileXml = doc.getChild( "warpconfig/profile" );
// iterate maps
for( XmlTree::ConstIter child = profileXml.begin( "map" ); child != profileXml.end(); ++child ) {
XmlTree warpXml = child->getChild( "warp" );
// create warp of the correct type
std::string method = warpXml.getAttributeValue<std::string>( "method", "unknown" );
if( method == "bilinear" ) {
WarpBilinearRef warp( new WarpBilinear() );
warp->fromXml( warpXml );
warps.push_back( warp );
}
else if( method == "perspective" ) {
WarpPerspectiveRef warp( new WarpPerspective() );
warp->fromXml( warpXml );
warps.push_back( warp );
}
else if( method == "perspectivebilinear" ) {
WarpPerspectiveBilinearRef warp( new WarpPerspectiveBilinear() );
warp->fromXml( warpXml );
warps.push_back( warp );
}
}
}
return warps;
}
示例12: if
UserArea::UserArea(XmlTree area, PhidgetConnector *pc_)
{
// okay so if theres attributes aren't here, it bugs out it would seem?
pos = Vec2f(area.getAttributeValue<float>( "centerX" ), area.getAttributeValue<float>( "centerY" ));
angle = area.getAttributeValue<float>( "angle" );
key = area.getAttributeValue<char>( "key" );
// this should be loading from the XML.
background = "area_background.png";
// there is some serious abstracting to be done here
string activeArea_str = "active_area.png";
bg_img.load(background);
activeArea_img.load(activeArea_str);
// really, still? hmmm
// mTexture = gl::Texture( loadImage( loadResource( background ) ) );
vector<string> videos;
for( XmlTree::Iter child = area.begin(); child != area.end(); ++child)
{
if ( child->getTag() == "video" )
videos.push_back(child->getValue());
else if ( child->getTag() == "button" )
{
XmlTree b = *child;
//buttons.push_back(Button::Button(b/*, &UserArea::nextMovie*/));
buttons.push_back(TwoStateButton(b));
buttonStates.push_back(false);
// void (UserArea::*func)() = &UserArea::nextMovie;
/* void (*func)() = &printTest;
func(); */
}
}
player = VideoPlayer ( Rectf(0, 0, 640, 480), videos);
frameCount = rand() % 628;
pc = pc_;
}
示例13: fromXml
void Warp::fromXml( const XmlTree &xml )
{
mControlsX = xml.getAttributeValue<int>( "width", 2 );
mControlsY = xml.getAttributeValue<int>( "height", 2 );
mBrightness = xml.getAttributeValue<float>( "brightness", 1.0f );
// load control points
mPoints.clear();
for( auto child = xml.begin( "controlpoint" ); child != xml.end(); ++child ) {
float x = child->getAttributeValue<float>( "x", 0.0f );
float y = child->getAttributeValue<float>( "y", 0.0f );
mPoints.push_back( vec2( x, y ) );
}
// load blend params
auto blend = xml.find( "blend" );
if( blend != xml.end() ) {
mExponent = blend->getAttributeValue<float>( "exponent", mExponent );
auto edges = blend->find( "edges" );
if( edges != blend->end() ) {
mEdges.x = edges->getAttributeValue<float>( "left", mEdges.x );
mEdges.y = edges->getAttributeValue<float>( "top", mEdges.y );
mEdges.z = edges->getAttributeValue<float>( "right", mEdges.z );
mEdges.w = edges->getAttributeValue<float>( "bottom", mEdges.w );
}
auto gamma = blend->find( "gamma" );
if( gamma != blend->end() ) {
mGamma.x = gamma->getAttributeValue<float>( "red", mGamma.x );
mGamma.y = gamma->getAttributeValue<float>( "green", mGamma.y );
mGamma.z = gamma->getAttributeValue<float>( "blue", mGamma.z );
}
auto luminance = blend->find( "luminance" );
if( luminance != blend->end() ) {
mLuminance.x = luminance->getAttributeValue<float>( "red", mLuminance.x );
mLuminance.y = luminance->getAttributeValue<float>( "green", mLuminance.y );
mLuminance.z = luminance->getAttributeValue<float>( "blue", mLuminance.z );
}
}
// reconstruct warp
mIsDirty = true;
}
示例14: init
void License::init( XmlTree &doc )
{
if( doc.hasChild( "License" ))
{
XmlTree xmlLicense = doc.getChild( "License" );
string product = xmlLicense.getAttributeValue<string>( "Product", "" );
string key = xmlLicense.getAttributeValue<string>( "Key" , "" );
setProduct( product );
setKeyPath( getAssetPath( key ));
for( XmlTree::Iter child = xmlLicense.begin(); child != xmlLicense.end(); ++child )
{
if( child->getTag() == "Server" )
{
string server = child->getAttributeValue<string>( "Name" );
addServer( server );
}
}
}
}
示例15: if
TwoStateButton::TwoStateButton(XmlTree xml)
{
pos.x = xml.getAttributeValue<float>( "posX" );
pos.y = xml.getAttributeValue<float>( "posY" );
float angle = xml.getAttributeValue<float>( "angle" );
device = xml.getAttributeValue<int>( "device" );
sensor = xml.getAttributeValue<int>( "sensor" );
for( XmlTree::Iter img = xml.begin(); img != xml.end(); ++img)
{
if (img->getAttributeValue<string>( "id" ) == "active")
{
active = Image(img->getValue(), pos);
}
else if (img->getAttributeValue<string>( "id" ) == "inactive")
{
inactive = Image(img->getValue(), pos);
}
}
active.setRotation(angle);
inactive.setRotation(angle);
}