Changeset 146 for osgVisual/src
- Timestamp:
- Nov 4, 2010, 8:50:17 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
osgVisual/src/util/visual_util.cpp
r144 r146 25 25 util::~util(void) 26 26 { 27 } 28 29 xmlNode* util::getSceneryXMLConfig(std::string configFilename, xmlDoc*& doc) 30 { 31 doc = NULL; 32 xmlNode *root_element = NULL; 33 34 // Check for valid parameters 35 if(configFilename == "") 36 { 37 OSG_ALWAYS << "ERROR - util::getModuleXMLConfig() : Invalid Configuration Filename!" << std::endl; 38 return NULL; 39 } 40 41 // It is a valid XML document? 42 doc = xmlReadFile(configFilename.c_str(), NULL, 0); 43 if (doc == NULL) 44 { 45 OSG_ALWAYS << "ERROR - util::getModuleXMLConfig() : " << configFilename << " is not a valid XML file!" << std::endl; 46 return NULL; 47 } 48 49 // Get the root element node 50 root_element = xmlDocGetRootElement(doc); 51 52 // If file is a valid osgVisual config file, check all the root xml node and all of it's children of osgvisualconfiguration for the specified module 53 xmlNode* tmpNode = checkXMLNodeChildrenForScenery(root_element); 54 55 if( !tmpNode ) // if no valid node was found: clena up. Otherwise: the caller has to clean up. 56 { 57 xmlFreeDoc(doc); // free the document 58 xmlCleanupParser(); // Free the global variables that may have been allocated by the parser. 59 return NULL; 60 } 61 else 62 return tmpNode; 63 } 64 65 xmlNode* util::checkXMLNodeChildrenForScenery(xmlNode* node) 66 { 67 for (xmlNode *cur_node = node; cur_node; cur_node = cur_node->next) // iterate through all elements 68 { 69 // Is the node the one we are searching for? 70 if (cur_node->type == XML_ELEMENT_NODE) 71 { 72 std::string node_name=reinterpret_cast<const char*>(cur_node->name); 73 if (node_name == "scenery") 74 { 75 OSG_DEBUG << "XML node scenery found" << std::endl; 76 return cur_node; 77 } 78 else // Otherwise: check its children.. 79 { 80 xmlNode* tmp_XmlNode = checkXMLNodeChildrenForScenery(cur_node->children); 81 if(tmp_XmlNode) 82 return tmp_XmlNode; 83 } 84 } // IF NODE TYPE = ELEMENT END 85 86 // Proceed with next node in this loop. 87 } 88 return NULL; 27 89 } 28 90 … … 100 162 // Proceed with next node in this loop. 101 163 } 164 return NULL; 102 165 } 103 166
Note: See TracChangeset
for help on using the changeset viewer.