5 #include <vrecko/Export>
18 #include <osgDB/DynamicLibrary>
25 #include <xercesc/parsers/AbstractDOMParser.hpp>
26 #include <xercesc/dom/DOMErrorHandler.hpp>
27 #include <xercesc/dom/DOMBuilder.hpp>
28 #include <xercesc/util/XMLString.hpp>
30 #if defined(XERCES_NEW_IOSTREAMS)
38 #define CREATOR_FILENAME_ID_SIMPLE "_XMLCreatorFileName_"
39 #define CREATOR_FILENAME_ID L ## "_XMLCreatorFileName_"
44 class VRECKO_EXPORT World;
45 class VRECKO_EXPORT Scene;
46 class VRECKO_EXPORT EnvironmentObject;
68 bool handleError(
const XERCES_CPP_NAMESPACE_QUALIFIER DOMError& domError);
125 bool loadMultipleFiles(std::vector<std::string> &files,
float *loadingPosition, std::string *loadingCategory,
VRECKOMutex load_Mutex);
128 bool loadOld(
const char *configName,
float *loadingPosition, std::string *loadingCategory,
VRECKOMutex load_Mutex);
138 int save(
const char *configName,
const char *originalSceneFile,
float *savingPosition, std::string *savingCategory,
VRECKOMutex save_Mutex);
145 static XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *findNodeByName(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *
node,
const std::string &nodeName,
int level = 1);
148 static XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *findChildByName(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *
node,
const XMLCh* xChChildNodeName,
int level = 1);
152 static void getStringValue(std::string &returnValue, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *
node,
const std::string &nodeName,
const std::string &failReturn =
"",
int level = 1);
156 static const XMLCh* getStringValueXCh(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *parentNode,
const XMLCh* childNodeName);
160 static bool getBoolValue(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *
node,
const std::string &nodeName,
bool failReturn =
false,
int level = 1);
164 static int getIntValue(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *
node,
const std::string &nodeName,
int failReturn = 0,
int level = 1);
168 static long int getLongIntValue(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *
node,
const std::string &nodeName,
long int failReturn = 0,
int level = 1);
172 static float getFloatValue(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *
node,
const std::string &nodeName,
float failReturn = 0.0,
int level = 1);
176 static double getDoubleValue(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *
node,
const std::string &nodeName,
double failReturn = 0.0,
int level = 1);
180 static void getVec2Value(osg::Vec2 &returnValue, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *
node,
const std::string &nodeName,
const osg::Vec2 &failReturn = osg::Vec2(0.0, 0.0),
int level = 1);
184 static void getVec3Value(osg::Vec3 &returnValue, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *node,
const std::string &nodeName,
const osg::Vec3 &failReturn = osg::Vec3(0.0, 0.0, 0.0),
int level = 1);
188 static void getVec4Value(osg::Vec4 &returnValue, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *node,
const std::string &nodeName,
const osg::Vec4 &failReturn = osg::Vec4(0.0, 0.0, 0.0, 0.0),
int level = 1);
192 static void getMatrixValue(osg::Matrix &returnValue, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *node,
const std::string &nodeName,
const osg::Matrix &failReturn = osg::Matrix::identity(),
int level = 1);
196 static void getQuatValue(osg::Quat &returnValue, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *node,
const std::string &nodeName,
const osg::Quat &failReturn = osg::Quat(),
int level = 1);
205 static bool getAttribStringValue(std::string &returnValue, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *node,
const std::string &attribName,
const std::string &failReturn =
"");
209 static XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *createElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *pDocNode,
const std::string &elementName);
212 static XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *appendElementAndStringValue(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *pDocNode, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *pParentNode,
const std::string &elementName,
const std::string &value);
215 static XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *appendElementAndBoolValue(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *pDocNode, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *pParentNode,
const std::string &elementName,
bool value);
218 static XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *appendElementAndIntValue(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *pDocNode, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *pParentNode,
const std::string &elementName,
int value);
221 static XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *appendElementAndLongIntValue(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *pDocNode, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *pParentNode,
const std::string &elementName,
long int value);
224 static XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *appendElementAndFloatValue(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *pDocNode, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *pParentNode,
const std::string &elementName,
float value);
227 static XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *appendElementAndDoubleValue(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *pDocNode, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *pParentNode,
const std::string &elementName,
double value);
230 static XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *appendElementAndVec2Value(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *pDocNode, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *pParentNode,
const std::string &elementName, osg::Vec2 value);
233 static XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *appendElementAndVec3Value(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *pDocNode, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *pParentNode,
const std::string &elementName, osg::Vec3 value);
236 static XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *appendElementAndVec4Value(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *pDocNode, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *pParentNode,
const std::string &elementName, osg::Vec4 value);
239 static XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *appendElementAndMatrixValue(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *pDocNode, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *pParentNode,
const std::string &elementName, osg::Matrix value);
242 static XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *appendElementAndQuatValue(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *pDocNode, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *pParentNode,
const std::string &elementName, osg::Quat value);
248 bool loadScene(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *sceneNode, AbInitVector &abilitiesToInitialize);
250 bool loadDevice(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *deviceNode);
252 bool loadAbilities(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *eoNode,
bool bLoadingWorldAbility, AbInitVector &abilitiesToInitialize);
256 bool loadEvent(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *eventNode);
259 void saveEnvironmentObject(
const char *originalSceneFile, XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *pDocNode, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *parentNode,
vrecko::EnvironmentObject *pEO);
261 void saveChildren(
const char *originalSceneFile, XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *pDocNode, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *eoNode,
vrecko::EnvironmentObject *pEO);
267 void analyzeXMLTree(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *pNode);
270 unsigned int getNodeCountByName(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *pNode,
const std::string &nodeName);
276 XERCES_CPP_NAMESPACE_QUALIFIER DOMBuilder * createParser();
282 void releaseParser(XERCES_CPP_NAMESPACE_QUALIFIER DOMBuilder * parser);
287 XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *loadXMLDocument(
const char *configName, XERCES_CPP_NAMESPACE_QUALIFIER DOMBuilder *parser);
292 bool findRealFile(
char *outputFileWithPath,
const char* inputFile,
const char* currentDir, std::vector<std::string> *requiredBy = NULL,
bool bOutputErrors =
true);
295 void removeUnnecessaryWhitespace(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *pNode);
298 bool saveXMLDocument(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *pDoc,
const char *strPath);
303 XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *mergeFiles(std::vector<std::string> &files, XERCES_CPP_NAMESPACE_QUALIFIER DOMBuilder *parser);
306 bool processNodeToMergeRecursive(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *mainNode,
307 XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *secNode,
const XMLCh *xChConfigFile);
310 bool removeAttribRecursive(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *node,
const XMLCh *attribName);
335 XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *findDuplicateNode(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *mainParentNode, XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *origNode);
340 bool getNodeIdentification(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *node, FDNNodeType nodeType, XMLCh *strId1, XMLCh *strId2);
343 bool addCreatorInfoRecursive(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *node,
const XMLCh *xChConfigFile);
370 bool incrementActNode();
373 HANDLE loadsave_Mutex;
382 XERCES_CPP_NAMESPACE_QUALIFIER AbstractDOMParser::ValSchemes valScheme;
385 bool schemaFullChecking;
406 fUnicodeForm = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toTranscode);
411 XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&fUnicodeForm);
433 #define strToXerces(str) XercesStr(str).unicodeForm()