本文整理汇总了C++中XmlTree类的典型用法代码示例。如果您正苦于以下问题:C++ XmlTree类的具体用法?C++ XmlTree怎么用?C++ XmlTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XmlTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xml
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>();
}
}
}
示例2: cutLastExt
Checksum Scenario::load(const string &path) {
Checksum scenarioChecksum;
try {
scenarioChecksum.addFile(path);
checksumValue.addFile(path);
string name= cutLastExt(lastDir(path));
Logger::getInstance().add("Scenario: " + formatString(name), true);
//parse xml
XmlTree xmlTree;
xmlTree.load(path);
const XmlNode *scenarioNode= xmlTree.getRootNode();
const XmlNode *scriptsNode= scenarioNode->getChild("scripts");
for(int i= 0; i<scriptsNode->getChildCount(); ++i){
const XmlNode *scriptNode = scriptsNode->getChild(i);
scripts.push_back(Script(getFunctionName(scriptNode), scriptNode->getText()));
}
}
//Exception handling (conversions and so on);
catch(const exception &e) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
throw runtime_error("Error: " + path + "\n" + e.what());
}
return scenarioChecksum;
}
示例3: if
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?
}
}
}
}
}
示例4: clear
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();
}
示例5: loadObjectFromFile
Object* ObjectLoader::loadObjectFromFile(const char* filename){
Object* object = NULL;
//Leo el archivo y lo parseo en un arbol
XmlTree* xmlTree = XmlParser::parse(string(WindowConnector::getBaseApplicationPath() + filename).c_str());
//***Transformo el arbol en un Object***
XmlTreeNode* root = xmlTree->getRootNode();
//Primiero busco la etiqueta de Object
XmlTreeNode* objectNode = NULL;
for(unsigned int i=0; i < root->getChildNodes().size(); i++){
objectNode = root->getChildNodes()[i];
if(objectNode->getName().compare("Object")==0){
//Cargo el mesh y le seteo los valores del xml
object = initObject(objectNode);
break;
}
}
if(object == NULL){
if(xmlTree != NULL){ delete xmlTree; }
return NULL; //Error
}
//Busco las etiquetas de Mesh y reemplazo los valores del xml
Mesh* mesh = object->getMesh();
if(mesh->getChilds()->size() > 0){
loadMesh(mesh, objectNode);
}
//Busco las etiquetas de Light y las agrego a las luces del objeto
loadLights(object, objectNode);
//Guardo el path en el object
object->setFilename(filename);
delete xmlTree;
return object;
}
示例6: load
void UnitParticleSystemType::load(const XmlNode *particleFileNode, const string &dir, const string &path,
RendererInterface *renderer, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader, string techtreePath) {
try{
XmlTree xmlTree;
std::map<string,string> mapExtraTagReplacementValues;
mapExtraTagReplacementValues["$COMMONDATAPATH"] = techtreePath + "/commondata/";
xmlTree.load(path, Properties::getTagReplacementValues(&mapExtraTagReplacementValues));
loadedFileList[path].push_back(make_pair(parentLoader,parentLoader));
const XmlNode *particleSystemNode= xmlTree.getRootNode();
if(particleFileNode){
// immediate children in the particleFileNode will override the particleSystemNode
particleFileNode->setSuper(particleSystemNode);
particleSystemNode= particleFileNode;
}
UnitParticleSystemType::load(particleSystemNode, dir, renderer,
loadedFileList, parentLoader, techtreePath);
}
catch(const exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
throw megaglest_runtime_error("Error loading ParticleSystem: "+ path + "\n" +e.what());
}
}
示例7: XmlTree
XmlTree* ScaenaAnimationWriter::animationsToXmlTree(list<AnimationDataTransfer*>* animations){
XmlTree* xmlTree = new XmlTree();
XmlTreeNode* rootNode = xmlTree->getRootNode();
// Agrego el tag inicial
XmlTreeNode* safNode = new XmlTreeNode("ScaenaAnimationFile", rootNode);
rootNode->addChild(safNode);
// Agrego todas las animaciones
list<AnimationDataTransfer*>::iterator animIt = animations->begin();
while( animIt != animations->end() ){
// Agrego el tag de animacion
XmlTreeNode* animationNode = new XmlTreeNode("Animation", safNode);
safNode->addChild(animationNode);
// Agrego como atributo el nombre de la animacion
AnimationDataTransfer* animationDataTransfer = *animIt;
animationNode->addAttribute(new XmlNodeAttribute("Name", animationDataTransfer->name));
// Agrego cada uno de los keyframes
list<KeyFrameDataTransfer*>::iterator keyIt = animationDataTransfer->keyframes->begin();
while(keyIt != animationDataTransfer->keyframes->end()){
keyFrameToXmlTree(animationNode, *keyIt);
++keyIt;
}
++animIt;
}
return xmlTree;
}
示例8: mCaseSensitive
XmlTree::ConstIter::ConstIter( const XmlTree &root, const string &filterPath, bool caseSensitive, char separator )
: mCaseSensitive( caseSensitive )
{
mFilter = split( filterPath, separator );
// we ignore a leading separator so that "/one/two" is equivalent to "one/two"
if( ( ! filterPath.empty() ) && ( filterPath[0] == separator ) && ( ! mFilter.empty() ) )
mFilter.erase( mFilter.begin() );
if( mFilter.empty() ) { // empty filter means nothing matches
setToEnd( &root.getChildren() );
return;
}
for( vector<string>::const_iterator filterComp = mFilter.begin(); filterComp != mFilter.end(); ++filterComp ) {
if( mIterStack.empty() ) // first item
mSequenceStack.push_back( &root.getChildren() );
else
mSequenceStack.push_back( &(*mIterStack.back())->getChildren() );
Container::const_iterator child = findNextChildNamed( *mSequenceStack.back(), mSequenceStack.back()->begin(), *filterComp, mCaseSensitive );
if( child != (mSequenceStack.back())->end() )
mIterStack.push_back( child );
else { // failed to find an item that matches this part of the filter; mark as finished and return
setToEnd( &root.getChildren() );
return;
}
}
}
示例9: throw
XmlTree::ExcChildNotFound::ExcChildNotFound( const XmlTree &node, const string &childPath ) throw()
{
#if defined( CINDER_MSW )
sprintf_s( mMessage, "Could not find child: %s for node: %s", childPath.c_str(), node.getPath().c_str() );
#else
sprintf( mMessage, "Could not find child: %s for node: %s", childPath.c_str(), node.getPath().c_str() );
#endif
}
示例10: Load
bool ObjectRenderer::Load(string name){
char filename[256];
XmlTree tree;
sprintf(filename,"Worlds/Objects/%s.xml",name.c_str());
if(FileFinder::Find(filename)){
tree.LoadFromFile(FileFinder::GetCStr());
}
return Load(&tree);
}
示例11: 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;
}
}
示例12: 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);
}
}
}
示例13: FbxModelLoader
bool GenerationProcessor::processScaenaAnimationFile(string& inAnimationFile, string& outAnimationFile, string& keyFrameFBXFile, string& animationName, float keyDuration){
//Parseo el archivo de modelo
FbxModelLoader* fbxLoader = new FbxModelLoader();
ModelDataTransfer* modelDataTransfer = fbxLoader->loadModel(keyFrameFBXFile.c_str());
KeyFrameDataTransfer* keyframe = getKeyFrameData(modelDataTransfer, 0);
keyframe->animationTime = keyDuration;
delete fbxLoader;
// Si tengo SAF de entrada, lo cargo para agregarle la nueva animacion o keyframe
if(!inAnimationFile.empty()){
Logger::getInstance()->logInfo(new Log("Procesando el SAF de salida..."));
//Leo el archivo y lo parseo en un arbol
XmlTree* xmlTree = XmlParser::parse(inAnimationFile.c_str());
XmlTreeNode* rootNode = xmlTree->getRootNode();
// Busco el nodo de archivo SAF
XmlTreeNode* safNode = rootNode->searchDirectChild("ScaenaAnimationFile", 0);
if(safNode != NULL){
// Busco si alguna animacion tiene el mismo nombre que la indicada, si no creo una nueva
XmlTreeNode* animationNode = searchForAnimation(safNode, animationName);
if(animationNode == NULL){
animationNode = new XmlTreeNode("Animation", safNode);
animationNode->addAttribute(new XmlNodeAttribute("Name", animationName));
safNode->addChild(animationNode);
}
// Agrego el keyframe
XmlTreeNode* keyFrameNode = new XmlTreeNode("KeyFrame", animationNode);
keyFrameNode->addAttribute(new XmlNodeAttribute("DurationInSeconds", StringUtils::toString(keyframe->animationTime)));
ScaenaAnimationWriter::skeletonToXmlTree(keyFrameNode, keyframe->getRootSkeleton());
animationNode->addChild(keyFrameNode);
// Grabo en el archivo SAF (REVIEW: podria dejar de escribir cada cambio en disco)
XmlParser::writeXmlToFile(outAnimationFile.c_str(), xmlTree);
}
else{
throw new AnimationLoadException("No se puede procesar el SAF de entrada");
}
}
// Si no tengo SAF de entrada, creo la estructura de cero
else{
list<AnimationDataTransfer*> animations;
AnimationDataTransfer* animation = new AnimationDataTransfer();
animation->name = animationName;
animation->keyframes->push_back(keyframe);
animations.push_back(animation);
// Escribo el SAF e indico que ahora tengo archivo de entrada
ScaenaAnimationWriter::writeAnimation(outAnimationFile, &animations);
inAnimationFile = outAnimationFile;
}
delete modelDataTransfer;
delete keyframe;
return true;
}
示例14: Load
bool World::Load(string name){
char filename[256];
XmlTree tree;
sprintf(filename,"Worlds/%s.xml",name.c_str());
if(FileFinder::Find(filename)){
if(tree.LoadFromFile(FileFinder::GetString())){
return Load(&tree);
}
}
return false;
}
示例15: 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();
}