本文整理汇总了C++中XmlTree::getChild方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlTree::getChild方法的具体用法?C++ XmlTree::getChild怎么用?C++ XmlTree::getChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlTree
的用法示例。
在下文中一共展示了XmlTree::getChild方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例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: 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();
}
示例4: loadXml
void cApp::loadXml(){
fs::path p = "gui.xml";
if( !fs::is_empty( p ) ){
XmlTree xml( loadFile( p ) );
XmlTree mn = xml.getChild("gui_setting/main");
frame = (mn/"frame").getValue<int>();
bOrtho = (mn/"ortho").getValue<bool>();
Ramses::globalScale = (mn/"xyz_global_scale").getValue<float>();
//Ramses::boxelx = (mn/"r_resolution").getValue<float>();
//Ramses::boxely = (mn/"theta_resolution").getValue<float>();
XmlTree sim = xml.getChild( "gui_setting/simType_" + to_string(simType) );
for( int i=0; i<rms.size(); i++){
Ramses & r = rms[i];
string name = Ramses::prm[i];
XmlTree prm = sim.getChild(name);
r.bShow = (prm/"show").getValue<bool>();
r.bPolar = (prm/"polar").getValue<bool>(true);
r.bAutoMinMax = (prm/"Auto_Min_Max").getValue<bool>();
r.in_min = (prm/"in_min").getValue<float>();
r.in_max = (prm/"in_max").getValue<float>();
r.extrude = (prm/"z_extrude").getValue<float>();
r.xoffset = (prm/"x_offset").getValue<float>();
r.yoffset = (prm/"y_offset").getValue<float>();
r.zoffset = (prm/"z_offset").getValue<float>();
r.scale = (prm/"xy_scale").getValue<float>();
r.eStretch = (prm/"log").getValue<float>();
}
}
}
示例5: XmlTree
PlistReader::PlistReader()
{
XmlTree plist = XmlTree(loadResource( "RECIPES.plist" ) );
console() << "this is the tag name... " << plist.getTag() << "IS THIS A DOC ELEMENT OR WAHAT???? " << plist.isDocument() << endl;
try {
root = plist.getChild("plist");
} catch(XmlTree::Exception e){
console() << "darn" << endl;
}
//trace(root);
parseRecipes();
}
示例6: 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(""));
}
}
}
}
示例7: 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;
}
示例8: 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;
}
示例9: 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 );
}
}
}
}
示例10: load
void Config::load(fs::path filePath)
{
try
{
XmlTree doc(loadFile(filePath));
XmlTree node;
node = doc.getChild("general");
for(std::vector<ConfigParam>::iterator it = mConfigParameters.begin(); it!=mConfigParameters.end(); ++it)
{
switch(it->type)
{
case _NODE:
node = doc.getChild(it->name);
break;
case _BOOL:
*((bool*)it->param) = node.getChild(it->name).getValue<bool>();
break;
case _FLOAT:
*((float*)it->param) = node.getChild(it->name).getValue<float>();
break;
case _DOUBLE:
*((double*)it->param) = node.getChild(it->name).getValue<double>();
break;
case _INT:
*((int*)it->param) = node.getChild(it->name).getValue<int>();
break;
case _VEC3F:
(*((Vec3f*)it->param)).x = node.getChild(it->name).getAttributeValue<float>("x");
(*((Vec3f*)it->param)).y = node.getChild(it->name).getAttributeValue<float>("y");
(*((Vec3f*)it->param)).z = node.getChild(it->name).getAttributeValue<float>("z");
break;
case _QUATF:
(*((Quatf*)it->param)).w = node.getChild(it->name).getAttributeValue<float>("w");
(*((Quatf*)it->param)).v.x = node.getChild(it->name).getAttributeValue<float>("x");
(*((Quatf*)it->param)).v.y = node.getChild(it->name).getAttributeValue<float>("y");
(*((Quatf*)it->param)).v.z = node.getChild(it->name).getAttributeValue<float>("z");
break;
case _COLOR:
(*((Color*)it->param)).r = node.getChild(it->name).getAttributeValue<float>("r");
(*((Color*)it->param)).g = node.getChild(it->name).getAttributeValue<float>("g");
(*((Color*)it->param)).b = node.getChild(it->name).getAttributeValue<float>("b");
break;
case _COLORA:
(*((ColorA*)it->param)).r = node.getChild(it->name).getAttributeValue<float>("r");
(*((ColorA*)it->param)).g = node.getChild(it->name).getAttributeValue<float>("g");
(*((ColorA*)it->param)).b = node.getChild(it->name).getAttributeValue<float>("b");
(*((ColorA*)it->param)).a = node.getChild(it->name).getAttributeValue<float>("a");
break;
case _STRING:
*((std::string*)it->param) = node.getChild(it->name).getValue<std::string>();
break;
}
}
}
catch(Exception e) {
std::cout << "ERROR loading/reading config file." << std::endl;
}
}
示例11: 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);
}
}
}
示例12: parseSettings
void AppModel::parseSettings(XmlTree _root){
XmlTree t = _root.getChild("dict");
// is key background?
// load background
// is key user areas?
// loop children
// create userareamodel
// set x, y, r
// is it a button?
UserAreaModel uam;
TouchSensorModel tsm;
string topLevelKey = "";
for( XmlTree::Iter child = t.begin(); child != t.end(); ++child ){
string tagType = child->getTag();
console() << "tag: " << tagType << endl;
if(tagType.compare("key")==0){
topLevelKey = child->getValue();
console() << "topkey: " << topLevelKey << endl;
} else {
if(tagType.compare("string")==0 || tagType.compare("false")==0 || tagType.compare("true")==0){
if(topLevelKey.compare("background")==0){
backgroundPath = child->getValue();
} else if(topLevelKey.compare("button")==0){
console() << "Button Value::: " << tagType << "!!!!!" << endl;
buttonPath = child->getValue();
} else if(topLevelKey.compare("fullscreen")==0){
console() << "FULLSCREEN VALUE:::: " << tagType << "!!!!!!!!!" << endl;
if(tagType.compare("true")==0) isFullScreen = true;
}
} else if(tagType.compare("dict")==0){
// this is either the user areas, or the sensor boards
// depending on the toplevelkey
XmlTree t2 = *child;
string midLevelKey = "";
for( XmlTree::Iter grandchild = t2.begin(); grandchild != t2.end(); ++grandchild ){
console() << grandchild->getTag() << " ::: " << grandchild->getValue() << endl;
string gcTagType = grandchild->getTag();
if(gcTagType.compare("key")==0){
midLevelKey = grandchild->getValue();
} else {
console() << "GRANCHILDLEVEL: " << grandchild->getValue() << " : " << midLevelKey << ", " << topLevelKey << endl;
if(topLevelKey.compare("User Areas")==0){
uam = UserAreaModel();
} else if(topLevelKey.compare("Sensor Boards")==0){
tsm = TouchSensorModel();
}
// this should always be a dict (either a list of nums and strings for user areas, or nums for sensor boards)
XmlTree t3 = *grandchild;
string bottomLevelKey = "";
for( XmlTree::Iter baby = t3.begin(); baby != t3.end(); ++baby ){
string babyTag = baby->getTag();
if(babyTag.compare("key")==0){
bottomLevelKey = baby->getValue();
} else if(babyTag.compare("dict")!=0){
// console() << "BABY LEVEL: " << baby->getValue() << " : " << bottomLevelKey << " : " << midLevelKey << ", " << topLevelKey << endl;
if(topLevelKey.compare("User Areas")==0){
if(bottomLevelKey.compare("x")==0){
uam.x = atof(baby->getValue().c_str());
} else if(bottomLevelKey.compare("y")==0){
uam.y = atof(baby->getValue().c_str());
} else if(bottomLevelKey.compare("r")==0){
uam.r = atof(baby->getValue().c_str());
}else if(bottomLevelKey.compare("recipe")==0){
uam.recipe = baby->getValue();
}
} else if(topLevelKey.compare("Sensor Boards")==0) {
tsm.sensor = atoi(baby->getValue().c_str());
tsm.keymap = bottomLevelKey[0];
tsm.board = atoi(midLevelKey.c_str());
sensors.push_back(tsm);
}
} else {
if(topLevelKey.compare("User Areas")==0){
uam.name = midLevelKey;
}
XmlTree t4 = *baby;
string easyModeKey = "";
for( XmlTree::Iter zygote = t4.begin(); zygote != t4.end(); ++zygote ){
string zygoteTag = zygote->getTag();
if(zygoteTag.compare("key")==0){
easyModeKey = zygote->getValue();
} else {
// console() << "ZYGOTE LEVEL: " << zygote->getValue() << ": " << easyModeKey << " : " << bottomLevelKey << " : " << midLevelKey << ", " << topLevelKey << endl;
}
}
}
//.........这里部分代码省略.........