-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Config_XMLReader.h>
static const char FSEP = '/';
#endif
-Config_XMLReader::Config_XMLReader(const std::string& theXmlFileName)
+Config_XMLReader::Config_XMLReader(const std::string& theXmlFileName, bool isXMLContent)
: myXmlDoc(NULL), myRootFileName(theXmlFileName)
{
- myDocumentPath = findConfigFile(theXmlFileName);
- if (myDocumentPath.empty()) {
- Events_InfoMessage("Config_XMLReader", "Unable to open %1").arg(theXmlFileName).send();
+ isFromMemory = isXMLContent;
+ if (!isXMLContent) {
+ myDocumentPath = findConfigFile(theXmlFileName);
+ if (myDocumentPath.empty()) {
+ Events_InfoMessage("Config_XMLReader", "Unable to open %1").arg(theXmlFileName).send();
+ }
}
}
xmlFreeDoc(myXmlDoc);
}
+// LCOV_EXCL_START
std::string Config_XMLReader::resourcesConfigFile()
{
std::string aValue;
aValue = std::string(anEnv) +
FSEP + "share" + FSEP + "salome" + FSEP + "resources" + FSEP + "shaper";
} else {
- anEnv = getenv("OPENPARTS_ROOT_DIR");
+ anEnv = getenv("CADBUILDER_ROOT_DIR");
if (anEnv) {
aValue = std::string(anEnv) + FSEP + "resources";
}
aValue = std::string(anEnv) +
FSEP + "share" + FSEP + "salome" + FSEP + "resources" + FSEP + "shaper";
} else {
- anEnv = getenv("OPENPARTS_ROOT_DIR");
+ anEnv = getenv("CADBUILDER_ROOT_DIR");
if (anEnv) {
aValue = std::string(anEnv) + FSEP + "plugins";
}
}
return aValue;
}
+// LCOV_EXCL_STOP
std::string Config_XMLReader::findConfigFile(const std::string theFileName, const int theFindIndex)
{
if (aSolution == 1)
anEnvName<<"SHAPER_ROOT_DIR";
else if (aSolution == 2)
- anEnvName<<"OPENPARTS_ROOT_DIR";
+ anEnvName<<"CADBUILDER_ROOT_DIR";
else
- anEnvName<<"OPENPARTS_PLUGINS_DIR";
+ anEnvName<<"CADBUILDER_ROOT_DIR";
char* anEnv = getenv(anEnvName.str().c_str());
if (!anEnv)
continue;
if (aSolution > 2) { // there may be several paths separated by ";" symbol
+// LCOV_EXCL_START
std::string anEnvPart = anEnv;
size_t aPosStart = 0, aPosEnd;
for(int aSubNum = 0; aSubNum < aSolution - 3; aSubNum++) {
aPosEnd = anEnvPart.find(';', aPosStart);
aFileName = anEnvPart.substr(aPosStart,
aPosEnd == std::string::npos ? aPosEnd : aPosEnd - aPosStart) + FSEP;
+// LCOV_EXCL_STOP
} else {
aFileName = std::string(anEnv) + FSEP;
}
if (aResultIndex == theFindIndex)
return aFileName;
aResultIndex++;
- if (aSolution == 1) // don't allow SHAPER and OpenParts paths treated simultaneously
+ if (aSolution == 1) // don't allow SHAPER and CADBuilder paths treated simultaneously
aSolution++;
}
}
void Config_XMLReader::readAll()
{
+ if (isFromMemory) {
+ myXmlDoc = xmlParseMemory(myRootFileName.c_str(), (int)myRootFileName.length());
+ xmlNodePtr aRoot = xmlDocGetRootElement(myXmlDoc);
+ readRecursively(aRoot);
+ return;
+ }
+
// to load external modules dependencies (like GEOM for Connector Feature)
Config_ModuleReader::loadScript("salome.shaper.initConfig", false);
// do nothing;
}
-bool Config_XMLReader::processChildren(xmlNodePtr aNode)
+// LCOV_EXCL_START
+bool Config_XMLReader::processChildren(xmlNodePtr /*aNode*/)
{
return true;
}
+// LCOV_EXCL_STOP
xmlNodePtr Config_XMLReader::findRoot(const std::string theDocumentPath)
{
}
}
+// LCOV_EXCL_START
xmlNodePtr Config_XMLReader::node(void* theNode)
{
return static_cast<xmlNodePtr>(theNode);
}
+// LCOV_EXCL_STOP
std::string Config_XMLReader::getNodeName(xmlNodePtr theNode)
{
}
}
+// LCOV_EXCL_START
std::string Config_XMLReader::restoreAttribute(xmlNodePtr theNode, const char* theAttribute)
{
return restoreAttribute(getNodeName(theNode).c_str(), theAttribute);
}
+// LCOV_EXCL_STOP
std::string Config_XMLReader::restoreAttribute(const char* theNodeName, const char* theAttribute)
{
return result;
}
+// LCOV_EXCL_START
const char* Config_XMLReader::encoding() const
{
return (const char*) myXmlDoc->encoding;
-}
\ No newline at end of file
+}
+// LCOV_EXCL_STOP