00001 #ifndef CSXMLHelperTinyXML_H 00002 #define CSXMLHelperTinyXML_H 00003 00004 #ifdef WIN32 00005 #pragma warning(disable : 4786 ) 00006 #endif 00007 00008 #include "CSLog.h" 00009 #include <map> 00010 #include <string> 00011 #include <iostream.h> 00012 00013 #include "tinyxml.h" 00014 00015 typedef std::map<std::string, std::string> EntityMap; 00016 00017 class TiFunctionReturn : public TiXmlText 00018 { 00019 public: 00020 TiFunctionReturn (const char * initValue) : TiXmlText (initValue) 00021 { 00022 setType(TiXmlNode::FUNCTION); 00023 } 00024 }; 00025 00026 class ElementDescription 00027 { 00028 public: 00029 std::string elementName; 00030 bool function; 00031 bool count; 00032 bool leadingSlash; 00033 int predicatePos; 00034 ElementDescription() 00035 { 00036 elementName = ""; 00037 function = false; 00038 count = false; 00039 leadingSlash = false; 00040 predicatePos = -1; 00041 } 00042 00043 }; 00044 00045 class XPathDescription 00046 { 00047 public: 00048 std::string id; 00049 }; 00050 00051 class CSXMLHelper 00052 { 00053 private: 00054 EntityMap mEntityMap; 00055 00056 std::string mErrorMessageString; 00057 TiXmlDocument *mXMLdoc; 00058 TiXmlNode *mXMLsource; 00059 00060 int mError; 00061 ElementDescription getElementDescription(std::string &xpath); 00062 TiXmlNode *getNextNode(TiXmlNode *sourceElement, std::string &xpath); 00063 void addEntitiesFromFile(const std::string &filename, const std::string &parentFilename); 00064 00065 TiXmlNode *getXPathResult(const std::string &xpath); 00066 std::string toAscii(const TiXmlNode &node); 00067 int toInt(const TiXmlNode &node); 00068 std::string lookUp(const std::string &key); 00069 std::string findPredicate(const std::string &key); 00070 00071 public: 00072 CSXMLHelper(const std::string &xmlFilename, const std::string &contextNode); 00073 virtual ~CSXMLHelper(); 00074 static const char *CLASS; 00075 virtual std::string getType() {return (std::string) CLASS;} 00076 00077 int getError(void); 00078 std::string getErrorMessage(void); 00079 int getInt(const std::string &xpath); 00080 std::string getString(const std::string &xpath); 00081 }; 00082 00083 #endif CSXMLHelperTinyXML_H