本文整理汇总了C++中XmlTree::hasChild方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlTree::hasChild方法的具体用法?C++ XmlTree::hasChild怎么用?C++ XmlTree::hasChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlTree
的用法示例。
在下文中一共展示了XmlTree::hasChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getThemeColor
ci::ColorA QTimeline::getThemeColor( XmlTree tree, string tag )
{
ColorA col;
if ( tree.hasChild( tag ) )
{
tree = tree.getChild(tag);
col = ColorA( tree.getAttributeValue<float>("r"),
tree.getAttributeValue<float>("g"),
tree.getAttributeValue<float>("b"),
tree.getAttributeValue<float>("a") );
}
return col;
}
示例2: 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;
}
示例3: 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 );
}
}
}
}
示例4: loadLevelFromFile
void Level::loadLevelFromFile(string pathToLevel)
{
// root
id = pathToLevel;
string realPath = "levels/" + pathToLevel;
realPath = getAssetPath(realPath).string();
XmlTree doc((loadFile(realPath)));
XmlTree root = doc.getChild("level");
// width + height
width = root.getChild("width").getValue<int>();
height = root.getChild("height").getValue<int>();
Map.resize(width, vector<int>(height, -1));
// hero start position
int hx = root.getChild("heroX").getValue<int>();
int hy = root.getChild("heroY").getValue<int>();
hero.position.set(hx * TILESIZE, hy * TILESIZE);
// antenna
int ax = root.getChild("antennaX").getValue<int>();
int ay = root.getChild("antennaY").getValue<int>();
antennaPosition.set(ax * TILESIZE, ay * TILESIZE);
// level-data
stringstream stream;
stream << root.getChild("data").getValue();
int index = 0;
while (stream.good() && index < width * height) {
int tileId;
stream >> tileId;
setTileAtPosition(index, tileId);
index++;
}
// attractors
if (root.hasChild("attractors")) {
XmlTree firstAttractor = root.getChild("attractors");
for (XmlTree::Iter child = firstAttractor.begin(); child != firstAttractor.end(); child++) {
float x = child->getChild("x").getValue<float>();
float y = child->getChild("y").getValue<float>();
Attractor* attractor = new Attractor(x, y);
attractor->autoConnectTime = child->getChild("autoConnectTime").getValue<float>(attractor->autoConnectTime);
attractor->autoDisconnectTime = child->getChild("autoDisconnectTime").getValue<float>();
attractor->autoConnectRadius = child->getChild("autoConnectRadius").getValue<float>();
attractor->connectTimeout = child->getChild("connectTimeout").getValue<float>();
attractor->attractForce = child->getChild("attractForce").getValue<float>(attractor->attractForce);
attractor->maxAttractForce = child->getChild("maxAttractForce").getValue<float>(attractor->maxAttractForce);
addConnector(attractor);
}
}
// detractors
if (root.hasChild("detractors")) {
XmlTree firstDetractor = root.getChild("detractors");
for (XmlTree::Iter child = firstDetractor.begin(); child != firstDetractor.end(); child++) {
float x = child->getChild("x").getValue<float>();
float y = child->getChild("y").getValue<float>();
Detractor* detractor = new Detractor(x, y);
detractor->autoConnectTime = child->getChild("autoConnectTime").getValue<float>(detractor->autoConnectTime);
detractor->autoDisconnectTime = child->getChild("autoDisconnectTime").getValue<float>();
detractor->autoConnectRadius = child->getChild("autoConnectRadius").getValue<float>();
detractor->connectTimeout = child->getChild("connectTimeout").getValue<float>();
detractor->bounceForce = child->getChild("bounceForce").getValue<float>(detractor->bounceForce);
detractor->maxBounceForce = child->getChild("maxBounceForce").getValue<float>(detractor->maxBounceForce);
addConnector(detractor);
}
}
}