-/*\r
-Copyright (C) 2006, Stefan Greven.\r
-All Rights Reserved.\r
-\r
-This file is part of GtkRadiant.\r
-\r
-GtkRadiant is free software; you can redistribute it and/or modify\r
-it under the terms of the GNU General Public License as published by\r
-the Free Software Foundation; either version 2 of the License, or\r
-(at your option) any later version.\r
-\r
-GtkRadiant is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-GNU General Public License for more details.\r
-\r
-You should have received a copy of the GNU General Public License\r
-along with GtkRadiant; if not, write to the Free Software\r
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\r
-*/\r
-\r
-#if !defined(INCLUDED_XMLTEXTAGS_H)\r
-#define INCLUDED_XMLTEXTAGS_H\r
-\r
-#include <set>\r
-#include <string/string.h>\r
-#include <vector>\r
-\r
-#include "iscriplib.h"\r
-\r
-#include <libxml/xpath.h>\r
-#include <libxml/xmlwriter.h>\r
-\r
-enum NodeTagType\r
-{\r
- TAG,\r
- EMPTY\r
-};\r
-\r
-enum NodeShaderType\r
-{\r
- SHADER,\r
- TEXTURE\r
-};\r
-\r
-enum TextureType\r
-{\r
- STOCK,\r
- CUSTOM\r
-};\r
-\r
-class XmlTagBuilder\r
-{\r
-private:\r
- CopiedString m_savefilename;\r
- xmlDocPtr doc;\r
- xmlXPathContextPtr context;\r
- xmlNodeSetPtr nodePtr;\r
-\r
- xmlXPathObjectPtr XpathEval(const char* queryString)\r
- {\r
- xmlChar* expression = (xmlChar*)queryString;\r
- xmlXPathObjectPtr result = xmlXPathEvalExpression(expression, context);\r
- return result;\r
- };\r
-\r
- char* GetTagsXpathExpression(char* buffer, const char* shader, NodeTagType nodeTagType)\r
- {\r
- strcpy(buffer, "/root/*/*[@path='");\r
- strcat(buffer, shader);\r
- \r
- switch(nodeTagType)\r
- {\r
- case TAG:\r
- strcat(buffer, "']/tag");\r
- break;\r
- case EMPTY:\r
- strcat(buffer, "']");\r
- };\r
-\r
- return buffer;\r
- }\r
-\r
-public:\r
- XmlTagBuilder();\r
- ~XmlTagBuilder();\r
-\r
- bool CreateXmlDocument();\r
- bool OpenXmlDoc(const char* file, const char* savefile = 0);\r
- bool SaveXmlDoc(const char* file);\r
- bool SaveXmlDoc(void);\r
- bool AddShaderNode(const char* shader, TextureType textureType, NodeShaderType nodeShaderType);\r
- bool DeleteShaderNode(const char* shader);\r
- bool CheckShaderTag(const char* shader);\r
- bool CheckShaderTag(const char* shader, const char* content);\r
- bool AddShaderTag(const char* shader, const char* content, NodeTagType nodeTagType);\r
- bool DeleteTag(const char* tag);\r
- int RenameShaderTag(const char* oldtag, CopiedString newtag);\r
- bool DeleteShaderTag(const char* shader, const char* tag);\r
- void GetShaderTags(const char* shader, std::vector<CopiedString>& tags);\r
- void GetUntagged(std::set<CopiedString>& shaders);\r
- void GetAllTags(std::set<CopiedString>& tags);\r
- void TagSearch(const char* expression, std::set<CopiedString>& paths);\r
-};\r
-\r
-#endif\r
+/*
+ Copyright (C) 2006, Stefan Greven.
+ All Rights Reserved.
+
+ This file is part of GtkRadiant.
+
+ GtkRadiant is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ GtkRadiant is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#if !defined( INCLUDED_XMLTEXTAGS_H )
+#define INCLUDED_XMLTEXTAGS_H
+
+#include <set>
+#include <string/string.h>
+#include <vector>
+
+#include "iscriplib.h"
+
+#include <libxml/xpath.h>
+#include <libxml/xmlwriter.h>
+
+enum NodeTagType
+{
+ TAG,
+ EMPTY
+};
+
+enum NodeShaderType
+{
+ SHADER,
+ TEXTURE
+};
+
+enum TextureType
+{
+ STOCK,
+ CUSTOM
+};
+
+class XmlTagBuilder
+{
+private:
+CopiedString m_savefilename;
+xmlDocPtr doc;
+xmlXPathContextPtr context;
+xmlNodeSetPtr nodePtr;
+
+xmlXPathObjectPtr XpathEval( const char* queryString ){
+ xmlChar* expression = (xmlChar*)queryString;
+ xmlXPathObjectPtr result = xmlXPathEvalExpression( expression, context );
+ return result;
+};
+
+char* GetTagsXpathExpression( char* buffer, const char* shader, NodeTagType nodeTagType ){
+ strcpy( buffer, "/root/*/*[@path='" );
+ strcat( buffer, shader );
+
+ switch ( nodeTagType )
+ {
+ case TAG:
+ strcat( buffer, "']/tag" );
+ break;
+ case EMPTY:
+ strcat( buffer, "']" );
+ };
+
+ return buffer;
+}
+
+public:
+XmlTagBuilder();
+~XmlTagBuilder();
+
+bool CreateXmlDocument();
+bool OpenXmlDoc( const char* file, const char* savefile = 0 );
+bool SaveXmlDoc( const char* file );
+bool SaveXmlDoc( void );
+bool AddShaderNode( const char* shader, TextureType textureType, NodeShaderType nodeShaderType );
+bool DeleteShaderNode( const char* shader );
+bool CheckShaderTag( const char* shader );
+bool CheckShaderTag( const char* shader, const char* content );
+bool AddShaderTag( const char* shader, const char* content, NodeTagType nodeTagType );
+bool DeleteTag( const char* tag );
+int RenameShaderTag( const char* oldtag, CopiedString newtag );
+bool DeleteShaderTag( const char* shader, const char* tag );
+void GetShaderTags( const char* shader, std::vector<CopiedString>& tags );
+void GetUntagged( std::set<CopiedString>& shaders );
+void GetAllTags( std::set<CopiedString>& tags );
+void TagSearch( const char* expression, std::set<CopiedString>& paths );
+};
+
+#endif