* the problem: application may be launched using python executable,
* to use environment variable (at least for the current moment)
*/
- if (prefix.empty()) {
- char* anEnv = getenv("NEW_GEOM_CONFIG_FILE");
- if (anEnv) {
- prefix = std::string(anEnv);
- }
- }
+ if (prefix.empty())
+ prefix = pluginConfigFile();
+
#ifdef WIN32
prefix += "\\";
#else
xmlFreeDoc(myXmlDoc);
}
+std::string Config_XMLReader::pluginConfigFile()
+{
+ std::string aValue;
+ char* anEnv = getenv("PLUGINS_CONFIG_FILE");
+ if (anEnv) {
+ aValue = std::string(anEnv);
+ }
+ return aValue;
+}
+
void Config_XMLReader::readAll()
{
xmlNodePtr aRoot = findRoot();
}
}
+void Config_XMLReader::cleanup(xmlNodePtr)
+{
+ // do nothing;
+}
+
bool Config_XMLReader::processChildren(xmlNodePtr aNode)
{
return true;
if (processChildren(aNode)) {
readRecursively(aNode);
}
+ cleanup(aNode);
}
}
return result;
}
-void Config_XMLReader::storeAttribute(xmlNodePtr theNode, const char* theAttribute)
+void Config_XMLReader::storeAttribute(xmlNodePtr theNode, const char* theAttribute, bool doClean)
{
std::string aKey = getNodeName(theNode) + ":" + std::string(theAttribute);
std::string aValue = getProperty(theNode, theAttribute);
- if(!aValue.empty()) {
+ if (doClean || !aValue.empty()) {
myCachedAttributes[aKey] = aValue;
}
}
}
return result;
}
+
+bool Config_XMLReader::cleanupAttribute(xmlNodePtr theNode, const char* theNodeAttribute)
+{
+ return cleanupAttribute(getNodeName(theNode).c_str(), theNodeAttribute);
+}
+
+bool Config_XMLReader::cleanupAttribute(const char* theNodeName, const char* theNodeAttribute)
+{
+ std::string aKey = std::string(theNodeName) + ":" + std::string(theNodeAttribute);
+ bool result = false;
+ std::map<std::string, std::string>::iterator anEntry = myCachedAttributes.find(aKey);
+ if( anEntry != myCachedAttributes.end()) {
+ myCachedAttributes.erase(anEntry);
+ result = true;
+ }
+ return result;
+}