├── .gitignore ├── LICENSE ├── README.md ├── XMLLuaToCPP.sln └── XMLLuaToCPP ├── Bin ├── CppFileInfo.xml ├── LuaFileInfo.xml ├── TestAPIInfo.xml └── UserData.xml ├── Common.h ├── CppFileCreate.cpp ├── CppFileCreate.h ├── LuaCommon.h ├── LuaFileCreate.cpp ├── LuaFileCreate.h ├── LuaInclude ├── lauxlib.h ├── lua.h ├── lua.hpp ├── luaconf.h └── lualib.h ├── Makefile ├── Makefile.define ├── ParseCAPIFile.cpp ├── ParseCAPIFile.h ├── ParseLuaFile.cpp ├── ParseLuaFile.h ├── ReadMe.txt ├── TinyXML ├── tinystr.cpp ├── tinystr.h ├── tinyxml.cpp ├── tinyxml.h ├── tinyxmlerror.cpp └── tinyxmlparser.cpp ├── XMLLuaToCPP.cpp ├── XMLLuaToCPP.vcxproj ├── XMLLuaToCPP.vcxproj.filters ├── XMLLuaToCPP.vcxproj.user ├── XmlOpeation.cpp ├── XmlOpeation.h ├── stdafx.cpp ├── stdafx.h └── targetver.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | 19 | # Compiled Static libraries 20 | *.lai 21 | *.la 22 | *.a 23 | *.lib 24 | 25 | # Executables 26 | *.exe 27 | *.out 28 | *.app 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 freeeyes 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # XMLLua2Cpp 2 | Generate Lua/C++ code and test code through XML automatically 3 | 4 | 本来想用英文来写此文档,但是实在是英文能力有限,先用中文吧,以后可以添加。 5 | 6 | ##功能: 7 | * 此工具是为了规范化Lua和Cpp之间的代码关系。 8 | * 根据指定的XML格式自动生成Lua文件框架和基于Lua的CAPI代码框架。 9 | * 开发者可以通过设计XML来管理和生成自己的Lua代码关系。 10 | * XML即可用于文档,也可以用于设计。 11 | 12 | ##设计目的: 13 | * 由于自己的工程也用到了不少Lua的地方,随着工程的日益复杂。 14 | * Lua和CAPI之间交互关系也变得复杂。 15 | * 为了减低程序员开发和维护的成本,同时自动建立维护文档。 16 | * 基于此目的,开发了这个工具。 17 | * 通过XML自动生成Lua文件的自动生成。 18 | * 并填充Lua文件内部的函数以及出入参。 19 | * 通过XML自动生成Lua C API的文件(包含h和cpp)。 20 | * 让开发者只要填充相关代码即可(做填空题)。 21 | * 同时提供生成简易的代码测试工程,用以可以测试整体的工程效率。 22 | * 程序员不必在关注如何编写胶水代码,而是注重出入参,函数的逻辑代码。 23 | 24 | ##简易说明: 25 | ### LuaFileInfo.xml 26 | * 这个文件是用来生成所有的Lua文件。 27 | * 你可以通过它来设计你的Lua文件接口函数以及结构。 28 | * 支持多个Lua文件的声明 29 | * ProjectName="autotest" 是工程名称,你可以任意起一个名字。 30 | * XMLLua2Cpp会根据这个工程名称,自动建立一个目录以存放生成好的所有代码。 31 | * LuaFile节点你可以设计多个,工具会自动根据这个文件属性生成不同的文件。 32 | * LuaFunc节点同样允许多个。Param节点也是 33 | * Param节点中的ParamType节点包含两种,一个是"in"入参,一个是"out"出参。 34 | * ParamClass属性目前支持三种类型,int(数字类型),string(字符串类型)和void(指针类型) 35 | 36 | ### CppFileInfo.xml 37 | * 这个文件是用来生成所有的C API。 38 | * 也就是Lua可以调用的C API接口函数。 39 | * 基本参数同上。 40 | * 说明一点的是,ParamClass属性支持自定义数据结构。你可以在这里设计自己的数据结构。 41 | * 例如:ParamClass="_PlayerInfo"。 42 | * 意思就是 这个数据声明为_PlayerInfo类型,在自动生成代码的时候会以此问标准。 43 | * 请在生成代码后,自动引用这个类型所在的头文件。 -------------------------------------------------------------------------------- /XMLLuaToCPP.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XMLLuaToCPP", "XMLLuaToCPP\XMLLuaToCPP.vcxproj", "{ED30C015-5EB9-48F7-9B59-C2D4DA0F8F0E}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {ED30C015-5EB9-48F7-9B59-C2D4DA0F8F0E}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {ED30C015-5EB9-48F7-9B59-C2D4DA0F8F0E}.Debug|Win32.Build.0 = Debug|Win32 14 | {ED30C015-5EB9-48F7-9B59-C2D4DA0F8F0E}.Release|Win32.ActiveCfg = Release|Win32 15 | {ED30C015-5EB9-48F7-9B59-C2D4DA0F8F0E}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /XMLLuaToCPP/Bin/CppFileInfo.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /XMLLuaToCPP/Bin/LuaFileInfo.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /XMLLuaToCPP/Bin/TestAPIInfo.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /XMLLuaToCPP/Bin/UserData.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | <_PlayerInfo desc="PlayerInfo"> 6 | int 7 | int 8 | int 9 | char 10 | 11 | -------------------------------------------------------------------------------- /XMLLuaToCPP/Common.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freeeyes/XMLLua2Cpp/3dad76a8eb95ab80f2bed588ef93d5220085e208/XMLLuaToCPP/Common.h -------------------------------------------------------------------------------- /XMLLuaToCPP/CppFileCreate.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freeeyes/XMLLua2Cpp/3dad76a8eb95ab80f2bed588ef93d5220085e208/XMLLuaToCPP/CppFileCreate.cpp -------------------------------------------------------------------------------- /XMLLuaToCPP/CppFileCreate.h: -------------------------------------------------------------------------------- 1 | #ifndef _CPPFILECREATE_H 2 | #define _CPPFILECREATE_H 3 | 4 | #include "Common.h" 5 | #include "XmlOpeation.h" 6 | #ifdef WIN32 7 | #include 8 | #else 9 | #include 10 | #endif 11 | #include 12 | #include 13 | using namespace std; 14 | 15 | #include "ParseCAPIFile.h" 16 | 17 | void Tranfile(const char* pFileSrc, const char* pFileDes); 18 | void Create_Lua_Environment(_Project_Lua_Info* pLuaProject); 19 | 20 | bool Read_Cpp_File_XML(const char* pXMLName, _Project_Cpp_Info* pCppProject); 21 | bool Read_Test_File_XML(const char* pXMLName, _Test_API* pTestAPI); 22 | bool Read_StructData_File_XML(const char* pXMLName, _Base_Data_Group* pBaseDataGroup); 23 | 24 | bool Create_Cpp_API_Files(_Project_Cpp_Info* pCppProject); 25 | bool Create_Cpp_Exec_File(_Project_Cpp_Info* pCppProject); 26 | bool Create_Cpp_Test_Files(_Project_Lua_Info* pLuaProject, _Project_Cpp_Info* pCppProject, _Test_API* pTestAPI); 27 | bool Create_LuaCpp_Wrapper_Head_File(_Project_Lua_Info* pLuaProject, _Project_Cpp_Info* pCppProject); 28 | bool Create_LuaCpp_Wrapper_Cpp_File(_Project_Lua_Info* pLuaProject, _Project_Cpp_Info* pCppProject); 29 | bool Create_User_Data_Interface_Head_Files(_Base_Data_Group* pBaseDataGroup); 30 | bool Create_User_Data_Interface_Cpp_Files(_Base_Data_Group* pBaseDataGroup); 31 | 32 | bool CreateMakefile(_Project_Cpp_Info* pCppProject); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /XMLLuaToCPP/LuaCommon.h: -------------------------------------------------------------------------------- 1 | #ifndef _LUA_COMMON_H 2 | #define _LUA_COMMON_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #ifndef WIN32 9 | #include 10 | #else 11 | #include "windows.h" 12 | #endif 13 | 14 | #define LOG_STRING_LENGTH 300 15 | 16 | static unsigned long GetSystemTickCount() 17 | { 18 | #ifdef WIN32 19 | return GetTickCount(); 20 | #else 21 | struct timespec ts; 22 | 23 | clock_gettime(CLOCK_MONOTONIC, &ts); 24 | 25 | return (ts.tv_sec * 1000 + ts.tv_nsec / 1000000); 26 | #endif 27 | } 28 | 29 | static void sprintf_safe(char* pText, int nLen, const char* fmt ...) 30 | { 31 | va_list ap; 32 | va_start(ap, fmt); 33 | 34 | #ifdef WIN32 35 | vsnprintf_s(pText, nLen, _TRUNCATE, fmt, ap); 36 | #else 37 | vsnprintf(pText, nLen, fmt, ap); 38 | #endif 39 | pText[nLen - 1] = '\0'; 40 | 41 | va_end(ap); 42 | } 43 | 44 | static void Lua_Print(const char* fmt ...) 45 | { 46 | char szText[LOG_STRING_LENGTH] = {'\0'}; 47 | 48 | va_list ap; 49 | va_start(ap, fmt); 50 | 51 | #ifdef WIN32 52 | vsnprintf_s(szText, LOG_STRING_LENGTH, _TRUNCATE, fmt, ap); 53 | #else 54 | vsnprintf(szText, LOG_STRING_LENGTH, fmt, ap); 55 | #endif 56 | szText[LOG_STRING_LENGTH - 1] = '\0'; 57 | 58 | va_end(ap); 59 | 60 | #ifdef WIN32 61 | printf_s(szText); 62 | #else 63 | printf(szText); 64 | #endif 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /XMLLuaToCPP/LuaFileCreate.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freeeyes/XMLLua2Cpp/3dad76a8eb95ab80f2bed588ef93d5220085e208/XMLLuaToCPP/LuaFileCreate.cpp -------------------------------------------------------------------------------- /XMLLuaToCPP/LuaFileCreate.h: -------------------------------------------------------------------------------- 1 | #ifndef _LUAFILECREATE_H 2 | #define _LUAFILECREATE_H 3 | 4 | #include "ParseLuaFile.h" 5 | #include "XmlOpeation.h" 6 | #ifdef WIN32 7 | #include 8 | #else 9 | #include 10 | #endif 11 | 12 | bool Read_Lua_File_XML(const char* pXMLName, _Project_Lua_Info* pLuaProject); 13 | 14 | bool Creat_Lua_Files(_Project_Lua_Info* pLuaProject); 15 | 16 | #endif -------------------------------------------------------------------------------- /XMLLuaToCPP/LuaInclude/lauxlib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lauxlib.h,v 1.128 2014/10/29 16:11:17 roberto Exp $ 3 | ** Auxiliary functions for building Lua libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lauxlib_h 9 | #define lauxlib_h 10 | 11 | 12 | #include 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | 18 | 19 | /* extra error code for 'luaL_load' */ 20 | #define LUA_ERRFILE (LUA_ERRERR+1) 21 | 22 | 23 | typedef struct luaL_Reg { 24 | const char *name; 25 | lua_CFunction func; 26 | } luaL_Reg; 27 | 28 | 29 | #define LUAL_NUMSIZES (sizeof(lua_Integer)*16 + sizeof(lua_Number)) 30 | 31 | LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver, size_t sz); 32 | #define luaL_checkversion(L) \ 33 | luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES) 34 | 35 | LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); 36 | LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); 37 | LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len); 38 | LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg); 39 | LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg, 40 | size_t *l); 41 | LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg, 42 | const char *def, size_t *l); 43 | LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int arg); 44 | LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def); 45 | 46 | LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg); 47 | LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg, 48 | lua_Integer def); 49 | 50 | LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); 51 | LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t); 52 | LUALIB_API void (luaL_checkany) (lua_State *L, int arg); 53 | 54 | LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); 55 | LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname); 56 | LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname); 57 | LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); 58 | 59 | LUALIB_API void (luaL_where) (lua_State *L, int lvl); 60 | LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); 61 | 62 | LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def, 63 | const char *const lst[]); 64 | 65 | LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname); 66 | LUALIB_API int (luaL_execresult) (lua_State *L, int stat); 67 | 68 | /* pre-defined references */ 69 | #define LUA_NOREF (-2) 70 | #define LUA_REFNIL (-1) 71 | 72 | LUALIB_API int (luaL_ref) (lua_State *L, int t); 73 | LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); 74 | 75 | LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, 76 | const char *mode); 77 | 78 | #define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL) 79 | 80 | LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, 81 | const char *name, const char *mode); 82 | LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); 83 | 84 | LUALIB_API lua_State *(luaL_newstate) (void); 85 | 86 | LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx); 87 | 88 | LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, 89 | const char *r); 90 | 91 | LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup); 92 | 93 | LUALIB_API int (luaL_getsubtable) (lua_State *L, int idx, const char *fname); 94 | 95 | LUALIB_API void (luaL_traceback) (lua_State *L, lua_State *L1, 96 | const char *msg, int level); 97 | 98 | LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, 99 | lua_CFunction openf, int glb); 100 | 101 | /* 102 | ** =============================================================== 103 | ** some useful macros 104 | ** =============================================================== 105 | */ 106 | 107 | 108 | #define luaL_newlibtable(L,l) \ 109 | lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1) 110 | 111 | #define luaL_newlib(L,l) \ 112 | (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0)) 113 | 114 | #define luaL_argcheck(L, cond,arg,extramsg) \ 115 | ((void)((cond) || luaL_argerror(L, (arg), (extramsg)))) 116 | #define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) 117 | #define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) 118 | 119 | #define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) 120 | 121 | #define luaL_dofile(L, fn) \ 122 | (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) 123 | 124 | #define luaL_dostring(L, s) \ 125 | (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) 126 | 127 | #define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) 128 | 129 | #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) 130 | 131 | #define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL) 132 | 133 | 134 | /* 135 | ** {====================================================== 136 | ** Generic Buffer manipulation 137 | ** ======================================================= 138 | */ 139 | 140 | typedef struct luaL_Buffer { 141 | char *b; /* buffer address */ 142 | size_t size; /* buffer size */ 143 | size_t n; /* number of characters in buffer */ 144 | lua_State *L; 145 | char initb[LUAL_BUFFERSIZE]; /* initial buffer */ 146 | } luaL_Buffer; 147 | 148 | 149 | #define luaL_addchar(B,c) \ 150 | ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \ 151 | ((B)->b[(B)->n++] = (c))) 152 | 153 | #define luaL_addsize(B,s) ((B)->n += (s)) 154 | 155 | LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); 156 | LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz); 157 | LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); 158 | LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); 159 | LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); 160 | LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); 161 | LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz); 162 | LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz); 163 | 164 | #define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE) 165 | 166 | /* }====================================================== */ 167 | 168 | 169 | 170 | /* 171 | ** {====================================================== 172 | ** File handles for IO library 173 | ** ======================================================= 174 | */ 175 | 176 | /* 177 | ** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and 178 | ** initial structure 'luaL_Stream' (it may contain other fields 179 | ** after that initial structure). 180 | */ 181 | 182 | #define LUA_FILEHANDLE "FILE*" 183 | 184 | 185 | typedef struct luaL_Stream { 186 | FILE *f; /* stream (NULL for incompletely created streams) */ 187 | lua_CFunction closef; /* to close stream (NULL for closed streams) */ 188 | } luaL_Stream; 189 | 190 | /* }====================================================== */ 191 | 192 | 193 | 194 | /* compatibility with old module system */ 195 | #if defined(LUA_COMPAT_MODULE) 196 | 197 | LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname, 198 | int sizehint); 199 | LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, 200 | const luaL_Reg *l, int nup); 201 | 202 | #define luaL_register(L,n,l) (luaL_openlib(L,(n),(l),0)) 203 | 204 | #endif 205 | 206 | 207 | /* 208 | ** {================================================================== 209 | ** "Abstraction Layer" for basic report of messages and errors 210 | ** =================================================================== 211 | */ 212 | 213 | /* print a string */ 214 | #if !defined(lua_writestring) 215 | #define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout) 216 | #endif 217 | 218 | /* print a newline and flush the output */ 219 | #if !defined(lua_writeline) 220 | #define lua_writeline() (lua_writestring("\n", 1), fflush(stdout)) 221 | #endif 222 | 223 | /* print an error message */ 224 | #if !defined(lua_writestringerror) 225 | #define lua_writestringerror(s,p) \ 226 | (fprintf(stderr, (s), (p)), fflush(stderr)) 227 | #endif 228 | 229 | /* }================================================================== */ 230 | 231 | 232 | /* 233 | ** {============================================================ 234 | ** Compatibility with deprecated conversions 235 | ** ============================================================= 236 | */ 237 | #if defined(LUA_COMPAT_APIINTCASTS) 238 | 239 | #define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a)) 240 | #define luaL_optunsigned(L,a,d) \ 241 | ((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d))) 242 | 243 | #define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) 244 | #define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) 245 | 246 | #define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) 247 | #define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) 248 | 249 | #endif 250 | /* }============================================================ */ 251 | 252 | 253 | 254 | #endif 255 | 256 | 257 | -------------------------------------------------------------------------------- /XMLLuaToCPP/LuaInclude/lua.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lua.h,v 1.328 2015/06/03 13:03:38 roberto Exp $ 3 | ** Lua - A Scripting Language 4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) 5 | ** See Copyright Notice at the end of this file 6 | */ 7 | 8 | 9 | #ifndef lua_h 10 | #define lua_h 11 | 12 | #include 13 | #include 14 | 15 | 16 | #include "luaconf.h" 17 | 18 | 19 | #define LUA_VERSION_MAJOR "5" 20 | #define LUA_VERSION_MINOR "3" 21 | #define LUA_VERSION_NUM 503 22 | #define LUA_VERSION_RELEASE "1" 23 | 24 | #define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR 25 | #define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE 26 | #define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2015 Lua.org, PUC-Rio" 27 | #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" 28 | 29 | 30 | /* mark for precompiled code ('Lua') */ 31 | #define LUA_SIGNATURE "\x1bLua" 32 | 33 | /* option for multiple returns in 'lua_pcall' and 'lua_call' */ 34 | #define LUA_MULTRET (-1) 35 | 36 | 37 | /* 38 | ** Pseudo-indices 39 | ** (-LUAI_MAXSTACK is the minimum valid index; we keep some free empty 40 | ** space after that to help overflow detection) 41 | */ 42 | #define LUA_REGISTRYINDEX (-LUAI_MAXSTACK - 1000) 43 | #define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i)) 44 | 45 | 46 | /* thread status */ 47 | #define LUA_OK 0 48 | #define LUA_YIELD 1 49 | #define LUA_ERRRUN 2 50 | #define LUA_ERRSYNTAX 3 51 | #define LUA_ERRMEM 4 52 | #define LUA_ERRGCMM 5 53 | #define LUA_ERRERR 6 54 | 55 | 56 | typedef struct lua_State lua_State; 57 | 58 | 59 | /* 60 | ** basic types 61 | */ 62 | #define LUA_TNONE (-1) 63 | 64 | #define LUA_TNIL 0 65 | #define LUA_TBOOLEAN 1 66 | #define LUA_TLIGHTUSERDATA 2 67 | #define LUA_TNUMBER 3 68 | #define LUA_TSTRING 4 69 | #define LUA_TTABLE 5 70 | #define LUA_TFUNCTION 6 71 | #define LUA_TUSERDATA 7 72 | #define LUA_TTHREAD 8 73 | 74 | #define LUA_NUMTAGS 9 75 | 76 | 77 | 78 | /* minimum Lua stack available to a C function */ 79 | #define LUA_MINSTACK 20 80 | 81 | 82 | /* predefined values in the registry */ 83 | #define LUA_RIDX_MAINTHREAD 1 84 | #define LUA_RIDX_GLOBALS 2 85 | #define LUA_RIDX_LAST LUA_RIDX_GLOBALS 86 | 87 | 88 | /* type of numbers in Lua */ 89 | typedef LUA_NUMBER lua_Number; 90 | 91 | 92 | /* type for integer functions */ 93 | typedef LUA_INTEGER lua_Integer; 94 | 95 | /* unsigned integer type */ 96 | typedef LUA_UNSIGNED lua_Unsigned; 97 | 98 | /* type for continuation-function contexts */ 99 | typedef LUA_KCONTEXT lua_KContext; 100 | 101 | 102 | /* 103 | ** Type for C functions registered with Lua 104 | */ 105 | typedef int (*lua_CFunction) (lua_State *L); 106 | 107 | /* 108 | ** Type for continuation functions 109 | */ 110 | typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx); 111 | 112 | 113 | /* 114 | ** Type for functions that read/write blocks when loading/dumping Lua chunks 115 | */ 116 | typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); 117 | 118 | typedef int (*lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud); 119 | 120 | 121 | /* 122 | ** Type for memory-allocation functions 123 | */ 124 | typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); 125 | 126 | 127 | 128 | /* 129 | ** generic extra include file 130 | */ 131 | #if defined(LUA_USER_H) 132 | #include LUA_USER_H 133 | #endif 134 | 135 | 136 | /* 137 | ** RCS ident string 138 | */ 139 | extern const char lua_ident[]; 140 | 141 | 142 | /* 143 | ** state manipulation 144 | */ 145 | LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); 146 | LUA_API void (lua_close) (lua_State *L); 147 | LUA_API lua_State *(lua_newthread) (lua_State *L); 148 | 149 | LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); 150 | 151 | 152 | LUA_API const lua_Number *(lua_version) (lua_State *L); 153 | 154 | 155 | /* 156 | ** basic stack manipulation 157 | */ 158 | LUA_API int (lua_absindex) (lua_State *L, int idx); 159 | LUA_API int (lua_gettop) (lua_State *L); 160 | LUA_API void (lua_settop) (lua_State *L, int idx); 161 | LUA_API void (lua_pushvalue) (lua_State *L, int idx); 162 | LUA_API void (lua_rotate) (lua_State *L, int idx, int n); 163 | LUA_API void (lua_copy) (lua_State *L, int fromidx, int toidx); 164 | LUA_API int (lua_checkstack) (lua_State *L, int n); 165 | 166 | LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); 167 | 168 | 169 | /* 170 | ** access functions (stack -> C) 171 | */ 172 | 173 | LUA_API int (lua_isnumber) (lua_State *L, int idx); 174 | LUA_API int (lua_isstring) (lua_State *L, int idx); 175 | LUA_API int (lua_iscfunction) (lua_State *L, int idx); 176 | LUA_API int (lua_isinteger) (lua_State *L, int idx); 177 | LUA_API int (lua_isuserdata) (lua_State *L, int idx); 178 | LUA_API int (lua_type) (lua_State *L, int idx); 179 | LUA_API const char *(lua_typename) (lua_State *L, int tp); 180 | 181 | LUA_API lua_Number (lua_tonumberx) (lua_State *L, int idx, int *isnum); 182 | LUA_API lua_Integer (lua_tointegerx) (lua_State *L, int idx, int *isnum); 183 | LUA_API int (lua_toboolean) (lua_State *L, int idx); 184 | LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); 185 | LUA_API size_t (lua_rawlen) (lua_State *L, int idx); 186 | LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); 187 | LUA_API void *(lua_touserdata) (lua_State *L, int idx); 188 | LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); 189 | LUA_API const void *(lua_topointer) (lua_State *L, int idx); 190 | 191 | 192 | /* 193 | ** Comparison and arithmetic functions 194 | */ 195 | 196 | #define LUA_OPADD 0 /* ORDER TM, ORDER OP */ 197 | #define LUA_OPSUB 1 198 | #define LUA_OPMUL 2 199 | #define LUA_OPMOD 3 200 | #define LUA_OPPOW 4 201 | #define LUA_OPDIV 5 202 | #define LUA_OPIDIV 6 203 | #define LUA_OPBAND 7 204 | #define LUA_OPBOR 8 205 | #define LUA_OPBXOR 9 206 | #define LUA_OPSHL 10 207 | #define LUA_OPSHR 11 208 | #define LUA_OPUNM 12 209 | #define LUA_OPBNOT 13 210 | 211 | LUA_API void (lua_arith) (lua_State *L, int op); 212 | 213 | #define LUA_OPEQ 0 214 | #define LUA_OPLT 1 215 | #define LUA_OPLE 2 216 | 217 | LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); 218 | LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op); 219 | 220 | 221 | /* 222 | ** push functions (C -> stack) 223 | */ 224 | LUA_API void (lua_pushnil) (lua_State *L); 225 | LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); 226 | LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); 227 | LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t len); 228 | LUA_API const char *(lua_pushstring) (lua_State *L, const char *s); 229 | LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, 230 | va_list argp); 231 | LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); 232 | LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); 233 | LUA_API void (lua_pushboolean) (lua_State *L, int b); 234 | LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); 235 | LUA_API int (lua_pushthread) (lua_State *L); 236 | 237 | 238 | /* 239 | ** get functions (Lua -> stack) 240 | */ 241 | LUA_API int (lua_getglobal) (lua_State *L, const char *name); 242 | LUA_API int (lua_gettable) (lua_State *L, int idx); 243 | LUA_API int (lua_getfield) (lua_State *L, int idx, const char *k); 244 | LUA_API int (lua_geti) (lua_State *L, int idx, lua_Integer n); 245 | LUA_API int (lua_rawget) (lua_State *L, int idx); 246 | LUA_API int (lua_rawgeti) (lua_State *L, int idx, lua_Integer n); 247 | LUA_API int (lua_rawgetp) (lua_State *L, int idx, const void *p); 248 | 249 | LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); 250 | LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); 251 | LUA_API int (lua_getmetatable) (lua_State *L, int objindex); 252 | LUA_API int (lua_getuservalue) (lua_State *L, int idx); 253 | 254 | 255 | /* 256 | ** set functions (stack -> Lua) 257 | */ 258 | LUA_API void (lua_setglobal) (lua_State *L, const char *name); 259 | LUA_API void (lua_settable) (lua_State *L, int idx); 260 | LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); 261 | LUA_API void (lua_seti) (lua_State *L, int idx, lua_Integer n); 262 | LUA_API void (lua_rawset) (lua_State *L, int idx); 263 | LUA_API void (lua_rawseti) (lua_State *L, int idx, lua_Integer n); 264 | LUA_API void (lua_rawsetp) (lua_State *L, int idx, const void *p); 265 | LUA_API int (lua_setmetatable) (lua_State *L, int objindex); 266 | LUA_API void (lua_setuservalue) (lua_State *L, int idx); 267 | 268 | 269 | /* 270 | ** 'load' and 'call' functions (load and run Lua code) 271 | */ 272 | LUA_API void (lua_callk) (lua_State *L, int nargs, int nresults, 273 | lua_KContext ctx, lua_KFunction k); 274 | #define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL) 275 | 276 | LUA_API int (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc, 277 | lua_KContext ctx, lua_KFunction k); 278 | #define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL) 279 | 280 | LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, 281 | const char *chunkname, const char *mode); 282 | 283 | LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data, int strip); 284 | 285 | 286 | /* 287 | ** coroutine functions 288 | */ 289 | LUA_API int (lua_yieldk) (lua_State *L, int nresults, lua_KContext ctx, 290 | lua_KFunction k); 291 | LUA_API int (lua_resume) (lua_State *L, lua_State *from, int narg); 292 | LUA_API int (lua_status) (lua_State *L); 293 | LUA_API int (lua_isyieldable) (lua_State *L); 294 | 295 | #define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL) 296 | 297 | 298 | /* 299 | ** garbage-collection function and options 300 | */ 301 | 302 | #define LUA_GCSTOP 0 303 | #define LUA_GCRESTART 1 304 | #define LUA_GCCOLLECT 2 305 | #define LUA_GCCOUNT 3 306 | #define LUA_GCCOUNTB 4 307 | #define LUA_GCSTEP 5 308 | #define LUA_GCSETPAUSE 6 309 | #define LUA_GCSETSTEPMUL 7 310 | #define LUA_GCISRUNNING 9 311 | 312 | LUA_API int (lua_gc) (lua_State *L, int what, int data); 313 | 314 | 315 | /* 316 | ** miscellaneous functions 317 | */ 318 | 319 | LUA_API int (lua_error) (lua_State *L); 320 | 321 | LUA_API int (lua_next) (lua_State *L, int idx); 322 | 323 | LUA_API void (lua_concat) (lua_State *L, int n); 324 | LUA_API void (lua_len) (lua_State *L, int idx); 325 | 326 | LUA_API size_t (lua_stringtonumber) (lua_State *L, const char *s); 327 | 328 | LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); 329 | LUA_API void (lua_setallocf) (lua_State *L, lua_Alloc f, void *ud); 330 | 331 | 332 | 333 | /* 334 | ** {============================================================== 335 | ** some useful macros 336 | ** =============================================================== 337 | */ 338 | 339 | #define lua_getextraspace(L) ((void *)((char *)(L) - LUA_EXTRASPACE)) 340 | 341 | #define lua_tonumber(L,i) lua_tonumberx(L,(i),NULL) 342 | #define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL) 343 | 344 | #define lua_pop(L,n) lua_settop(L, -(n)-1) 345 | 346 | #define lua_newtable(L) lua_createtable(L, 0, 0) 347 | 348 | #define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) 349 | 350 | #define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) 351 | 352 | #define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) 353 | #define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) 354 | #define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) 355 | #define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) 356 | #define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) 357 | #define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) 358 | #define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) 359 | #define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) 360 | 361 | #define lua_pushliteral(L, s) lua_pushstring(L, "" s) 362 | 363 | #define lua_pushglobaltable(L) \ 364 | lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS) 365 | 366 | #define lua_tostring(L,i) lua_tolstring(L, (i), NULL) 367 | 368 | 369 | #define lua_insert(L,idx) lua_rotate(L, (idx), 1) 370 | 371 | #define lua_remove(L,idx) (lua_rotate(L, (idx), -1), lua_pop(L, 1)) 372 | 373 | #define lua_replace(L,idx) (lua_copy(L, -1, (idx)), lua_pop(L, 1)) 374 | 375 | /* }============================================================== */ 376 | 377 | 378 | /* 379 | ** {============================================================== 380 | ** compatibility macros for unsigned conversions 381 | ** =============================================================== 382 | */ 383 | #if defined(LUA_COMPAT_APIINTCASTS) 384 | 385 | #define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n)) 386 | #define lua_tounsignedx(L,i,is) ((lua_Unsigned)lua_tointegerx(L,i,is)) 387 | #define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL) 388 | 389 | #endif 390 | /* }============================================================== */ 391 | 392 | /* 393 | ** {====================================================================== 394 | ** Debug API 395 | ** ======================================================================= 396 | */ 397 | 398 | 399 | /* 400 | ** Event codes 401 | */ 402 | #define LUA_HOOKCALL 0 403 | #define LUA_HOOKRET 1 404 | #define LUA_HOOKLINE 2 405 | #define LUA_HOOKCOUNT 3 406 | #define LUA_HOOKTAILCALL 4 407 | 408 | 409 | /* 410 | ** Event masks 411 | */ 412 | #define LUA_MASKCALL (1 << LUA_HOOKCALL) 413 | #define LUA_MASKRET (1 << LUA_HOOKRET) 414 | #define LUA_MASKLINE (1 << LUA_HOOKLINE) 415 | #define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) 416 | 417 | typedef struct lua_Debug lua_Debug; /* activation record */ 418 | 419 | 420 | /* Functions to be called by the debugger in specific events */ 421 | typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); 422 | 423 | 424 | LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar); 425 | LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar); 426 | LUA_API const char *(lua_getlocal) (lua_State *L, const lua_Debug *ar, int n); 427 | LUA_API const char *(lua_setlocal) (lua_State *L, const lua_Debug *ar, int n); 428 | LUA_API const char *(lua_getupvalue) (lua_State *L, int funcindex, int n); 429 | LUA_API const char *(lua_setupvalue) (lua_State *L, int funcindex, int n); 430 | 431 | LUA_API void *(lua_upvalueid) (lua_State *L, int fidx, int n); 432 | LUA_API void (lua_upvaluejoin) (lua_State *L, int fidx1, int n1, 433 | int fidx2, int n2); 434 | 435 | LUA_API void (lua_sethook) (lua_State *L, lua_Hook func, int mask, int count); 436 | LUA_API lua_Hook (lua_gethook) (lua_State *L); 437 | LUA_API int (lua_gethookmask) (lua_State *L); 438 | LUA_API int (lua_gethookcount) (lua_State *L); 439 | 440 | 441 | struct lua_Debug { 442 | int event; 443 | const char *name; /* (n) */ 444 | const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */ 445 | const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */ 446 | const char *source; /* (S) */ 447 | int currentline; /* (l) */ 448 | int linedefined; /* (S) */ 449 | int lastlinedefined; /* (S) */ 450 | unsigned char nups; /* (u) number of upvalues */ 451 | unsigned char nparams;/* (u) number of parameters */ 452 | char isvararg; /* (u) */ 453 | char istailcall; /* (t) */ 454 | char short_src[LUA_IDSIZE]; /* (S) */ 455 | /* private part */ 456 | struct CallInfo *i_ci; /* active function */ 457 | }; 458 | 459 | /* }====================================================================== */ 460 | 461 | 462 | /****************************************************************************** 463 | * Copyright (C) 1994-2015 Lua.org, PUC-Rio. 464 | * 465 | * Permission is hereby granted, free of charge, to any person obtaining 466 | * a copy of this software and associated documentation files (the 467 | * "Software"), to deal in the Software without restriction, including 468 | * without limitation the rights to use, copy, modify, merge, publish, 469 | * distribute, sublicense, and/or sell copies of the Software, and to 470 | * permit persons to whom the Software is furnished to do so, subject to 471 | * the following conditions: 472 | * 473 | * The above copyright notice and this permission notice shall be 474 | * included in all copies or substantial portions of the Software. 475 | * 476 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 477 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 478 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 479 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 480 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 481 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 482 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 483 | ******************************************************************************/ 484 | 485 | 486 | #endif 487 | -------------------------------------------------------------------------------- /XMLLuaToCPP/LuaInclude/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /XMLLuaToCPP/LuaInclude/luaconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: luaconf.h,v 1.251 2015/05/20 17:39:23 roberto Exp $ 3 | ** Configuration file for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef luaconf_h 9 | #define luaconf_h 10 | 11 | #include 12 | #include 13 | 14 | 15 | /* 16 | ** =================================================================== 17 | ** Search for "@@" to find all configurable definitions. 18 | ** =================================================================== 19 | */ 20 | 21 | 22 | /* 23 | ** {==================================================================== 24 | ** System Configuration: macros to adapt (if needed) Lua to some 25 | ** particular platform, for instance compiling it with 32-bit numbers or 26 | ** restricting it to C89. 27 | ** ===================================================================== 28 | */ 29 | 30 | /* 31 | @@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. You 32 | ** can also define LUA_32BITS in the make file, but changing here you 33 | ** ensure that all software connected to Lua will be compiled with the 34 | ** same configuration. 35 | */ 36 | /* #define LUA_32BITS */ 37 | 38 | 39 | /* 40 | @@ LUA_USE_C89 controls the use of non-ISO-C89 features. 41 | ** Define it if you want Lua to avoid the use of a few C99 features 42 | ** or Windows-specific features on Windows. 43 | */ 44 | /* #define LUA_USE_C89 */ 45 | 46 | 47 | /* 48 | ** By default, Lua on Windows use (some) specific Windows features 49 | */ 50 | #if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE) 51 | #define LUA_USE_WINDOWS /* enable goodies for regular Windows */ 52 | #endif 53 | 54 | 55 | #if defined(LUA_USE_WINDOWS) 56 | #define LUA_DL_DLL /* enable support for DLL */ 57 | #define LUA_USE_C89 /* broadly, Windows is C89 */ 58 | #endif 59 | 60 | 61 | #if defined(LUA_USE_LINUX) 62 | #define LUA_USE_POSIX 63 | #define LUA_USE_DLOPEN /* needs an extra library: -ldl */ 64 | #define LUA_USE_READLINE /* needs some extra libraries */ 65 | #endif 66 | 67 | 68 | #if defined(LUA_USE_MACOSX) 69 | #define LUA_USE_POSIX 70 | #define LUA_USE_DLOPEN /* MacOS does not need -ldl */ 71 | #define LUA_USE_READLINE /* needs an extra library: -lreadline */ 72 | #endif 73 | 74 | 75 | /* 76 | @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for 77 | ** C89 ('long' and 'double'); Windows always has '__int64', so it does 78 | ** not need to use this case. 79 | */ 80 | #if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) 81 | #define LUA_C89_NUMBERS 82 | #endif 83 | 84 | 85 | 86 | /* 87 | @@ LUAI_BITSINT defines the (minimum) number of bits in an 'int'. 88 | */ 89 | /* avoid undefined shifts */ 90 | #if ((INT_MAX >> 15) >> 15) >= 1 91 | #define LUAI_BITSINT 32 92 | #else 93 | /* 'int' always must have at least 16 bits */ 94 | #define LUAI_BITSINT 16 95 | #endif 96 | 97 | 98 | /* 99 | @@ LUA_INT_TYPE defines the type for Lua integers. 100 | @@ LUA_FLOAT_TYPE defines the type for Lua floats. 101 | ** Lua should work fine with any mix of these options (if supported 102 | ** by your C compiler). The usual configurations are 64-bit integers 103 | ** and 'double' (the default), 32-bit integers and 'float' (for 104 | ** restricted platforms), and 'long'/'double' (for C compilers not 105 | ** compliant with C99, which may not have support for 'long long'). 106 | */ 107 | 108 | /* predefined options for LUA_INT_TYPE */ 109 | #define LUA_INT_INT 1 110 | #define LUA_INT_LONG 2 111 | #define LUA_INT_LONGLONG 3 112 | 113 | /* predefined options for LUA_FLOAT_TYPE */ 114 | #define LUA_FLOAT_FLOAT 1 115 | #define LUA_FLOAT_DOUBLE 2 116 | #define LUA_FLOAT_LONGDOUBLE 3 117 | 118 | #if defined(LUA_32BITS) /* { */ 119 | /* 120 | ** 32-bit integers and 'float' 121 | */ 122 | #if LUAI_BITSINT >= 32 /* use 'int' if big enough */ 123 | #define LUA_INT_TYPE LUA_INT_INT 124 | #else /* otherwise use 'long' */ 125 | #define LUA_INT_TYPE LUA_INT_LONG 126 | #endif 127 | #define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT 128 | 129 | #elif defined(LUA_C89_NUMBERS) /* }{ */ 130 | /* 131 | ** largest types available for C89 ('long' and 'double') 132 | */ 133 | #define LUA_INT_TYPE LUA_INT_LONG 134 | #define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE 135 | 136 | #endif /* } */ 137 | 138 | 139 | /* 140 | ** default configuration for 64-bit Lua ('long long' and 'double') 141 | */ 142 | #if !defined(LUA_INT_TYPE) 143 | #define LUA_INT_TYPE LUA_INT_LONGLONG 144 | #endif 145 | 146 | #if !defined(LUA_FLOAT_TYPE) 147 | #define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE 148 | #endif /* } */ 149 | 150 | /* }================================================================== */ 151 | 152 | 153 | 154 | 155 | /* 156 | ** {================================================================== 157 | ** Configuration for Paths. 158 | ** =================================================================== 159 | */ 160 | 161 | /* 162 | @@ LUA_PATH_DEFAULT is the default path that Lua uses to look for 163 | ** Lua libraries. 164 | @@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for 165 | ** C libraries. 166 | ** CHANGE them if your machine has a non-conventional directory 167 | ** hierarchy or if you want to install your libraries in 168 | ** non-conventional directories. 169 | */ 170 | #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR 171 | #if defined(_WIN32) /* { */ 172 | /* 173 | ** In Windows, any exclamation mark ('!') in the path is replaced by the 174 | ** path of the directory of the executable file of the current process. 175 | */ 176 | #define LUA_LDIR "!\\lua\\" 177 | #define LUA_CDIR "!\\" 178 | #define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\" 179 | #define LUA_PATH_DEFAULT \ 180 | LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ 181 | LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \ 182 | LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \ 183 | ".\\?.lua;" ".\\?\\init.lua" 184 | #define LUA_CPATH_DEFAULT \ 185 | LUA_CDIR"?.dll;" \ 186 | LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \ 187 | LUA_CDIR"loadall.dll;" ".\\?.dll" 188 | 189 | #else /* }{ */ 190 | 191 | #define LUA_ROOT "/usr/local/" 192 | #define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" 193 | #define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" 194 | #define LUA_PATH_DEFAULT \ 195 | LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ 196 | LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \ 197 | "./?.lua;" "./?/init.lua" 198 | #define LUA_CPATH_DEFAULT \ 199 | LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" 200 | #endif /* } */ 201 | 202 | 203 | /* 204 | @@ LUA_DIRSEP is the directory separator (for submodules). 205 | ** CHANGE it if your machine does not use "/" as the directory separator 206 | ** and is not Windows. (On Windows Lua automatically uses "\".) 207 | */ 208 | #if defined(_WIN32) 209 | #define LUA_DIRSEP "\\" 210 | #else 211 | #define LUA_DIRSEP "/" 212 | #endif 213 | 214 | /* }================================================================== */ 215 | 216 | 217 | /* 218 | ** {================================================================== 219 | ** Marks for exported symbols in the C code 220 | ** =================================================================== 221 | */ 222 | 223 | /* 224 | @@ LUA_API is a mark for all core API functions. 225 | @@ LUALIB_API is a mark for all auxiliary library functions. 226 | @@ LUAMOD_API is a mark for all standard library opening functions. 227 | ** CHANGE them if you need to define those functions in some special way. 228 | ** For instance, if you want to create one Windows DLL with the core and 229 | ** the libraries, you may want to use the following definition (define 230 | ** LUA_BUILD_AS_DLL to get it). 231 | */ 232 | #if defined(LUA_BUILD_AS_DLL) /* { */ 233 | 234 | #if defined(LUA_CORE) || defined(LUA_LIB) /* { */ 235 | #define LUA_API __declspec(dllexport) 236 | #else /* }{ */ 237 | #define LUA_API __declspec(dllimport) 238 | #endif /* } */ 239 | 240 | #else /* }{ */ 241 | 242 | #define LUA_API extern 243 | 244 | #endif /* } */ 245 | 246 | 247 | /* more often than not the libs go together with the core */ 248 | #define LUALIB_API LUA_API 249 | #define LUAMOD_API LUALIB_API 250 | 251 | 252 | /* 253 | @@ LUAI_FUNC is a mark for all extern functions that are not to be 254 | ** exported to outside modules. 255 | @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables 256 | ** that are not to be exported to outside modules (LUAI_DDEF for 257 | ** definitions and LUAI_DDEC for declarations). 258 | ** CHANGE them if you need to mark them in some special way. Elf/gcc 259 | ** (versions 3.2 and later) mark them as "hidden" to optimize access 260 | ** when Lua is compiled as a shared library. Not all elf targets support 261 | ** this attribute. Unfortunately, gcc does not offer a way to check 262 | ** whether the target offers that support, and those without support 263 | ** give a warning about it. To avoid these warnings, change to the 264 | ** default definition. 265 | */ 266 | #if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ 267 | defined(__ELF__) /* { */ 268 | #define LUAI_FUNC __attribute__((visibility("hidden"))) extern 269 | #else /* }{ */ 270 | #define LUAI_FUNC extern 271 | #endif /* } */ 272 | 273 | #define LUAI_DDEC LUAI_FUNC 274 | #define LUAI_DDEF /* empty */ 275 | 276 | /* }================================================================== */ 277 | 278 | 279 | /* 280 | ** {================================================================== 281 | ** Compatibility with previous versions 282 | ** =================================================================== 283 | */ 284 | 285 | /* 286 | @@ LUA_COMPAT_5_2 controls other macros for compatibility with Lua 5.2. 287 | @@ LUA_COMPAT_5_1 controls other macros for compatibility with Lua 5.1. 288 | ** You can define it to get all options, or change specific options 289 | ** to fit your specific needs. 290 | */ 291 | #if defined(LUA_COMPAT_5_2) /* { */ 292 | 293 | /* 294 | @@ LUA_COMPAT_MATHLIB controls the presence of several deprecated 295 | ** functions in the mathematical library. 296 | */ 297 | #define LUA_COMPAT_MATHLIB 298 | 299 | /* 300 | @@ LUA_COMPAT_BITLIB controls the presence of library 'bit32'. 301 | */ 302 | #define LUA_COMPAT_BITLIB 303 | 304 | /* 305 | @@ LUA_COMPAT_IPAIRS controls the effectiveness of the __ipairs metamethod. 306 | */ 307 | #define LUA_COMPAT_IPAIRS 308 | 309 | /* 310 | @@ LUA_COMPAT_APIINTCASTS controls the presence of macros for 311 | ** manipulating other integer types (lua_pushunsigned, lua_tounsigned, 312 | ** luaL_checkint, luaL_checklong, etc.) 313 | */ 314 | #define LUA_COMPAT_APIINTCASTS 315 | 316 | #endif /* } */ 317 | 318 | 319 | #if defined(LUA_COMPAT_5_1) /* { */ 320 | 321 | /* Incompatibilities from 5.2 -> 5.3 */ 322 | #define LUA_COMPAT_MATHLIB 323 | #define LUA_COMPAT_APIINTCASTS 324 | 325 | /* 326 | @@ LUA_COMPAT_UNPACK controls the presence of global 'unpack'. 327 | ** You can replace it with 'table.unpack'. 328 | */ 329 | #define LUA_COMPAT_UNPACK 330 | 331 | /* 332 | @@ LUA_COMPAT_LOADERS controls the presence of table 'package.loaders'. 333 | ** You can replace it with 'package.searchers'. 334 | */ 335 | #define LUA_COMPAT_LOADERS 336 | 337 | /* 338 | @@ macro 'lua_cpcall' emulates deprecated function lua_cpcall. 339 | ** You can call your C function directly (with light C functions). 340 | */ 341 | #define lua_cpcall(L,f,u) \ 342 | (lua_pushcfunction(L, (f)), \ 343 | lua_pushlightuserdata(L,(u)), \ 344 | lua_pcall(L,1,0,0)) 345 | 346 | 347 | /* 348 | @@ LUA_COMPAT_LOG10 defines the function 'log10' in the math library. 349 | ** You can rewrite 'log10(x)' as 'log(x, 10)'. 350 | */ 351 | #define LUA_COMPAT_LOG10 352 | 353 | /* 354 | @@ LUA_COMPAT_LOADSTRING defines the function 'loadstring' in the base 355 | ** library. You can rewrite 'loadstring(s)' as 'load(s)'. 356 | */ 357 | #define LUA_COMPAT_LOADSTRING 358 | 359 | /* 360 | @@ LUA_COMPAT_MAXN defines the function 'maxn' in the table library. 361 | */ 362 | #define LUA_COMPAT_MAXN 363 | 364 | /* 365 | @@ The following macros supply trivial compatibility for some 366 | ** changes in the API. The macros themselves document how to 367 | ** change your code to avoid using them. 368 | */ 369 | #define lua_strlen(L,i) lua_rawlen(L, (i)) 370 | 371 | #define lua_objlen(L,i) lua_rawlen(L, (i)) 372 | 373 | #define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) 374 | #define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT) 375 | 376 | /* 377 | @@ LUA_COMPAT_MODULE controls compatibility with previous 378 | ** module functions 'module' (Lua) and 'luaL_register' (C). 379 | */ 380 | #define LUA_COMPAT_MODULE 381 | 382 | #endif /* } */ 383 | 384 | 385 | /* 386 | @@ LUA_COMPAT_FLOATSTRING makes Lua format integral floats without a 387 | @@ a float mark ('.0'). 388 | ** This macro is not on by default even in compatibility mode, 389 | ** because this is not really an incompatibility. 390 | */ 391 | /* #define LUA_COMPAT_FLOATSTRING */ 392 | 393 | /* }================================================================== */ 394 | 395 | 396 | 397 | /* 398 | ** {================================================================== 399 | ** Configuration for Numbers. 400 | ** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_* 401 | ** satisfy your needs. 402 | ** =================================================================== 403 | */ 404 | 405 | /* 406 | @@ LUA_NUMBER is the floating-point type used by Lua. 407 | @@ LUAI_UACNUMBER is the result of an 'usual argument conversion' 408 | @@ over a floating number. 409 | @@ l_mathlim(x) corrects limit name 'x' to the proper float type 410 | ** by prefixing it with one of FLT/DBL/LDBL. 411 | @@ LUA_NUMBER_FRMLEN is the length modifier for writing floats. 412 | @@ LUA_NUMBER_FMT is the format for writing floats. 413 | @@ lua_number2str converts a float to a string. 414 | @@ l_mathop allows the addition of an 'l' or 'f' to all math operations. 415 | @@ lua_str2number converts a decimal numeric string to a number. 416 | */ 417 | 418 | #if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT /* { single float */ 419 | 420 | #define LUA_NUMBER float 421 | 422 | #define l_mathlim(n) (FLT_##n) 423 | 424 | #define LUAI_UACNUMBER double 425 | 426 | #define LUA_NUMBER_FRMLEN "" 427 | #define LUA_NUMBER_FMT "%.7g" 428 | 429 | #define l_mathop(op) op##f 430 | 431 | #define lua_str2number(s,p) strtof((s), (p)) 432 | 433 | 434 | #elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE /* }{ long double */ 435 | 436 | #define LUA_NUMBER long double 437 | 438 | #define l_mathlim(n) (LDBL_##n) 439 | 440 | #define LUAI_UACNUMBER long double 441 | 442 | #define LUA_NUMBER_FRMLEN "L" 443 | #define LUA_NUMBER_FMT "%.19Lg" 444 | 445 | #define l_mathop(op) op##l 446 | 447 | #define lua_str2number(s,p) strtold((s), (p)) 448 | 449 | #elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE /* }{ double */ 450 | 451 | #define LUA_NUMBER double 452 | 453 | #define l_mathlim(n) (DBL_##n) 454 | 455 | #define LUAI_UACNUMBER double 456 | 457 | #define LUA_NUMBER_FRMLEN "" 458 | #define LUA_NUMBER_FMT "%.14g" 459 | 460 | #define l_mathop(op) op 461 | 462 | #define lua_str2number(s,p) strtod((s), (p)) 463 | 464 | #else /* }{ */ 465 | 466 | #error "numeric float type not defined" 467 | 468 | #endif /* } */ 469 | 470 | 471 | #define l_floor(x) (l_mathop(floor)(x)) 472 | 473 | #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) 474 | 475 | 476 | /* 477 | @@ lua_numbertointeger converts a float number to an integer, or 478 | ** returns 0 if float is not within the range of a lua_Integer. 479 | ** (The range comparisons are tricky because of rounding. The tests 480 | ** here assume a two-complement representation, where MININTEGER always 481 | ** has an exact representation as a float; MAXINTEGER may not have one, 482 | ** and therefore its conversion to float may have an ill-defined value.) 483 | */ 484 | #define lua_numbertointeger(n,p) \ 485 | ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \ 486 | (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \ 487 | (*(p) = (LUA_INTEGER)(n), 1)) 488 | 489 | 490 | 491 | /* 492 | @@ LUA_INTEGER is the integer type used by Lua. 493 | ** 494 | @@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER. 495 | ** 496 | @@ LUAI_UACINT is the result of an 'usual argument conversion' 497 | @@ over a lUA_INTEGER. 498 | @@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers. 499 | @@ LUA_INTEGER_FMT is the format for writing integers. 500 | @@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER. 501 | @@ LUA_MININTEGER is the minimum value for a LUA_INTEGER. 502 | @@ lua_integer2str converts an integer to a string. 503 | */ 504 | 505 | 506 | /* The following definitions are good for most cases here */ 507 | 508 | #define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d" 509 | #define lua_integer2str(s,n) sprintf((s), LUA_INTEGER_FMT, (n)) 510 | 511 | #define LUAI_UACINT LUA_INTEGER 512 | 513 | /* 514 | ** use LUAI_UACINT here to avoid problems with promotions (which 515 | ** can turn a comparison between unsigneds into a signed comparison) 516 | */ 517 | #define LUA_UNSIGNED unsigned LUAI_UACINT 518 | 519 | 520 | /* now the variable definitions */ 521 | 522 | #if LUA_INT_TYPE == LUA_INT_INT /* { int */ 523 | 524 | #define LUA_INTEGER int 525 | #define LUA_INTEGER_FRMLEN "" 526 | 527 | #define LUA_MAXINTEGER INT_MAX 528 | #define LUA_MININTEGER INT_MIN 529 | 530 | #elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */ 531 | 532 | #define LUA_INTEGER long 533 | #define LUA_INTEGER_FRMLEN "l" 534 | 535 | #define LUA_MAXINTEGER LONG_MAX 536 | #define LUA_MININTEGER LONG_MIN 537 | 538 | #elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */ 539 | 540 | #if defined(LLONG_MAX) /* { */ 541 | /* use ISO C99 stuff */ 542 | 543 | #define LUA_INTEGER long long 544 | #define LUA_INTEGER_FRMLEN "ll" 545 | 546 | #define LUA_MAXINTEGER LLONG_MAX 547 | #define LUA_MININTEGER LLONG_MIN 548 | 549 | #elif defined(LUA_USE_WINDOWS) /* }{ */ 550 | /* in Windows, can use specific Windows types */ 551 | 552 | #define LUA_INTEGER __int64 553 | #define LUA_INTEGER_FRMLEN "I64" 554 | 555 | #define LUA_MAXINTEGER _I64_MAX 556 | #define LUA_MININTEGER _I64_MIN 557 | 558 | #else /* }{ */ 559 | 560 | #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ 561 | or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)" 562 | 563 | #endif /* } */ 564 | 565 | #else /* }{ */ 566 | 567 | #error "numeric integer type not defined" 568 | 569 | #endif /* } */ 570 | 571 | /* }================================================================== */ 572 | 573 | 574 | /* 575 | ** {================================================================== 576 | ** Dependencies with C99 and other C details 577 | ** =================================================================== 578 | */ 579 | 580 | /* 581 | @@ lua_strx2number converts an hexadecimal numeric string to a number. 582 | ** In C99, 'strtod' does that conversion. Otherwise, you can 583 | ** leave 'lua_strx2number' undefined and Lua will provide its own 584 | ** implementation. 585 | */ 586 | #if !defined(LUA_USE_C89) 587 | #define lua_strx2number(s,p) lua_str2number(s,p) 588 | #endif 589 | 590 | 591 | /* 592 | @@ lua_number2strx converts a float to an hexadecimal numeric string. 593 | ** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that. 594 | ** Otherwise, you can leave 'lua_number2strx' undefined and Lua will 595 | ** provide its own implementation. 596 | */ 597 | #if !defined(LUA_USE_C89) 598 | #define lua_number2strx(L,b,f,n) sprintf(b,f,n) 599 | #endif 600 | 601 | 602 | /* 603 | ** 'strtof' and 'opf' variants for math functions are not valid in 604 | ** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the 605 | ** availability of these variants. ('math.h' is already included in 606 | ** all files that use these macros.) 607 | */ 608 | #if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF)) 609 | #undef l_mathop /* variants not available */ 610 | #undef lua_str2number 611 | #define l_mathop(op) (lua_Number)op /* no variant */ 612 | #define lua_str2number(s,p) ((lua_Number)strtod((s), (p))) 613 | #endif 614 | 615 | 616 | /* 617 | @@ LUA_KCONTEXT is the type of the context ('ctx') for continuation 618 | ** functions. It must be a numerical type; Lua will use 'intptr_t' if 619 | ** available, otherwise it will use 'ptrdiff_t' (the nearest thing to 620 | ** 'intptr_t' in C89) 621 | */ 622 | #define LUA_KCONTEXT ptrdiff_t 623 | 624 | #if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \ 625 | __STDC_VERSION__ >= 199901L 626 | #include 627 | #if defined(INTPTR_MAX) /* even in C99 this type is optional */ 628 | #undef LUA_KCONTEXT 629 | #define LUA_KCONTEXT intptr_t 630 | #endif 631 | #endif 632 | 633 | 634 | /* 635 | @@ lua_getlocaledecpoint gets the locale "radix character" (decimal point). 636 | ** Change that if you do not want to use C locales. (Code using this 637 | ** macro must include header 'locale.h'.) 638 | */ 639 | #if !defined(lua_getlocaledecpoint) 640 | #define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) 641 | #endif 642 | 643 | /* }================================================================== */ 644 | 645 | 646 | /* 647 | ** {================================================================== 648 | ** Language Variations 649 | ** ===================================================================== 650 | */ 651 | 652 | /* 653 | @@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some 654 | ** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from 655 | ** numbers to strings. Define LUA_NOCVTS2N to turn off automatic 656 | ** coercion from strings to numbers. 657 | */ 658 | /* #define LUA_NOCVTN2S */ 659 | /* #define LUA_NOCVTS2N */ 660 | 661 | 662 | /* 663 | @@ LUA_USE_APICHECK turns on several consistency checks on the C API. 664 | ** Define it as a help when debugging C code. 665 | */ 666 | #if defined(LUA_USE_APICHECK) 667 | #include 668 | #define luai_apicheck(l,e) assert(e) 669 | #endif 670 | 671 | /* }================================================================== */ 672 | 673 | 674 | /* 675 | ** {================================================================== 676 | ** Macros that affect the API and must be stable (that is, must be the 677 | ** same when you compile Lua and when you compile code that links to 678 | ** Lua). You probably do not want/need to change them. 679 | ** ===================================================================== 680 | */ 681 | 682 | /* 683 | @@ LUAI_MAXSTACK limits the size of the Lua stack. 684 | ** CHANGE it if you need a different limit. This limit is arbitrary; 685 | ** its only purpose is to stop Lua from consuming unlimited stack 686 | ** space (and to reserve some numbers for pseudo-indices). 687 | */ 688 | #if LUAI_BITSINT >= 32 689 | #define LUAI_MAXSTACK 1000000 690 | #else 691 | #define LUAI_MAXSTACK 15000 692 | #endif 693 | 694 | 695 | /* 696 | @@ LUA_EXTRASPACE defines the size of a raw memory area associated with 697 | ** a Lua state with very fast access. 698 | ** CHANGE it if you need a different size. 699 | */ 700 | #define LUA_EXTRASPACE (sizeof(void *)) 701 | 702 | 703 | /* 704 | @@ LUA_IDSIZE gives the maximum size for the description of the source 705 | @@ of a function in debug information. 706 | ** CHANGE it if you want a different size. 707 | */ 708 | #define LUA_IDSIZE 60 709 | 710 | 711 | /* 712 | @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. 713 | ** CHANGE it if it uses too much C-stack space. (For long double, 714 | ** 'string.format("%.99f", 1e4932)' needs ~5030 bytes, so a 715 | ** smaller buffer would force a memory allocation for each call to 716 | ** 'string.format'.) 717 | */ 718 | #if defined(LUA_FLOAT_LONGDOUBLE) 719 | #define LUAL_BUFFERSIZE 8192 720 | #else 721 | #define LUAL_BUFFERSIZE ((int)(0x80 * sizeof(void*) * sizeof(lua_Integer))) 722 | #endif 723 | 724 | /* }================================================================== */ 725 | 726 | 727 | /* 728 | @@ LUA_QL describes how error messages quote program elements. 729 | ** Lua does not use these macros anymore; they are here for 730 | ** compatibility only. 731 | */ 732 | #define LUA_QL(x) "'" x "'" 733 | #define LUA_QS LUA_QL("%s") 734 | 735 | 736 | 737 | 738 | /* =================================================================== */ 739 | 740 | /* 741 | ** Local configuration. You can use this space to add your redefinitions 742 | ** without modifying the main part of the file. 743 | */ 744 | 745 | 746 | 747 | 748 | 749 | #endif 750 | 751 | -------------------------------------------------------------------------------- /XMLLuaToCPP/LuaInclude/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.44 2014/02/06 17:32:33 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | 15 | LUAMOD_API int (luaopen_base) (lua_State *L); 16 | 17 | #define LUA_COLIBNAME "coroutine" 18 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 19 | 20 | #define LUA_TABLIBNAME "table" 21 | LUAMOD_API int (luaopen_table) (lua_State *L); 22 | 23 | #define LUA_IOLIBNAME "io" 24 | LUAMOD_API int (luaopen_io) (lua_State *L); 25 | 26 | #define LUA_OSLIBNAME "os" 27 | LUAMOD_API int (luaopen_os) (lua_State *L); 28 | 29 | #define LUA_STRLIBNAME "string" 30 | LUAMOD_API int (luaopen_string) (lua_State *L); 31 | 32 | #define LUA_UTF8LIBNAME "utf8" 33 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 34 | 35 | #define LUA_BITLIBNAME "bit32" 36 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 37 | 38 | #define LUA_MATHLIBNAME "math" 39 | LUAMOD_API int (luaopen_math) (lua_State *L); 40 | 41 | #define LUA_DBLIBNAME "debug" 42 | LUAMOD_API int (luaopen_debug) (lua_State *L); 43 | 44 | #define LUA_LOADLIBNAME "package" 45 | LUAMOD_API int (luaopen_package) (lua_State *L); 46 | 47 | 48 | /* open all previous libraries */ 49 | LUALIB_API void (luaL_openlibs) (lua_State *L); 50 | 51 | 52 | 53 | #if !defined(lua_assert) 54 | #define lua_assert(x) ((void)0) 55 | #endif 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /XMLLuaToCPP/Makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freeeyes/XMLLua2Cpp/3dad76a8eb95ab80f2bed588ef93d5220085e208/XMLLuaToCPP/Makefile -------------------------------------------------------------------------------- /XMLLuaToCPP/Makefile.define: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freeeyes/XMLLua2Cpp/3dad76a8eb95ab80f2bed588ef93d5220085e208/XMLLuaToCPP/Makefile.define -------------------------------------------------------------------------------- /XMLLuaToCPP/ParseCAPIFile.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freeeyes/XMLLua2Cpp/3dad76a8eb95ab80f2bed588ef93d5220085e208/XMLLuaToCPP/ParseCAPIFile.cpp -------------------------------------------------------------------------------- /XMLLuaToCPP/ParseCAPIFile.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freeeyes/XMLLua2Cpp/3dad76a8eb95ab80f2bed588ef93d5220085e208/XMLLuaToCPP/ParseCAPIFile.h -------------------------------------------------------------------------------- /XMLLuaToCPP/ParseLuaFile.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freeeyes/XMLLua2Cpp/3dad76a8eb95ab80f2bed588ef93d5220085e208/XMLLuaToCPP/ParseLuaFile.cpp -------------------------------------------------------------------------------- /XMLLuaToCPP/ParseLuaFile.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freeeyes/XMLLua2Cpp/3dad76a8eb95ab80f2bed588ef93d5220085e208/XMLLuaToCPP/ParseLuaFile.h -------------------------------------------------------------------------------- /XMLLuaToCPP/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | 控制台应用程序:XMLLuaToCPP 项目概述 3 | ======================================================================== 4 | 5 | 应用程序向导已为您创建了此 XMLLuaToCPP 应用程序。 6 | 7 | 本文件概要介绍组成 XMLLuaToCPP 应用程序的每个文件的内容。 8 | 9 | 10 | XMLLuaToCPP.vcxproj 11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 12 | 13 | XMLLuaToCPP.vcxproj.filters 14 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 15 | 16 | XMLLuaToCPP.cpp 17 | 这是主应用程序源文件。 18 | 19 | ///////////////////////////////////////////////////////////////////////////// 20 | 其他标准文件: 21 | 22 | StdAfx.h, StdAfx.cpp 23 | 这些文件用于生成名为 XMLLuaToCPP.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 24 | 25 | ///////////////////////////////////////////////////////////////////////////// 26 | 其他注释: 27 | 28 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 29 | 30 | ///////////////////////////////////////////////////////////////////////////// 31 | -------------------------------------------------------------------------------- /XMLLuaToCPP/TinyXML/tinystr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | www.sourceforge.net/projects/tinyxml 3 | 4 | This software is provided 'as-is', without any express or implied 5 | warranty. In no event will the authors be held liable for any 6 | damages arising from the use of this software. 7 | 8 | Permission is granted to anyone to use this software for any 9 | purpose, including commercial applications, and to alter it and 10 | redistribute it freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must 13 | not claim that you wrote the original software. If you use this 14 | software in a product, an acknowledgment in the product documentation 15 | would be appreciated but is not required. 16 | 17 | 2. Altered source versions must be plainly marked as such, and 18 | must not be misrepresented as being the original software. 19 | 20 | 3. This notice may not be removed or altered from any source 21 | distribution. 22 | */ 23 | 24 | 25 | #ifndef TIXML_USE_STL 26 | 27 | #include "tinystr.h" 28 | 29 | // Error value for find primitive 30 | const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1); 31 | 32 | 33 | // Null rep. 34 | TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } }; 35 | 36 | 37 | void TiXmlString::reserve (size_type cap) 38 | { 39 | if (cap > capacity()) 40 | { 41 | TiXmlString tmp; 42 | tmp.init(length(), cap); 43 | memcpy(tmp.start(), data(), length()); 44 | swap(tmp); 45 | } 46 | } 47 | 48 | 49 | TiXmlString& TiXmlString::assign(const char* str, size_type len) 50 | { 51 | size_type cap = capacity(); 52 | if (len > cap || cap > 3*(len + 8)) 53 | { 54 | TiXmlString tmp; 55 | tmp.init(len); 56 | memcpy(tmp.start(), str, len); 57 | swap(tmp); 58 | } 59 | else 60 | { 61 | memmove(start(), str, len); 62 | set_size(len); 63 | } 64 | return *this; 65 | } 66 | 67 | 68 | TiXmlString& TiXmlString::append(const char* str, size_type len) 69 | { 70 | size_type newsize = length() + len; 71 | if (newsize > capacity()) 72 | { 73 | reserve (newsize + capacity()); 74 | } 75 | memmove(finish(), str, len); 76 | set_size(newsize); 77 | return *this; 78 | } 79 | 80 | 81 | TiXmlString operator + (const TiXmlString & a, const TiXmlString & b) 82 | { 83 | TiXmlString tmp; 84 | tmp.reserve(a.length() + b.length()); 85 | tmp += a; 86 | tmp += b; 87 | return tmp; 88 | } 89 | 90 | TiXmlString operator + (const TiXmlString & a, const char* b) 91 | { 92 | TiXmlString tmp; 93 | TiXmlString::size_type b_len = static_cast( strlen(b) ); 94 | tmp.reserve(a.length() + b_len); 95 | tmp += a; 96 | tmp.append(b, b_len); 97 | return tmp; 98 | } 99 | 100 | TiXmlString operator + (const char* a, const TiXmlString & b) 101 | { 102 | TiXmlString tmp; 103 | TiXmlString::size_type a_len = static_cast( strlen(a) ); 104 | tmp.reserve(a_len + b.length()); 105 | tmp.append(a, a_len); 106 | tmp += b; 107 | return tmp; 108 | } 109 | 110 | 111 | #endif // TIXML_USE_STL 112 | -------------------------------------------------------------------------------- /XMLLuaToCPP/TinyXML/tinystr.h: -------------------------------------------------------------------------------- 1 | /* 2 | www.sourceforge.net/projects/tinyxml 3 | 4 | This software is provided 'as-is', without any express or implied 5 | warranty. In no event will the authors be held liable for any 6 | damages arising from the use of this software. 7 | 8 | Permission is granted to anyone to use this software for any 9 | purpose, including commercial applications, and to alter it and 10 | redistribute it freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must 13 | not claim that you wrote the original software. If you use this 14 | software in a product, an acknowledgment in the product documentation 15 | would be appreciated but is not required. 16 | 17 | 2. Altered source versions must be plainly marked as such, and 18 | must not be misrepresented as being the original software. 19 | 20 | 3. This notice may not be removed or altered from any source 21 | distribution. 22 | */ 23 | 24 | 25 | #ifndef TIXML_USE_STL 26 | 27 | #ifndef TIXML_STRING_INCLUDED 28 | #define TIXML_STRING_INCLUDED 29 | 30 | #include 31 | #include 32 | 33 | /* The support for explicit isn't that universal, and it isn't really 34 | required - it is used to check that the TiXmlString class isn't incorrectly 35 | used. Be nice to old compilers and macro it here: 36 | */ 37 | #if defined(_MSC_VER) && (_MSC_VER >= 1200 ) 38 | // Microsoft visual studio, version 6 and higher. 39 | #define TIXML_EXPLICIT explicit 40 | #elif defined(__GNUC__) && (__GNUC__ >= 3 ) 41 | // GCC version 3 and higher.s 42 | #define TIXML_EXPLICIT explicit 43 | #else 44 | #define TIXML_EXPLICIT 45 | #endif 46 | 47 | 48 | /* 49 | TiXmlString is an emulation of a subset of the std::string template. 50 | Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. 51 | Only the member functions relevant to the TinyXML project have been implemented. 52 | The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase 53 | a string and there's no more room, we allocate a buffer twice as big as we need. 54 | */ 55 | class TiXmlString 56 | { 57 | public : 58 | // The size type used 59 | typedef size_t size_type; 60 | 61 | // Error value for find primitive 62 | static const size_type npos; // = -1; 63 | 64 | 65 | // TiXmlString empty constructor 66 | TiXmlString () : rep_(&nullrep_) 67 | { 68 | } 69 | 70 | // TiXmlString copy constructor 71 | TiXmlString ( const TiXmlString & copy) : rep_(0) 72 | { 73 | init(copy.length()); 74 | memcpy(start(), copy.data(), length()); 75 | } 76 | 77 | // TiXmlString constructor, based on a string 78 | TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0) 79 | { 80 | init( static_cast( strlen(copy) )); 81 | memcpy(start(), copy, length()); 82 | } 83 | 84 | // TiXmlString constructor, based on a string 85 | TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0) 86 | { 87 | init(len); 88 | memcpy(start(), str, len); 89 | } 90 | 91 | // TiXmlString destructor 92 | ~TiXmlString () 93 | { 94 | quit(); 95 | } 96 | 97 | TiXmlString& operator = (const char * copy) 98 | { 99 | return assign( copy, (size_type)strlen(copy)); 100 | } 101 | 102 | TiXmlString& operator = (const TiXmlString & copy) 103 | { 104 | return assign(copy.start(), copy.length()); 105 | } 106 | 107 | 108 | // += operator. Maps to append 109 | TiXmlString& operator += (const char * suffix) 110 | { 111 | return append(suffix, static_cast( strlen(suffix) )); 112 | } 113 | 114 | // += operator. Maps to append 115 | TiXmlString& operator += (char single) 116 | { 117 | return append(&single, 1); 118 | } 119 | 120 | // += operator. Maps to append 121 | TiXmlString& operator += (const TiXmlString & suffix) 122 | { 123 | return append(suffix.data(), suffix.length()); 124 | } 125 | 126 | 127 | // Convert a TiXmlString into a null-terminated char * 128 | const char * c_str () const { return rep_->str; } 129 | 130 | // Convert a TiXmlString into a char * (need not be null terminated). 131 | const char * data () const { return rep_->str; } 132 | 133 | // Return the length of a TiXmlString 134 | size_type length () const { return rep_->size; } 135 | 136 | // Alias for length() 137 | size_type size () const { return rep_->size; } 138 | 139 | // Checks if a TiXmlString is empty 140 | bool empty () const { return rep_->size == 0; } 141 | 142 | // Return capacity of string 143 | size_type capacity () const { return rep_->capacity; } 144 | 145 | 146 | // single char extraction 147 | const char& at (size_type index) const 148 | { 149 | assert( index < length() ); 150 | return rep_->str[ index ]; 151 | } 152 | 153 | // [] operator 154 | char& operator [] (size_type index) const 155 | { 156 | assert( index < length() ); 157 | return rep_->str[ index ]; 158 | } 159 | 160 | // find a char in a string. Return TiXmlString::npos if not found 161 | size_type find (char lookup) const 162 | { 163 | return find(lookup, 0); 164 | } 165 | 166 | // find a char in a string from an offset. Return TiXmlString::npos if not found 167 | size_type find (char tofind, size_type offset) const 168 | { 169 | if (offset >= length()) return npos; 170 | 171 | for (const char* p = c_str() + offset; *p != '\0'; ++p) 172 | { 173 | if (*p == tofind) return static_cast< size_type >( p - c_str() ); 174 | } 175 | return npos; 176 | } 177 | 178 | void clear () 179 | { 180 | //Lee: 181 | //The original was just too strange, though correct: 182 | // TiXmlString().swap(*this); 183 | //Instead use the quit & re-init: 184 | quit(); 185 | init(0,0); 186 | } 187 | 188 | /* Function to reserve a big amount of data when we know we'll need it. Be aware that this 189 | function DOES NOT clear the content of the TiXmlString if any exists. 190 | */ 191 | void reserve (size_type cap); 192 | 193 | TiXmlString& assign (const char* str, size_type len); 194 | 195 | TiXmlString& append (const char* str, size_type len); 196 | 197 | void swap (TiXmlString& other) 198 | { 199 | Rep* r = rep_; 200 | rep_ = other.rep_; 201 | other.rep_ = r; 202 | } 203 | 204 | private: 205 | 206 | void init(size_type sz) { init(sz, sz); } 207 | void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; } 208 | char* start() const { return rep_->str; } 209 | char* finish() const { return rep_->str + rep_->size; } 210 | 211 | struct Rep 212 | { 213 | size_type size, capacity; 214 | char str[1]; 215 | }; 216 | 217 | void init(size_type sz, size_type cap) 218 | { 219 | if (cap) 220 | { 221 | // Lee: the original form: 222 | // rep_ = static_cast(operator new(sizeof(Rep) + cap)); 223 | // doesn't work in some cases of new being overloaded. Switching 224 | // to the normal allocation, although use an 'int' for systems 225 | // that are overly picky about structure alignment. 226 | const size_type bytesNeeded = sizeof(Rep) + cap; 227 | const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); 228 | rep_ = reinterpret_cast( new int[ intsNeeded ] ); 229 | 230 | rep_->str[ rep_->size = sz ] = '\0'; 231 | rep_->capacity = cap; 232 | } 233 | else 234 | { 235 | rep_ = &nullrep_; 236 | } 237 | } 238 | 239 | void quit() 240 | { 241 | if (rep_ != &nullrep_) 242 | { 243 | // The rep_ is really an array of ints. (see the allocator, above). 244 | // Cast it back before delete, so the compiler won't incorrectly call destructors. 245 | delete [] ( reinterpret_cast( rep_ ) ); 246 | } 247 | } 248 | 249 | Rep * rep_; 250 | static Rep nullrep_; 251 | 252 | } ; 253 | 254 | 255 | inline bool operator == (const TiXmlString & a, const TiXmlString & b) 256 | { 257 | return ( a.length() == b.length() ) // optimization on some platforms 258 | && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare 259 | } 260 | inline bool operator < (const TiXmlString & a, const TiXmlString & b) 261 | { 262 | return strcmp(a.c_str(), b.c_str()) < 0; 263 | } 264 | 265 | inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); } 266 | inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; } 267 | inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); } 268 | inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); } 269 | 270 | inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; } 271 | inline bool operator == (const char* a, const TiXmlString & b) { return b == a; } 272 | inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); } 273 | inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); } 274 | 275 | TiXmlString operator + (const TiXmlString & a, const TiXmlString & b); 276 | TiXmlString operator + (const TiXmlString & a, const char* b); 277 | TiXmlString operator + (const char* a, const TiXmlString & b); 278 | 279 | 280 | /* 281 | TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString. 282 | Only the operators that we need for TinyXML have been developped. 283 | */ 284 | class TiXmlOutStream : public TiXmlString 285 | { 286 | public : 287 | 288 | // TiXmlOutStream << operator. 289 | TiXmlOutStream & operator << (const TiXmlString & in) 290 | { 291 | *this += in; 292 | return *this; 293 | } 294 | 295 | // TiXmlOutStream << operator. 296 | TiXmlOutStream & operator << (const char * in) 297 | { 298 | *this += in; 299 | return *this; 300 | } 301 | 302 | } ; 303 | 304 | #endif // TIXML_STRING_INCLUDED 305 | #endif // TIXML_USE_STL 306 | -------------------------------------------------------------------------------- /XMLLuaToCPP/TinyXML/tinyxml.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | www.sourceforge.net/projects/tinyxml 3 | Original code by Lee Thomason (www.grinninglizard.com) 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any 7 | damages arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any 10 | purpose, including commercial applications, and to alter it and 11 | redistribute it freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must 14 | not claim that you wrote the original software. If you use this 15 | software in a product, an acknowledgment in the product documentation 16 | would be appreciated but is not required. 17 | 18 | 2. Altered source versions must be plainly marked as such, and 19 | must not be misrepresented as being the original software. 20 | 21 | 3. This notice may not be removed or altered from any source 22 | distribution. 23 | */ 24 | 25 | #include 26 | 27 | #ifdef TIXML_USE_STL 28 | #include 29 | #include 30 | #endif 31 | 32 | #include "tinyxml.h" 33 | 34 | FILE* TiXmlFOpen( const char* filename, const char* mode ); 35 | 36 | bool TiXmlBase::condenseWhiteSpace = true; 37 | 38 | // Microsoft compiler security 39 | FILE* TiXmlFOpen( const char* filename, const char* mode ) 40 | { 41 | #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) 42 | FILE* fp = 0; 43 | errno_t err = fopen_s( &fp, filename, mode ); 44 | if ( !err && fp ) 45 | return fp; 46 | return 0; 47 | #else 48 | return fopen( filename, mode ); 49 | #endif 50 | } 51 | 52 | void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) 53 | { 54 | int i=0; 55 | 56 | while( i<(int)str.length() ) 57 | { 58 | unsigned char c = (unsigned char) str[i]; 59 | 60 | if ( c == '&' 61 | && i < ( (int)str.length() - 2 ) 62 | && str[i+1] == '#' 63 | && str[i+2] == 'x' ) 64 | { 65 | // Hexadecimal character reference. 66 | // Pass through unchanged. 67 | // © -- copyright symbol, for example. 68 | // 69 | // The -1 is a bug fix from Rob Laveaux. It keeps 70 | // an overflow from happening if there is no ';'. 71 | // There are actually 2 ways to exit this loop - 72 | // while fails (error case) and break (semicolon found). 73 | // However, there is no mechanism (currently) for 74 | // this function to return an error. 75 | while ( i<(int)str.length()-1 ) 76 | { 77 | outString->append( str.c_str() + i, 1 ); 78 | ++i; 79 | if ( str[i] == ';' ) 80 | break; 81 | } 82 | } 83 | else if ( c == '&' ) 84 | { 85 | outString->append( entity[0].str, entity[0].strLength ); 86 | ++i; 87 | } 88 | else if ( c == '<' ) 89 | { 90 | outString->append( entity[1].str, entity[1].strLength ); 91 | ++i; 92 | } 93 | else if ( c == '>' ) 94 | { 95 | outString->append( entity[2].str, entity[2].strLength ); 96 | ++i; 97 | } 98 | else if ( c == '\"' ) 99 | { 100 | outString->append( entity[3].str, entity[3].strLength ); 101 | ++i; 102 | } 103 | else if ( c == '\'' ) 104 | { 105 | outString->append( entity[4].str, entity[4].strLength ); 106 | ++i; 107 | } 108 | else if ( c < 32 ) 109 | { 110 | // Easy pass at non-alpha/numeric/symbol 111 | // Below 32 is symbolic. 112 | char buf[ 32 ]; 113 | 114 | #if defined(TIXML_SNPRINTF) 115 | TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) ); 116 | #else 117 | sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); 118 | #endif 119 | 120 | //*ME: warning C4267: convert 'size_t' to 'int' 121 | //*ME: Int-Cast to make compiler happy ... 122 | outString->append( buf, (int)strlen( buf ) ); 123 | ++i; 124 | } 125 | else 126 | { 127 | //char realc = (char) c; 128 | //outString->append( &realc, 1 ); 129 | *outString += (char) c; // somewhat more efficient function call. 130 | ++i; 131 | } 132 | } 133 | } 134 | 135 | 136 | TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() 137 | { 138 | parent = 0; 139 | type = _type; 140 | firstChild = 0; 141 | lastChild = 0; 142 | prev = 0; 143 | next = 0; 144 | } 145 | 146 | 147 | TiXmlNode::~TiXmlNode() 148 | { 149 | TiXmlNode* node = firstChild; 150 | TiXmlNode* temp = 0; 151 | 152 | while ( node ) 153 | { 154 | temp = node; 155 | node = node->next; 156 | delete temp; 157 | } 158 | } 159 | 160 | 161 | void TiXmlNode::CopyTo( TiXmlNode* target ) const 162 | { 163 | target->SetValue (value.c_str() ); 164 | target->userData = userData; 165 | target->location = location; 166 | } 167 | 168 | 169 | void TiXmlNode::Clear() 170 | { 171 | TiXmlNode* node = firstChild; 172 | TiXmlNode* temp = 0; 173 | 174 | while ( node ) 175 | { 176 | temp = node; 177 | node = node->next; 178 | delete temp; 179 | } 180 | 181 | firstChild = 0; 182 | lastChild = 0; 183 | } 184 | 185 | 186 | TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) 187 | { 188 | assert( node->parent == 0 || node->parent == this ); 189 | assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); 190 | 191 | if ( node->Type() == TiXmlNode::TINYXML_DOCUMENT ) 192 | { 193 | delete node; 194 | if ( GetDocument() ) 195 | GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); 196 | return 0; 197 | } 198 | 199 | node->parent = this; 200 | 201 | node->prev = lastChild; 202 | node->next = 0; 203 | 204 | if ( lastChild ) 205 | lastChild->next = node; 206 | else 207 | firstChild = node; // it was an empty list. 208 | 209 | lastChild = node; 210 | return node; 211 | } 212 | 213 | 214 | TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) 215 | { 216 | if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) 217 | { 218 | if ( GetDocument() ) 219 | GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); 220 | return 0; 221 | } 222 | TiXmlNode* node = addThis.Clone(); 223 | if ( !node ) 224 | return 0; 225 | 226 | return LinkEndChild( node ); 227 | } 228 | 229 | 230 | TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) 231 | { 232 | if ( !beforeThis || beforeThis->parent != this ) { 233 | return 0; 234 | } 235 | if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) 236 | { 237 | if ( GetDocument() ) 238 | GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); 239 | return 0; 240 | } 241 | 242 | TiXmlNode* node = addThis.Clone(); 243 | if ( !node ) 244 | return 0; 245 | node->parent = this; 246 | 247 | node->next = beforeThis; 248 | node->prev = beforeThis->prev; 249 | if ( beforeThis->prev ) 250 | { 251 | beforeThis->prev->next = node; 252 | } 253 | else 254 | { 255 | assert( firstChild == beforeThis ); 256 | firstChild = node; 257 | } 258 | beforeThis->prev = node; 259 | return node; 260 | } 261 | 262 | 263 | TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) 264 | { 265 | if ( !afterThis || afterThis->parent != this ) { 266 | return 0; 267 | } 268 | if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) 269 | { 270 | if ( GetDocument() ) 271 | GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); 272 | return 0; 273 | } 274 | 275 | TiXmlNode* node = addThis.Clone(); 276 | if ( !node ) 277 | return 0; 278 | node->parent = this; 279 | 280 | node->prev = afterThis; 281 | node->next = afterThis->next; 282 | if ( afterThis->next ) 283 | { 284 | afterThis->next->prev = node; 285 | } 286 | else 287 | { 288 | assert( lastChild == afterThis ); 289 | lastChild = node; 290 | } 291 | afterThis->next = node; 292 | return node; 293 | } 294 | 295 | 296 | TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) 297 | { 298 | if ( !replaceThis ) 299 | return 0; 300 | 301 | if ( replaceThis->parent != this ) 302 | return 0; 303 | 304 | if ( withThis.ToDocument() ) { 305 | // A document can never be a child. Thanks to Noam. 306 | TiXmlDocument* document = GetDocument(); 307 | if ( document ) 308 | document->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); 309 | return 0; 310 | } 311 | 312 | TiXmlNode* node = withThis.Clone(); 313 | if ( !node ) 314 | return 0; 315 | 316 | node->next = replaceThis->next; 317 | node->prev = replaceThis->prev; 318 | 319 | if ( replaceThis->next ) 320 | replaceThis->next->prev = node; 321 | else 322 | lastChild = node; 323 | 324 | if ( replaceThis->prev ) 325 | replaceThis->prev->next = node; 326 | else 327 | firstChild = node; 328 | 329 | delete replaceThis; 330 | node->parent = this; 331 | return node; 332 | } 333 | 334 | 335 | bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) 336 | { 337 | if ( !removeThis ) { 338 | return false; 339 | } 340 | 341 | if ( removeThis->parent != this ) 342 | { 343 | assert( 0 ); 344 | return false; 345 | } 346 | 347 | if ( removeThis->next ) 348 | removeThis->next->prev = removeThis->prev; 349 | else 350 | lastChild = removeThis->prev; 351 | 352 | if ( removeThis->prev ) 353 | removeThis->prev->next = removeThis->next; 354 | else 355 | firstChild = removeThis->next; 356 | 357 | delete removeThis; 358 | return true; 359 | } 360 | 361 | const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const 362 | { 363 | const TiXmlNode* node; 364 | for ( node = firstChild; node; node = node->next ) 365 | { 366 | if ( strcmp( node->Value(), _value ) == 0 ) 367 | return node; 368 | } 369 | return 0; 370 | } 371 | 372 | 373 | const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const 374 | { 375 | const TiXmlNode* node; 376 | for ( node = lastChild; node; node = node->prev ) 377 | { 378 | if ( strcmp( node->Value(), _value ) == 0 ) 379 | return node; 380 | } 381 | return 0; 382 | } 383 | 384 | 385 | const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const 386 | { 387 | if ( !previous ) 388 | { 389 | return FirstChild(); 390 | } 391 | else 392 | { 393 | assert( previous->parent == this ); 394 | return previous->NextSibling(); 395 | } 396 | } 397 | 398 | 399 | const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const 400 | { 401 | if ( !previous ) 402 | { 403 | return FirstChild( val ); 404 | } 405 | else 406 | { 407 | assert( previous->parent == this ); 408 | return previous->NextSibling( val ); 409 | } 410 | } 411 | 412 | 413 | const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const 414 | { 415 | const TiXmlNode* node; 416 | for ( node = next; node; node = node->next ) 417 | { 418 | if ( strcmp( node->Value(), _value ) == 0 ) 419 | return node; 420 | } 421 | return 0; 422 | } 423 | 424 | 425 | const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const 426 | { 427 | const TiXmlNode* node; 428 | for ( node = prev; node; node = node->prev ) 429 | { 430 | if ( strcmp( node->Value(), _value ) == 0 ) 431 | return node; 432 | } 433 | return 0; 434 | } 435 | 436 | 437 | void TiXmlElement::RemoveAttribute( const char * name ) 438 | { 439 | #ifdef TIXML_USE_STL 440 | TIXML_STRING str( name ); 441 | TiXmlAttribute* node = attributeSet.Find( str ); 442 | #else 443 | TiXmlAttribute* node = attributeSet.Find( name ); 444 | #endif 445 | if ( node ) 446 | { 447 | attributeSet.Remove( node ); 448 | delete node; 449 | } 450 | } 451 | 452 | const TiXmlElement* TiXmlNode::FirstChildElement() const 453 | { 454 | const TiXmlNode* node; 455 | 456 | for ( node = FirstChild(); 457 | node; 458 | node = node->NextSibling() ) 459 | { 460 | if ( node->ToElement() ) 461 | return node->ToElement(); 462 | } 463 | return 0; 464 | } 465 | 466 | 467 | const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const 468 | { 469 | const TiXmlNode* node; 470 | 471 | for ( node = FirstChild( _value ); 472 | node; 473 | node = node->NextSibling( _value ) ) 474 | { 475 | if ( node->ToElement() ) 476 | return node->ToElement(); 477 | } 478 | return 0; 479 | } 480 | 481 | 482 | const TiXmlElement* TiXmlNode::NextSiblingElement() const 483 | { 484 | const TiXmlNode* node; 485 | 486 | for ( node = NextSibling(); 487 | node; 488 | node = node->NextSibling() ) 489 | { 490 | if ( node->ToElement() ) 491 | return node->ToElement(); 492 | } 493 | return 0; 494 | } 495 | 496 | 497 | const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const 498 | { 499 | const TiXmlNode* node; 500 | 501 | for ( node = NextSibling( _value ); 502 | node; 503 | node = node->NextSibling( _value ) ) 504 | { 505 | if ( node->ToElement() ) 506 | return node->ToElement(); 507 | } 508 | return 0; 509 | } 510 | 511 | 512 | const TiXmlDocument* TiXmlNode::GetDocument() const 513 | { 514 | const TiXmlNode* node; 515 | 516 | for( node = this; node; node = node->parent ) 517 | { 518 | if ( node->ToDocument() ) 519 | return node->ToDocument(); 520 | } 521 | return 0; 522 | } 523 | 524 | 525 | TiXmlElement::TiXmlElement (const char * _value) 526 | : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) 527 | { 528 | firstChild = lastChild = 0; 529 | value = _value; 530 | } 531 | 532 | 533 | #ifdef TIXML_USE_STL 534 | TiXmlElement::TiXmlElement( const std::string& _value ) 535 | : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) 536 | { 537 | firstChild = lastChild = 0; 538 | value = _value; 539 | } 540 | #endif 541 | 542 | 543 | TiXmlElement::TiXmlElement( const TiXmlElement& copy) 544 | : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) 545 | { 546 | firstChild = lastChild = 0; 547 | copy.CopyTo( this ); 548 | } 549 | 550 | 551 | TiXmlElement& TiXmlElement::operator=( const TiXmlElement& base ) 552 | { 553 | ClearThis(); 554 | base.CopyTo( this ); 555 | return *this; 556 | } 557 | 558 | 559 | TiXmlElement::~TiXmlElement() 560 | { 561 | ClearThis(); 562 | } 563 | 564 | 565 | void TiXmlElement::ClearThis() 566 | { 567 | Clear(); 568 | while( attributeSet.First() ) 569 | { 570 | TiXmlAttribute* node = attributeSet.First(); 571 | attributeSet.Remove( node ); 572 | delete node; 573 | } 574 | } 575 | 576 | 577 | const char* TiXmlElement::Attribute( const char* name ) const 578 | { 579 | const TiXmlAttribute* node = attributeSet.Find( name ); 580 | if ( node ) 581 | return node->Value(); 582 | return 0; 583 | } 584 | 585 | 586 | #ifdef TIXML_USE_STL 587 | const std::string* TiXmlElement::Attribute( const std::string& name ) const 588 | { 589 | const TiXmlAttribute* attrib = attributeSet.Find( name ); 590 | if ( attrib ) 591 | return &attrib->ValueStr(); 592 | return 0; 593 | } 594 | #endif 595 | 596 | 597 | const char* TiXmlElement::Attribute( const char* name, int* i ) const 598 | { 599 | const TiXmlAttribute* attrib = attributeSet.Find( name ); 600 | const char* result = 0; 601 | 602 | if ( attrib ) { 603 | result = attrib->Value(); 604 | if ( i ) { 605 | attrib->QueryIntValue( i ); 606 | } 607 | } 608 | return result; 609 | } 610 | 611 | 612 | #ifdef TIXML_USE_STL 613 | const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const 614 | { 615 | const TiXmlAttribute* attrib = attributeSet.Find( name ); 616 | const std::string* result = 0; 617 | 618 | if ( attrib ) { 619 | result = &attrib->ValueStr(); 620 | if ( i ) { 621 | attrib->QueryIntValue( i ); 622 | } 623 | } 624 | return result; 625 | } 626 | #endif 627 | 628 | 629 | const char* TiXmlElement::Attribute( const char* name, double* d ) const 630 | { 631 | const TiXmlAttribute* attrib = attributeSet.Find( name ); 632 | const char* result = 0; 633 | 634 | if ( attrib ) { 635 | result = attrib->Value(); 636 | if ( d ) { 637 | attrib->QueryDoubleValue( d ); 638 | } 639 | } 640 | return result; 641 | } 642 | 643 | 644 | #ifdef TIXML_USE_STL 645 | const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const 646 | { 647 | const TiXmlAttribute* attrib = attributeSet.Find( name ); 648 | const std::string* result = 0; 649 | 650 | if ( attrib ) { 651 | result = &attrib->ValueStr(); 652 | if ( d ) { 653 | attrib->QueryDoubleValue( d ); 654 | } 655 | } 656 | return result; 657 | } 658 | #endif 659 | 660 | 661 | int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const 662 | { 663 | const TiXmlAttribute* attrib = attributeSet.Find( name ); 664 | if ( !attrib ) 665 | return TIXML_NO_ATTRIBUTE; 666 | return attrib->QueryIntValue( ival ); 667 | } 668 | 669 | 670 | int TiXmlElement::QueryUnsignedAttribute( const char* name, unsigned* value ) const 671 | { 672 | const TiXmlAttribute* node = attributeSet.Find( name ); 673 | if ( !node ) 674 | return TIXML_NO_ATTRIBUTE; 675 | 676 | int ival = 0; 677 | int result = node->QueryIntValue( &ival ); 678 | *value = (unsigned)ival; 679 | return result; 680 | } 681 | 682 | 683 | int TiXmlElement::QueryBoolAttribute( const char* name, bool* bval ) const 684 | { 685 | const TiXmlAttribute* node = attributeSet.Find( name ); 686 | if ( !node ) 687 | return TIXML_NO_ATTRIBUTE; 688 | 689 | int result = TIXML_WRONG_TYPE; 690 | if ( StringEqual( node->Value(), "true", true, TIXML_ENCODING_UNKNOWN ) 691 | || StringEqual( node->Value(), "yes", true, TIXML_ENCODING_UNKNOWN ) 692 | || StringEqual( node->Value(), "1", true, TIXML_ENCODING_UNKNOWN ) ) 693 | { 694 | *bval = true; 695 | result = TIXML_SUCCESS; 696 | } 697 | else if ( StringEqual( node->Value(), "false", true, TIXML_ENCODING_UNKNOWN ) 698 | || StringEqual( node->Value(), "no", true, TIXML_ENCODING_UNKNOWN ) 699 | || StringEqual( node->Value(), "0", true, TIXML_ENCODING_UNKNOWN ) ) 700 | { 701 | *bval = false; 702 | result = TIXML_SUCCESS; 703 | } 704 | return result; 705 | } 706 | 707 | 708 | 709 | #ifdef TIXML_USE_STL 710 | int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const 711 | { 712 | const TiXmlAttribute* attrib = attributeSet.Find( name ); 713 | if ( !attrib ) 714 | return TIXML_NO_ATTRIBUTE; 715 | return attrib->QueryIntValue( ival ); 716 | } 717 | #endif 718 | 719 | 720 | int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const 721 | { 722 | const TiXmlAttribute* attrib = attributeSet.Find( name ); 723 | if ( !attrib ) 724 | return TIXML_NO_ATTRIBUTE; 725 | return attrib->QueryDoubleValue( dval ); 726 | } 727 | 728 | 729 | #ifdef TIXML_USE_STL 730 | int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const 731 | { 732 | const TiXmlAttribute* attrib = attributeSet.Find( name ); 733 | if ( !attrib ) 734 | return TIXML_NO_ATTRIBUTE; 735 | return attrib->QueryDoubleValue( dval ); 736 | } 737 | #endif 738 | 739 | 740 | void TiXmlElement::SetAttribute( const char * name, int val ) 741 | { 742 | TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); 743 | if ( attrib ) { 744 | attrib->SetIntValue( val ); 745 | } 746 | } 747 | 748 | 749 | #ifdef TIXML_USE_STL 750 | void TiXmlElement::SetAttribute( const std::string& name, int val ) 751 | { 752 | TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); 753 | if ( attrib ) { 754 | attrib->SetIntValue( val ); 755 | } 756 | } 757 | #endif 758 | 759 | 760 | void TiXmlElement::SetDoubleAttribute( const char * name, double val ) 761 | { 762 | TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); 763 | if ( attrib ) { 764 | attrib->SetDoubleValue( val ); 765 | } 766 | } 767 | 768 | 769 | #ifdef TIXML_USE_STL 770 | void TiXmlElement::SetDoubleAttribute( const std::string& name, double val ) 771 | { 772 | TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); 773 | if ( attrib ) { 774 | attrib->SetDoubleValue( val ); 775 | } 776 | } 777 | #endif 778 | 779 | 780 | void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) 781 | { 782 | TiXmlAttribute* attrib = attributeSet.FindOrCreate( cname ); 783 | if ( attrib ) { 784 | attrib->SetValue( cvalue ); 785 | } 786 | } 787 | 788 | 789 | #ifdef TIXML_USE_STL 790 | void TiXmlElement::SetAttribute( const std::string& _name, const std::string& _value ) 791 | { 792 | TiXmlAttribute* attrib = attributeSet.FindOrCreate( _name ); 793 | if ( attrib ) { 794 | attrib->SetValue( _value ); 795 | } 796 | } 797 | #endif 798 | 799 | 800 | void TiXmlElement::Print( FILE* cfile, int depth ) const 801 | { 802 | int i; 803 | assert( cfile ); 804 | for ( i=0; iNext() ) 812 | { 813 | fprintf( cfile, " " ); 814 | attrib->Print( cfile, depth ); 815 | } 816 | 817 | // There are 3 different formatting approaches: 818 | // 1) An element without children is printed as a node 819 | // 2) An element with only a text child is printed as text 820 | // 3) An element with children is printed on multiple lines. 821 | TiXmlNode* node; 822 | if ( !firstChild ) 823 | { 824 | fprintf( cfile, " />" ); 825 | } 826 | else if ( firstChild == lastChild && firstChild->ToText() ) 827 | { 828 | fprintf( cfile, ">" ); 829 | firstChild->Print( cfile, depth + 1 ); 830 | fprintf( cfile, "", value.c_str() ); 831 | } 832 | else 833 | { 834 | fprintf( cfile, ">" ); 835 | 836 | for ( node = firstChild; node; node=node->NextSibling() ) 837 | { 838 | if ( !node->ToText() ) 839 | { 840 | fprintf( cfile, "\n" ); 841 | } 842 | node->Print( cfile, depth+1 ); 843 | } 844 | fprintf( cfile, "\n" ); 845 | for( i=0; i", value.c_str() ); 849 | } 850 | } 851 | 852 | 853 | void TiXmlElement::CopyTo( TiXmlElement* target ) const 854 | { 855 | // superclass: 856 | TiXmlNode::CopyTo( target ); 857 | 858 | // Element class: 859 | // Clone the attributes, then clone the children. 860 | const TiXmlAttribute* attribute = 0; 861 | for( attribute = attributeSet.First(); 862 | attribute; 863 | attribute = attribute->Next() ) 864 | { 865 | target->SetAttribute( attribute->Name(), attribute->Value() ); 866 | } 867 | 868 | TiXmlNode* node = 0; 869 | for ( node = firstChild; node; node = node->NextSibling() ) 870 | { 871 | target->LinkEndChild( node->Clone() ); 872 | } 873 | } 874 | 875 | bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const 876 | { 877 | if ( visitor->VisitEnter( *this, attributeSet.First() ) ) 878 | { 879 | for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) 880 | { 881 | if ( !node->Accept( visitor ) ) 882 | break; 883 | } 884 | } 885 | return visitor->VisitExit( *this ); 886 | } 887 | 888 | 889 | TiXmlNode* TiXmlElement::Clone() const 890 | { 891 | TiXmlElement* clone = new TiXmlElement( Value() ); 892 | if ( !clone ) 893 | return 0; 894 | 895 | CopyTo( clone ); 896 | return clone; 897 | } 898 | 899 | 900 | const char* TiXmlElement::GetText() const 901 | { 902 | const TiXmlNode* child = this->FirstChild(); 903 | if ( child ) { 904 | const TiXmlText* childText = child->ToText(); 905 | if ( childText ) { 906 | return childText->Value(); 907 | } 908 | } 909 | return 0; 910 | } 911 | 912 | 913 | TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) 914 | { 915 | tabsize = 4; 916 | useMicrosoftBOM = false; 917 | ClearError(); 918 | } 919 | 920 | TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) 921 | { 922 | tabsize = 4; 923 | useMicrosoftBOM = false; 924 | value = documentName; 925 | ClearError(); 926 | } 927 | 928 | 929 | #ifdef TIXML_USE_STL 930 | TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) 931 | { 932 | tabsize = 4; 933 | useMicrosoftBOM = false; 934 | value = documentName; 935 | ClearError(); 936 | } 937 | #endif 938 | 939 | 940 | TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) 941 | { 942 | copy.CopyTo( this ); 943 | } 944 | 945 | 946 | TiXmlDocument& TiXmlDocument::operator=( const TiXmlDocument& copy ) 947 | { 948 | Clear(); 949 | copy.CopyTo( this ); 950 | return *this; 951 | } 952 | 953 | 954 | bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) 955 | { 956 | return LoadFile( Value(), encoding ); 957 | } 958 | 959 | 960 | bool TiXmlDocument::SaveFile() const 961 | { 962 | return SaveFile( Value() ); 963 | } 964 | 965 | bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) 966 | { 967 | TIXML_STRING filename( _filename ); 968 | value = filename; 969 | 970 | // reading in binary mode so that tinyxml can normalize the EOL 971 | FILE* file = TiXmlFOpen( value.c_str (), "rb" ); 972 | 973 | if ( file ) 974 | { 975 | bool result = LoadFile( file, encoding ); 976 | fclose( file ); 977 | return result; 978 | } 979 | else 980 | { 981 | SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); 982 | return false; 983 | } 984 | } 985 | 986 | bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) 987 | { 988 | if ( !file ) 989 | { 990 | SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); 991 | return false; 992 | } 993 | 994 | // Delete the existing data: 995 | Clear(); 996 | location.Clear(); 997 | 998 | // Get the file size, so we can pre-allocate the string. HUGE speed impact. 999 | long length = 0; 1000 | fseek( file, 0, SEEK_END ); 1001 | length = ftell( file ); 1002 | fseek( file, 0, SEEK_SET ); 1003 | 1004 | // Strange case, but good to handle up front. 1005 | if ( length <= 0 ) 1006 | { 1007 | SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); 1008 | return false; 1009 | } 1010 | 1011 | // Subtle bug here. TinyXml did use fgets. But from the XML spec: 1012 | // 2.11 End-of-Line Handling 1013 | // 1014 | // 1015 | // ...the XML processor MUST behave as if it normalized all line breaks in external 1016 | // parsed entities (including the document entity) on input, before parsing, by translating 1017 | // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to 1018 | // a single #xA character. 1019 | // 1020 | // 1021 | // It is not clear fgets does that, and certainly isn't clear it works cross platform. 1022 | // Generally, you expect fgets to translate from the convention of the OS to the c/unix 1023 | // convention, and not work generally. 1024 | 1025 | /* 1026 | while( fgets( buf, sizeof(buf), file ) ) 1027 | { 1028 | data += buf; 1029 | } 1030 | */ 1031 | 1032 | char* buf = new char[ length+1 ]; 1033 | buf[0] = 0; 1034 | 1035 | if ( fread( buf, length, 1, file ) != 1 ) { 1036 | delete [] buf; 1037 | SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); 1038 | return false; 1039 | } 1040 | 1041 | // Process the buffer in place to normalize new lines. (See comment above.) 1042 | // Copies from the 'p' to 'q' pointer, where p can advance faster if 1043 | // a newline-carriage return is hit. 1044 | // 1045 | // Wikipedia: 1046 | // Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or 1047 | // CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, 0x0D 0x0A)... 1048 | // * LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS X, FreeBSD, etc.), BeOS, Amiga, RISC OS, and others 1049 | // * CR+LF: DEC RT-11 and most other early non-Unix, non-IBM OSes, CP/M, MP/M, DOS, OS/2, Microsoft Windows, Symbian OS 1050 | // * CR: Commodore 8-bit machines, Apple II family, Mac OS up to version 9 and OS-9 1051 | 1052 | const char* p = buf; // the read head 1053 | char* q = buf; // the write head 1054 | const char CR = 0x0d; 1055 | const char LF = 0x0a; 1056 | 1057 | buf[length] = 0; 1058 | while( *p ) { 1059 | assert( p < (buf+length) ); 1060 | assert( q <= (buf+length) ); 1061 | assert( q <= p ); 1062 | 1063 | if ( *p == CR ) { 1064 | *q++ = LF; 1065 | p++; 1066 | if ( *p == LF ) { // check for CR+LF (and skip LF) 1067 | p++; 1068 | } 1069 | } 1070 | else { 1071 | *q++ = *p++; 1072 | } 1073 | } 1074 | assert( q <= (buf+length) ); 1075 | *q = 0; 1076 | 1077 | Parse( buf, 0, encoding ); 1078 | 1079 | delete [] buf; 1080 | return !Error(); 1081 | } 1082 | 1083 | 1084 | bool TiXmlDocument::SaveFile( const char * filename ) const 1085 | { 1086 | // The old c stuff lives on... 1087 | FILE* fp = TiXmlFOpen( filename, "w" ); 1088 | if ( fp ) 1089 | { 1090 | bool result = SaveFile( fp ); 1091 | fclose( fp ); 1092 | return result; 1093 | } 1094 | return false; 1095 | } 1096 | 1097 | 1098 | bool TiXmlDocument::SaveFile( FILE* fp ) const 1099 | { 1100 | if ( useMicrosoftBOM ) 1101 | { 1102 | const unsigned char TIXML_UTF_LEAD_0 = 0xefU; 1103 | const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; 1104 | const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; 1105 | 1106 | fputc( TIXML_UTF_LEAD_0, fp ); 1107 | fputc( TIXML_UTF_LEAD_1, fp ); 1108 | fputc( TIXML_UTF_LEAD_2, fp ); 1109 | } 1110 | Print( fp, 0 ); 1111 | return (ferror(fp) == 0); 1112 | } 1113 | 1114 | 1115 | void TiXmlDocument::CopyTo( TiXmlDocument* target ) const 1116 | { 1117 | TiXmlNode::CopyTo( target ); 1118 | 1119 | target->error = error; 1120 | target->errorId = errorId; 1121 | target->errorDesc = errorDesc; 1122 | target->tabsize = tabsize; 1123 | target->errorLocation = errorLocation; 1124 | target->useMicrosoftBOM = useMicrosoftBOM; 1125 | 1126 | TiXmlNode* node = 0; 1127 | for ( node = firstChild; node; node = node->NextSibling() ) 1128 | { 1129 | target->LinkEndChild( node->Clone() ); 1130 | } 1131 | } 1132 | 1133 | 1134 | TiXmlNode* TiXmlDocument::Clone() const 1135 | { 1136 | TiXmlDocument* clone = new TiXmlDocument(); 1137 | if ( !clone ) 1138 | return 0; 1139 | 1140 | CopyTo( clone ); 1141 | return clone; 1142 | } 1143 | 1144 | 1145 | void TiXmlDocument::Print( FILE* cfile, int depth ) const 1146 | { 1147 | assert( cfile ); 1148 | for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) 1149 | { 1150 | node->Print( cfile, depth ); 1151 | fprintf( cfile, "\n" ); 1152 | } 1153 | } 1154 | 1155 | 1156 | bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const 1157 | { 1158 | if ( visitor->VisitEnter( *this ) ) 1159 | { 1160 | for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) 1161 | { 1162 | if ( !node->Accept( visitor ) ) 1163 | break; 1164 | } 1165 | } 1166 | return visitor->VisitExit( *this ); 1167 | } 1168 | 1169 | 1170 | const TiXmlAttribute* TiXmlAttribute::Next() const 1171 | { 1172 | // We are using knowledge of the sentinel. The sentinel 1173 | // have a value or name. 1174 | if ( next->value.empty() && next->name.empty() ) 1175 | return 0; 1176 | return next; 1177 | } 1178 | 1179 | /* 1180 | TiXmlAttribute* TiXmlAttribute::Next() 1181 | { 1182 | // We are using knowledge of the sentinel. The sentinel 1183 | // have a value or name. 1184 | if ( next->value.empty() && next->name.empty() ) 1185 | return 0; 1186 | return next; 1187 | } 1188 | */ 1189 | 1190 | const TiXmlAttribute* TiXmlAttribute::Previous() const 1191 | { 1192 | // We are using knowledge of the sentinel. The sentinel 1193 | // have a value or name. 1194 | if ( prev->value.empty() && prev->name.empty() ) 1195 | return 0; 1196 | return prev; 1197 | } 1198 | 1199 | /* 1200 | TiXmlAttribute* TiXmlAttribute::Previous() 1201 | { 1202 | // We are using knowledge of the sentinel. The sentinel 1203 | // have a value or name. 1204 | if ( prev->value.empty() && prev->name.empty() ) 1205 | return 0; 1206 | return prev; 1207 | } 1208 | */ 1209 | 1210 | void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const 1211 | { 1212 | TIXML_STRING n, v; 1213 | 1214 | EncodeString( name, &n ); 1215 | EncodeString( value, &v ); 1216 | 1217 | if (value.find ('\"') == TIXML_STRING::npos) { 1218 | if ( cfile ) { 1219 | fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); 1220 | } 1221 | if ( str ) { 1222 | (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; 1223 | } 1224 | } 1225 | else { 1226 | if ( cfile ) { 1227 | fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); 1228 | } 1229 | if ( str ) { 1230 | (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; 1231 | } 1232 | } 1233 | } 1234 | 1235 | 1236 | int TiXmlAttribute::QueryIntValue( int* ival ) const 1237 | { 1238 | if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 ) 1239 | return TIXML_SUCCESS; 1240 | return TIXML_WRONG_TYPE; 1241 | } 1242 | 1243 | int TiXmlAttribute::QueryDoubleValue( double* dval ) const 1244 | { 1245 | if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 ) 1246 | return TIXML_SUCCESS; 1247 | return TIXML_WRONG_TYPE; 1248 | } 1249 | 1250 | void TiXmlAttribute::SetIntValue( int _value ) 1251 | { 1252 | char buf [64]; 1253 | #if defined(TIXML_SNPRINTF) 1254 | TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); 1255 | #else 1256 | sprintf (buf, "%d", _value); 1257 | #endif 1258 | SetValue (buf); 1259 | } 1260 | 1261 | void TiXmlAttribute::SetDoubleValue( double _value ) 1262 | { 1263 | char buf [256]; 1264 | #if defined(TIXML_SNPRINTF) 1265 | TIXML_SNPRINTF( buf, sizeof(buf), "%g", _value); 1266 | #else 1267 | sprintf (buf, "%g", _value); 1268 | #endif 1269 | SetValue (buf); 1270 | } 1271 | 1272 | int TiXmlAttribute::IntValue() const 1273 | { 1274 | return atoi (value.c_str ()); 1275 | } 1276 | 1277 | double TiXmlAttribute::DoubleValue() const 1278 | { 1279 | return atof (value.c_str ()); 1280 | } 1281 | 1282 | 1283 | TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) 1284 | { 1285 | copy.CopyTo( this ); 1286 | } 1287 | 1288 | 1289 | TiXmlComment& TiXmlComment::operator=( const TiXmlComment& base ) 1290 | { 1291 | Clear(); 1292 | base.CopyTo( this ); 1293 | return *this; 1294 | } 1295 | 1296 | 1297 | void TiXmlComment::Print( FILE* cfile, int depth ) const 1298 | { 1299 | assert( cfile ); 1300 | for ( int i=0; i", value.c_str() ); 1305 | } 1306 | 1307 | 1308 | void TiXmlComment::CopyTo( TiXmlComment* target ) const 1309 | { 1310 | TiXmlNode::CopyTo( target ); 1311 | } 1312 | 1313 | 1314 | bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const 1315 | { 1316 | return visitor->Visit( *this ); 1317 | } 1318 | 1319 | 1320 | TiXmlNode* TiXmlComment::Clone() const 1321 | { 1322 | TiXmlComment* clone = new TiXmlComment(); 1323 | 1324 | if ( !clone ) 1325 | return 0; 1326 | 1327 | CopyTo( clone ); 1328 | return clone; 1329 | } 1330 | 1331 | 1332 | void TiXmlText::Print( FILE* cfile, int depth ) const 1333 | { 1334 | assert( cfile ); 1335 | if ( cdata ) 1336 | { 1337 | int i; 1338 | fprintf( cfile, "\n" ); 1339 | for ( i=0; i\n", value.c_str() ); // unformatted output 1343 | } 1344 | else 1345 | { 1346 | TIXML_STRING buffer; 1347 | EncodeString( value, &buffer ); 1348 | fprintf( cfile, "%s", buffer.c_str() ); 1349 | } 1350 | } 1351 | 1352 | 1353 | void TiXmlText::CopyTo( TiXmlText* target ) const 1354 | { 1355 | TiXmlNode::CopyTo( target ); 1356 | target->cdata = cdata; 1357 | } 1358 | 1359 | 1360 | bool TiXmlText::Accept( TiXmlVisitor* visitor ) const 1361 | { 1362 | return visitor->Visit( *this ); 1363 | } 1364 | 1365 | 1366 | TiXmlNode* TiXmlText::Clone() const 1367 | { 1368 | TiXmlText* clone = 0; 1369 | clone = new TiXmlText( "" ); 1370 | 1371 | if ( !clone ) 1372 | return 0; 1373 | 1374 | CopyTo( clone ); 1375 | return clone; 1376 | } 1377 | 1378 | 1379 | TiXmlDeclaration::TiXmlDeclaration( const char * _version, 1380 | const char * _encoding, 1381 | const char * _standalone ) 1382 | : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) 1383 | { 1384 | version = _version; 1385 | encoding = _encoding; 1386 | standalone = _standalone; 1387 | } 1388 | 1389 | 1390 | #ifdef TIXML_USE_STL 1391 | TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, 1392 | const std::string& _encoding, 1393 | const std::string& _standalone ) 1394 | : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) 1395 | { 1396 | version = _version; 1397 | encoding = _encoding; 1398 | standalone = _standalone; 1399 | } 1400 | #endif 1401 | 1402 | 1403 | TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy ) 1404 | : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) 1405 | { 1406 | copy.CopyTo( this ); 1407 | } 1408 | 1409 | 1410 | TiXmlDeclaration& TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ) 1411 | { 1412 | Clear(); 1413 | copy.CopyTo( this ); 1414 | return *this; 1415 | } 1416 | 1417 | 1418 | void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const 1419 | { 1420 | if ( cfile ) fprintf( cfile, "" ); 1436 | if ( str ) (*str) += "?>"; 1437 | } 1438 | 1439 | 1440 | void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const 1441 | { 1442 | TiXmlNode::CopyTo( target ); 1443 | 1444 | target->version = version; 1445 | target->encoding = encoding; 1446 | target->standalone = standalone; 1447 | } 1448 | 1449 | 1450 | bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const 1451 | { 1452 | return visitor->Visit( *this ); 1453 | } 1454 | 1455 | 1456 | TiXmlNode* TiXmlDeclaration::Clone() const 1457 | { 1458 | TiXmlDeclaration* clone = new TiXmlDeclaration(); 1459 | 1460 | if ( !clone ) 1461 | return 0; 1462 | 1463 | CopyTo( clone ); 1464 | return clone; 1465 | } 1466 | 1467 | 1468 | void TiXmlUnknown::Print( FILE* cfile, int depth ) const 1469 | { 1470 | for ( int i=0; i", value.c_str() ); 1473 | } 1474 | 1475 | 1476 | void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const 1477 | { 1478 | TiXmlNode::CopyTo( target ); 1479 | } 1480 | 1481 | 1482 | bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const 1483 | { 1484 | return visitor->Visit( *this ); 1485 | } 1486 | 1487 | 1488 | TiXmlNode* TiXmlUnknown::Clone() const 1489 | { 1490 | TiXmlUnknown* clone = new TiXmlUnknown(); 1491 | 1492 | if ( !clone ) 1493 | return 0; 1494 | 1495 | CopyTo( clone ); 1496 | return clone; 1497 | } 1498 | 1499 | 1500 | TiXmlAttributeSet::TiXmlAttributeSet() 1501 | { 1502 | sentinel.next = &sentinel; 1503 | sentinel.prev = &sentinel; 1504 | } 1505 | 1506 | 1507 | TiXmlAttributeSet::~TiXmlAttributeSet() 1508 | { 1509 | assert( sentinel.next == &sentinel ); 1510 | assert( sentinel.prev == &sentinel ); 1511 | } 1512 | 1513 | 1514 | void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ) 1515 | { 1516 | #ifdef TIXML_USE_STL 1517 | assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set. 1518 | #else 1519 | assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. 1520 | #endif 1521 | 1522 | addMe->next = &sentinel; 1523 | addMe->prev = sentinel.prev; 1524 | 1525 | sentinel.prev->next = addMe; 1526 | sentinel.prev = addMe; 1527 | } 1528 | 1529 | void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) 1530 | { 1531 | TiXmlAttribute* node; 1532 | 1533 | for( node = sentinel.next; node != &sentinel; node = node->next ) 1534 | { 1535 | if ( node == removeMe ) 1536 | { 1537 | node->prev->next = node->next; 1538 | node->next->prev = node->prev; 1539 | node->next = 0; 1540 | node->prev = 0; 1541 | return; 1542 | } 1543 | } 1544 | assert( 0 ); // we tried to remove a non-linked attribute. 1545 | } 1546 | 1547 | 1548 | #ifdef TIXML_USE_STL 1549 | TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const 1550 | { 1551 | for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) 1552 | { 1553 | if ( node->name == name ) 1554 | return node; 1555 | } 1556 | return 0; 1557 | } 1558 | 1559 | TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const std::string& _name ) 1560 | { 1561 | TiXmlAttribute* attrib = Find( _name ); 1562 | if ( !attrib ) { 1563 | attrib = new TiXmlAttribute(); 1564 | Add( attrib ); 1565 | attrib->SetName( _name ); 1566 | } 1567 | return attrib; 1568 | } 1569 | #endif 1570 | 1571 | 1572 | TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const 1573 | { 1574 | for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) 1575 | { 1576 | if ( strcmp( node->name.c_str(), name ) == 0 ) 1577 | return node; 1578 | } 1579 | return 0; 1580 | } 1581 | 1582 | 1583 | TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const char* _name ) 1584 | { 1585 | TiXmlAttribute* attrib = Find( _name ); 1586 | if ( !attrib ) { 1587 | attrib = new TiXmlAttribute(); 1588 | Add( attrib ); 1589 | attrib->SetName( _name ); 1590 | } 1591 | return attrib; 1592 | } 1593 | 1594 | 1595 | #ifdef TIXML_USE_STL 1596 | std::istream& operator>> (std::istream & in, TiXmlNode & base) 1597 | { 1598 | TIXML_STRING tag; 1599 | tag.reserve( 8 * 1000 ); 1600 | base.StreamIn( &in, &tag ); 1601 | 1602 | base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); 1603 | return in; 1604 | } 1605 | #endif 1606 | 1607 | 1608 | #ifdef TIXML_USE_STL 1609 | std::ostream& operator<< (std::ostream & out, const TiXmlNode & base) 1610 | { 1611 | TiXmlPrinter printer; 1612 | printer.SetStreamPrinting(); 1613 | base.Accept( &printer ); 1614 | out << printer.Str(); 1615 | 1616 | return out; 1617 | } 1618 | 1619 | 1620 | std::string& operator<< (std::string& out, const TiXmlNode& base ) 1621 | { 1622 | TiXmlPrinter printer; 1623 | printer.SetStreamPrinting(); 1624 | base.Accept( &printer ); 1625 | out.append( printer.Str() ); 1626 | 1627 | return out; 1628 | } 1629 | #endif 1630 | 1631 | 1632 | TiXmlHandle TiXmlHandle::FirstChild() const 1633 | { 1634 | if ( node ) 1635 | { 1636 | TiXmlNode* child = node->FirstChild(); 1637 | if ( child ) 1638 | return TiXmlHandle( child ); 1639 | } 1640 | return TiXmlHandle( 0 ); 1641 | } 1642 | 1643 | 1644 | TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const 1645 | { 1646 | if ( node ) 1647 | { 1648 | TiXmlNode* child = node->FirstChild( value ); 1649 | if ( child ) 1650 | return TiXmlHandle( child ); 1651 | } 1652 | return TiXmlHandle( 0 ); 1653 | } 1654 | 1655 | 1656 | TiXmlHandle TiXmlHandle::FirstChildElement() const 1657 | { 1658 | if ( node ) 1659 | { 1660 | TiXmlElement* child = node->FirstChildElement(); 1661 | if ( child ) 1662 | return TiXmlHandle( child ); 1663 | } 1664 | return TiXmlHandle( 0 ); 1665 | } 1666 | 1667 | 1668 | TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const 1669 | { 1670 | if ( node ) 1671 | { 1672 | TiXmlElement* child = node->FirstChildElement( value ); 1673 | if ( child ) 1674 | return TiXmlHandle( child ); 1675 | } 1676 | return TiXmlHandle( 0 ); 1677 | } 1678 | 1679 | 1680 | TiXmlHandle TiXmlHandle::Child( int count ) const 1681 | { 1682 | if ( node ) 1683 | { 1684 | int i; 1685 | TiXmlNode* child = node->FirstChild(); 1686 | for ( i=0; 1687 | child && iNextSibling(), ++i ) 1689 | { 1690 | // nothing 1691 | } 1692 | if ( child ) 1693 | return TiXmlHandle( child ); 1694 | } 1695 | return TiXmlHandle( 0 ); 1696 | } 1697 | 1698 | 1699 | TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const 1700 | { 1701 | if ( node ) 1702 | { 1703 | int i; 1704 | TiXmlNode* child = node->FirstChild( value ); 1705 | for ( i=0; 1706 | child && iNextSibling( value ), ++i ) 1708 | { 1709 | // nothing 1710 | } 1711 | if ( child ) 1712 | return TiXmlHandle( child ); 1713 | } 1714 | return TiXmlHandle( 0 ); 1715 | } 1716 | 1717 | 1718 | TiXmlHandle TiXmlHandle::ChildElement( int count ) const 1719 | { 1720 | if ( node ) 1721 | { 1722 | int i; 1723 | TiXmlElement* child = node->FirstChildElement(); 1724 | for ( i=0; 1725 | child && iNextSiblingElement(), ++i ) 1727 | { 1728 | // nothing 1729 | } 1730 | if ( child ) 1731 | return TiXmlHandle( child ); 1732 | } 1733 | return TiXmlHandle( 0 ); 1734 | } 1735 | 1736 | 1737 | TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const 1738 | { 1739 | if ( node ) 1740 | { 1741 | int i; 1742 | TiXmlElement* child = node->FirstChildElement( value ); 1743 | for ( i=0; 1744 | child && iNextSiblingElement( value ), ++i ) 1746 | { 1747 | // nothing 1748 | } 1749 | if ( child ) 1750 | return TiXmlHandle( child ); 1751 | } 1752 | return TiXmlHandle( 0 ); 1753 | } 1754 | 1755 | 1756 | bool TiXmlPrinter::VisitEnter( const TiXmlDocument& ) 1757 | { 1758 | return true; 1759 | } 1760 | 1761 | bool TiXmlPrinter::VisitExit( const TiXmlDocument& ) 1762 | { 1763 | return true; 1764 | } 1765 | 1766 | bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) 1767 | { 1768 | DoIndent(); 1769 | buffer += "<"; 1770 | buffer += element.Value(); 1771 | 1772 | for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) 1773 | { 1774 | buffer += " "; 1775 | attrib->Print( 0, 0, &buffer ); 1776 | } 1777 | 1778 | if ( !element.FirstChild() ) 1779 | { 1780 | buffer += " />"; 1781 | DoLineBreak(); 1782 | } 1783 | else 1784 | { 1785 | buffer += ">"; 1786 | if ( element.FirstChild()->ToText() 1787 | && element.LastChild() == element.FirstChild() 1788 | && element.FirstChild()->ToText()->CDATA() == false ) 1789 | { 1790 | simpleTextPrint = true; 1791 | // no DoLineBreak()! 1792 | } 1793 | else 1794 | { 1795 | DoLineBreak(); 1796 | } 1797 | } 1798 | ++depth; 1799 | return true; 1800 | } 1801 | 1802 | 1803 | bool TiXmlPrinter::VisitExit( const TiXmlElement& element ) 1804 | { 1805 | --depth; 1806 | if ( !element.FirstChild() ) 1807 | { 1808 | // nothing. 1809 | } 1810 | else 1811 | { 1812 | if ( simpleTextPrint ) 1813 | { 1814 | simpleTextPrint = false; 1815 | } 1816 | else 1817 | { 1818 | DoIndent(); 1819 | } 1820 | buffer += ""; 1823 | DoLineBreak(); 1824 | } 1825 | return true; 1826 | } 1827 | 1828 | 1829 | bool TiXmlPrinter::Visit( const TiXmlText& text ) 1830 | { 1831 | if ( text.CDATA() ) 1832 | { 1833 | DoIndent(); 1834 | buffer += ""; 1837 | DoLineBreak(); 1838 | } 1839 | else if ( simpleTextPrint ) 1840 | { 1841 | TIXML_STRING str; 1842 | TiXmlBase::EncodeString( text.ValueTStr(), &str ); 1843 | buffer += str; 1844 | } 1845 | else 1846 | { 1847 | DoIndent(); 1848 | TIXML_STRING str; 1849 | TiXmlBase::EncodeString( text.ValueTStr(), &str ); 1850 | buffer += str; 1851 | DoLineBreak(); 1852 | } 1853 | return true; 1854 | } 1855 | 1856 | 1857 | bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) 1858 | { 1859 | DoIndent(); 1860 | declaration.Print( 0, 0, &buffer ); 1861 | DoLineBreak(); 1862 | return true; 1863 | } 1864 | 1865 | 1866 | bool TiXmlPrinter::Visit( const TiXmlComment& comment ) 1867 | { 1868 | DoIndent(); 1869 | buffer += ""; 1872 | DoLineBreak(); 1873 | return true; 1874 | } 1875 | 1876 | 1877 | bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) 1878 | { 1879 | DoIndent(); 1880 | buffer += "<"; 1881 | buffer += unknown.Value(); 1882 | buffer += ">"; 1883 | DoLineBreak(); 1884 | return true; 1885 | } 1886 | 1887 | -------------------------------------------------------------------------------- /XMLLuaToCPP/TinyXML/tinyxmlerror.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | www.sourceforge.net/projects/tinyxml 3 | Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any 7 | damages arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any 10 | purpose, including commercial applications, and to alter it and 11 | redistribute it freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must 14 | not claim that you wrote the original software. If you use this 15 | software in a product, an acknowledgment in the product documentation 16 | would be appreciated but is not required. 17 | 18 | 2. Altered source versions must be plainly marked as such, and 19 | must not be misrepresented as being the original software. 20 | 21 | 3. This notice may not be removed or altered from any source 22 | distribution. 23 | */ 24 | 25 | #include "tinyxml.h" 26 | 27 | // The goal of the seperate error file is to make the first 28 | // step towards localization. tinyxml (currently) only supports 29 | // english error messages, but the could now be translated. 30 | // 31 | // It also cleans up the code a bit. 32 | // 33 | 34 | const char* TiXmlBase::errorString[ TiXmlBase::TIXML_ERROR_STRING_COUNT ] = 35 | { 36 | "No error", 37 | "Error", 38 | "Failed to open file", 39 | "Error parsing Element.", 40 | "Failed to read Element name", 41 | "Error reading Element value.", 42 | "Error reading Attributes.", 43 | "Error: empty tag.", 44 | "Error reading end tag.", 45 | "Error parsing Unknown.", 46 | "Error parsing Comment.", 47 | "Error parsing Declaration.", 48 | "Error document empty.", 49 | "Error null (0) or unexpected EOF found in input stream.", 50 | "Error parsing CDATA.", 51 | "Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.", 52 | }; 53 | -------------------------------------------------------------------------------- /XMLLuaToCPP/TinyXML/tinyxmlparser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | www.sourceforge.net/projects/tinyxml 3 | Original code by Lee Thomason (www.grinninglizard.com) 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any 7 | damages arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any 10 | purpose, including commercial applications, and to alter it and 11 | redistribute it freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must 14 | not claim that you wrote the original software. If you use this 15 | software in a product, an acknowledgment in the product documentation 16 | would be appreciated but is not required. 17 | 18 | 2. Altered source versions must be plainly marked as such, and 19 | must not be misrepresented as being the original software. 20 | 21 | 3. This notice may not be removed or altered from any source 22 | distribution. 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | #include "tinyxml.h" 29 | 30 | //#define DEBUG_PARSER 31 | #if defined( DEBUG_PARSER ) 32 | # if defined( DEBUG ) && defined( _MSC_VER ) 33 | # include 34 | # define TIXML_LOG OutputDebugString 35 | # else 36 | # define TIXML_LOG printf 37 | # endif 38 | #endif 39 | 40 | // Note tha "PutString" hardcodes the same list. This 41 | // is less flexible than it appears. Changing the entries 42 | // or order will break putstring. 43 | TiXmlBase::Entity TiXmlBase::entity[ TiXmlBase::NUM_ENTITY ] = 44 | { 45 | { "&", 5, '&' }, 46 | { "<", 4, '<' }, 47 | { ">", 4, '>' }, 48 | { """, 6, '\"' }, 49 | { "'", 6, '\'' } 50 | }; 51 | 52 | // Bunch of unicode info at: 53 | // http://www.unicode.org/faq/utf_bom.html 54 | // Including the basic of this table, which determines the #bytes in the 55 | // sequence from the lead byte. 1 placed for invalid sequences -- 56 | // although the result will be junk, pass it through as much as possible. 57 | // Beware of the non-characters in UTF-8: 58 | // ef bb bf (Microsoft "lead bytes") 59 | // ef bf be 60 | // ef bf bf 61 | 62 | const unsigned char TIXML_UTF_LEAD_0 = 0xefU; 63 | const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; 64 | const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; 65 | 66 | const int TiXmlBase::utf8ByteTable[256] = 67 | { 68 | // 0 1 2 3 4 5 6 7 8 9 a b c d e f 69 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 70 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 71 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20 72 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30 73 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 74 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50 75 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 76 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range 77 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid 78 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 79 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 80 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 81 | 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte 82 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0 83 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte 84 | 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid 85 | }; 86 | 87 | 88 | void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) 89 | { 90 | const unsigned long BYTE_MASK = 0xBF; 91 | const unsigned long BYTE_MARK = 0x80; 92 | const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; 93 | 94 | if (input < 0x80) 95 | *length = 1; 96 | else if ( input < 0x800 ) 97 | *length = 2; 98 | else if ( input < 0x10000 ) 99 | *length = 3; 100 | else if ( input < 0x200000 ) 101 | *length = 4; 102 | else 103 | { *length = 0; return; } // This code won't covert this correctly anyway. 104 | 105 | output += *length; 106 | 107 | // Scary scary fall throughs. 108 | switch (*length) 109 | { 110 | case 4: 111 | --output; 112 | *output = (char)((input | BYTE_MARK) & BYTE_MASK); 113 | input >>= 6; 114 | case 3: 115 | --output; 116 | *output = (char)((input | BYTE_MARK) & BYTE_MASK); 117 | input >>= 6; 118 | case 2: 119 | --output; 120 | *output = (char)((input | BYTE_MARK) & BYTE_MASK); 121 | input >>= 6; 122 | case 1: 123 | --output; 124 | *output = (char)(input | FIRST_BYTE_MARK[*length]); 125 | } 126 | } 127 | 128 | 129 | /*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) 130 | { 131 | // This will only work for low-ascii, everything else is assumed to be a valid 132 | // letter. I'm not sure this is the best approach, but it is quite tricky trying 133 | // to figure out alhabetical vs. not across encoding. So take a very 134 | // conservative approach. 135 | 136 | // if ( encoding == TIXML_ENCODING_UTF8 ) 137 | // { 138 | if ( anyByte < 127 ) 139 | return isalpha( anyByte ); 140 | else 141 | return 1; // What else to do? The unicode set is huge...get the english ones right. 142 | // } 143 | // else 144 | // { 145 | // return isalpha( anyByte ); 146 | // } 147 | } 148 | 149 | 150 | /*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) 151 | { 152 | // This will only work for low-ascii, everything else is assumed to be a valid 153 | // letter. I'm not sure this is the best approach, but it is quite tricky trying 154 | // to figure out alhabetical vs. not across encoding. So take a very 155 | // conservative approach. 156 | 157 | // if ( encoding == TIXML_ENCODING_UTF8 ) 158 | // { 159 | if ( anyByte < 127 ) 160 | return isalnum( anyByte ); 161 | else 162 | return 1; // What else to do? The unicode set is huge...get the english ones right. 163 | // } 164 | // else 165 | // { 166 | // return isalnum( anyByte ); 167 | // } 168 | } 169 | 170 | 171 | class TiXmlParsingData 172 | { 173 | friend class TiXmlDocument; 174 | public: 175 | void Stamp( const char* now, TiXmlEncoding encoding ); 176 | 177 | const TiXmlCursor& Cursor() const { return cursor; } 178 | 179 | private: 180 | // Only used by the document! 181 | TiXmlParsingData( const char* start, int _tabsize, int row, int col ) 182 | { 183 | assert( start ); 184 | stamp = start; 185 | tabsize = _tabsize; 186 | cursor.row = row; 187 | cursor.col = col; 188 | } 189 | 190 | TiXmlCursor cursor; 191 | const char* stamp; 192 | int tabsize; 193 | }; 194 | 195 | 196 | void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding ) 197 | { 198 | assert( now ); 199 | 200 | // Do nothing if the tabsize is 0. 201 | if ( tabsize < 1 ) 202 | { 203 | return; 204 | } 205 | 206 | // Get the current row, column. 207 | int row = cursor.row; 208 | int col = cursor.col; 209 | const char* p = stamp; 210 | assert( p ); 211 | 212 | while ( p < now ) 213 | { 214 | // Treat p as unsigned, so we have a happy compiler. 215 | const unsigned char* pU = (const unsigned char*)p; 216 | 217 | // Code contributed by Fletcher Dunn: (modified by lee) 218 | switch (*pU) { 219 | case 0: 220 | // We *should* never get here, but in case we do, don't 221 | // advance past the terminating null character, ever 222 | return; 223 | 224 | case '\r': 225 | // bump down to the next line 226 | ++row; 227 | col = 0; 228 | // Eat the character 229 | ++p; 230 | 231 | // Check for \r\n sequence, and treat this as a single character 232 | if (*p == '\n') { 233 | ++p; 234 | } 235 | break; 236 | 237 | case '\n': 238 | // bump down to the next line 239 | ++row; 240 | col = 0; 241 | 242 | // Eat the character 243 | ++p; 244 | 245 | // Check for \n\r sequence, and treat this as a single 246 | // character. (Yes, this bizarre thing does occur still 247 | // on some arcane platforms...) 248 | if (*p == '\r') { 249 | ++p; 250 | } 251 | break; 252 | 253 | case '\t': 254 | // Eat the character 255 | ++p; 256 | 257 | // Skip to next tab stop 258 | col = (col / tabsize + 1) * tabsize; 259 | break; 260 | 261 | case TIXML_UTF_LEAD_0: 262 | if ( encoding == TIXML_ENCODING_UTF8 ) 263 | { 264 | if ( *(p+1) && *(p+2) ) 265 | { 266 | // In these cases, don't advance the column. These are 267 | // 0-width spaces. 268 | if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) 269 | p += 3; 270 | else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) 271 | p += 3; 272 | else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) 273 | p += 3; 274 | else 275 | { p +=3; ++col; } // A normal character. 276 | } 277 | } 278 | else 279 | { 280 | ++p; 281 | ++col; 282 | } 283 | break; 284 | 285 | default: 286 | if ( encoding == TIXML_ENCODING_UTF8 ) 287 | { 288 | // Eat the 1 to 4 byte utf8 character. 289 | int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)]; 290 | if ( step == 0 ) 291 | step = 1; // Error case from bad encoding, but handle gracefully. 292 | p += step; 293 | 294 | // Just advance one column, of course. 295 | ++col; 296 | } 297 | else 298 | { 299 | ++p; 300 | ++col; 301 | } 302 | break; 303 | } 304 | } 305 | cursor.row = row; 306 | cursor.col = col; 307 | assert( cursor.row >= -1 ); 308 | assert( cursor.col >= -1 ); 309 | stamp = p; 310 | assert( stamp ); 311 | } 312 | 313 | 314 | const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) 315 | { 316 | if ( !p || !*p ) 317 | { 318 | return 0; 319 | } 320 | if ( encoding == TIXML_ENCODING_UTF8 ) 321 | { 322 | while ( *p ) 323 | { 324 | const unsigned char* pU = (const unsigned char*)p; 325 | 326 | // Skip the stupid Microsoft UTF-8 Byte order marks 327 | if ( *(pU+0)==TIXML_UTF_LEAD_0 328 | && *(pU+1)==TIXML_UTF_LEAD_1 329 | && *(pU+2)==TIXML_UTF_LEAD_2 ) 330 | { 331 | p += 3; 332 | continue; 333 | } 334 | else if(*(pU+0)==TIXML_UTF_LEAD_0 335 | && *(pU+1)==0xbfU 336 | && *(pU+2)==0xbeU ) 337 | { 338 | p += 3; 339 | continue; 340 | } 341 | else if(*(pU+0)==TIXML_UTF_LEAD_0 342 | && *(pU+1)==0xbfU 343 | && *(pU+2)==0xbfU ) 344 | { 345 | p += 3; 346 | continue; 347 | } 348 | 349 | if ( IsWhiteSpace( *p ) ) // Still using old rules for white space. 350 | ++p; 351 | else 352 | break; 353 | } 354 | } 355 | else 356 | { 357 | while ( *p && IsWhiteSpace( *p ) ) 358 | ++p; 359 | } 360 | 361 | return p; 362 | } 363 | 364 | #ifdef TIXML_USE_STL 365 | /*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ) 366 | { 367 | for( ;; ) 368 | { 369 | if ( !in->good() ) return false; 370 | 371 | int c = in->peek(); 372 | // At this scope, we can't get to a document. So fail silently. 373 | if ( !IsWhiteSpace( c ) || c <= 0 ) 374 | return true; 375 | 376 | *tag += (char) in->get(); 377 | } 378 | } 379 | 380 | /*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag ) 381 | { 382 | //assert( character > 0 && character < 128 ); // else it won't work in utf-8 383 | while ( in->good() ) 384 | { 385 | int c = in->peek(); 386 | if ( c == character ) 387 | return true; 388 | if ( c <= 0 ) // Silent failure: can't get document at this scope 389 | return false; 390 | 391 | in->get(); 392 | *tag += (char) c; 393 | } 394 | return false; 395 | } 396 | #endif 397 | 398 | // One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The 399 | // "assign" optimization removes over 10% of the execution time. 400 | // 401 | const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding ) 402 | { 403 | // Oddly, not supported on some comilers, 404 | //name->clear(); 405 | // So use this: 406 | *name = ""; 407 | assert( p ); 408 | 409 | // Names start with letters or underscores. 410 | // Of course, in unicode, tinyxml has no idea what a letter *is*. The 411 | // algorithm is generous. 412 | // 413 | // After that, they can be letters, underscores, numbers, 414 | // hyphens, or colons. (Colons are valid ony for namespaces, 415 | // but tinyxml can't tell namespaces from names.) 416 | if ( p && *p 417 | && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) 418 | { 419 | const char* start = p; 420 | while( p && *p 421 | && ( IsAlphaNum( (unsigned char ) *p, encoding ) 422 | || *p == '_' 423 | || *p == '-' 424 | || *p == '.' 425 | || *p == ':' ) ) 426 | { 427 | //(*name) += *p; // expensive 428 | ++p; 429 | } 430 | if ( p-start > 0 ) { 431 | name->assign( start, p-start ); 432 | } 433 | return p; 434 | } 435 | return 0; 436 | } 437 | 438 | const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) 439 | { 440 | // Presume an entity, and pull it out. 441 | TIXML_STRING ent; 442 | int i; 443 | *length = 0; 444 | 445 | if ( *(p+1) && *(p+1) == '#' && *(p+2) ) 446 | { 447 | unsigned long ucs = 0; 448 | ptrdiff_t delta = 0; 449 | unsigned mult = 1; 450 | 451 | if ( *(p+2) == 'x' ) 452 | { 453 | // Hexadecimal. 454 | if ( !*(p+3) ) return 0; 455 | 456 | const char* q = p+3; 457 | q = strchr( q, ';' ); 458 | 459 | if ( !q || !*q ) return 0; 460 | 461 | delta = q-p; 462 | --q; 463 | 464 | while ( *q != 'x' ) 465 | { 466 | if ( *q >= '0' && *q <= '9' ) 467 | ucs += mult * (*q - '0'); 468 | else if ( *q >= 'a' && *q <= 'f' ) 469 | ucs += mult * (*q - 'a' + 10); 470 | else if ( *q >= 'A' && *q <= 'F' ) 471 | ucs += mult * (*q - 'A' + 10 ); 472 | else 473 | return 0; 474 | mult *= 16; 475 | --q; 476 | } 477 | } 478 | else 479 | { 480 | // Decimal. 481 | if ( !*(p+2) ) return 0; 482 | 483 | const char* q = p+2; 484 | q = strchr( q, ';' ); 485 | 486 | if ( !q || !*q ) return 0; 487 | 488 | delta = q-p; 489 | --q; 490 | 491 | while ( *q != '#' ) 492 | { 493 | if ( *q >= '0' && *q <= '9' ) 494 | ucs += mult * (*q - '0'); 495 | else 496 | return 0; 497 | mult *= 10; 498 | --q; 499 | } 500 | } 501 | if ( encoding == TIXML_ENCODING_UTF8 ) 502 | { 503 | // convert the UCS to UTF-8 504 | ConvertUTF32ToUTF8( ucs, value, length ); 505 | } 506 | else 507 | { 508 | *value = (char)ucs; 509 | *length = 1; 510 | } 511 | return p + delta + 1; 512 | } 513 | 514 | // Now try to match it. 515 | for( i=0; iappend( cArr, len ); 594 | } 595 | } 596 | else 597 | { 598 | bool whitespace = false; 599 | 600 | // Remove leading white space: 601 | p = SkipWhiteSpace( p, encoding ); 602 | while ( p && *p 603 | && !StringEqual( p, endTag, caseInsensitive, encoding ) ) 604 | { 605 | if ( *p == '\r' || *p == '\n' ) 606 | { 607 | whitespace = true; 608 | ++p; 609 | } 610 | else if ( IsWhiteSpace( *p ) ) 611 | { 612 | whitespace = true; 613 | ++p; 614 | } 615 | else 616 | { 617 | // If we've found whitespace, add it before the 618 | // new character. Any whitespace just becomes a space. 619 | if ( whitespace ) 620 | { 621 | (*text) += ' '; 622 | whitespace = false; 623 | } 624 | int len; 625 | char cArr[4] = { 0, 0, 0, 0 }; 626 | p = GetChar( p, cArr, &len, encoding ); 627 | if ( len == 1 ) 628 | (*text) += cArr[0]; // more efficient 629 | else 630 | text->append( cArr, len ); 631 | } 632 | } 633 | } 634 | if ( p && *p ) 635 | p += strlen( endTag ); 636 | return ( p && *p ) ? p : 0; 637 | } 638 | 639 | #ifdef TIXML_USE_STL 640 | 641 | void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) 642 | { 643 | // The basic issue with a document is that we don't know what we're 644 | // streaming. Read something presumed to be a tag (and hope), then 645 | // identify it, and call the appropriate stream method on the tag. 646 | // 647 | // This "pre-streaming" will never read the closing ">" so the 648 | // sub-tag can orient itself. 649 | 650 | if ( !StreamTo( in, '<', tag ) ) 651 | { 652 | SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); 653 | return; 654 | } 655 | 656 | while ( in->good() ) 657 | { 658 | int tagIndex = (int) tag->length(); 659 | while ( in->good() && in->peek() != '>' ) 660 | { 661 | int c = in->get(); 662 | if ( c <= 0 ) 663 | { 664 | SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); 665 | break; 666 | } 667 | (*tag) += (char) c; 668 | } 669 | 670 | if ( in->good() ) 671 | { 672 | // We now have something we presume to be a node of 673 | // some sort. Identify it, and call the node to 674 | // continue streaming. 675 | TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING ); 676 | 677 | if ( node ) 678 | { 679 | node->StreamIn( in, tag ); 680 | bool isElement = node->ToElement() != 0; 681 | delete node; 682 | node = 0; 683 | 684 | // If this is the root element, we're done. Parsing will be 685 | // done by the >> operator. 686 | if ( isElement ) 687 | { 688 | return; 689 | } 690 | } 691 | else 692 | { 693 | SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); 694 | return; 695 | } 696 | } 697 | } 698 | // We should have returned sooner. 699 | SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); 700 | } 701 | 702 | #endif 703 | 704 | const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding ) 705 | { 706 | ClearError(); 707 | 708 | // Parse away, at the document level. Since a document 709 | // contains nothing but other tags, most of what happens 710 | // here is skipping white space. 711 | if ( !p || !*p ) 712 | { 713 | SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); 714 | return 0; 715 | } 716 | 717 | // Note that, for a document, this needs to come 718 | // before the while space skip, so that parsing 719 | // starts from the pointer we are given. 720 | location.Clear(); 721 | if ( prevData ) 722 | { 723 | location.row = prevData->cursor.row; 724 | location.col = prevData->cursor.col; 725 | } 726 | else 727 | { 728 | location.row = 0; 729 | location.col = 0; 730 | } 731 | TiXmlParsingData data( p, TabSize(), location.row, location.col ); 732 | location = data.Cursor(); 733 | 734 | if ( encoding == TIXML_ENCODING_UNKNOWN ) 735 | { 736 | // Check for the Microsoft UTF-8 lead bytes. 737 | const unsigned char* pU = (const unsigned char*)p; 738 | if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0 739 | && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1 740 | && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 ) 741 | { 742 | encoding = TIXML_ENCODING_UTF8; 743 | useMicrosoftBOM = true; 744 | } 745 | } 746 | 747 | p = SkipWhiteSpace( p, encoding ); 748 | if ( !p ) 749 | { 750 | SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); 751 | return 0; 752 | } 753 | 754 | while ( p && *p ) 755 | { 756 | TiXmlNode* node = Identify( p, encoding ); 757 | if ( node ) 758 | { 759 | p = node->Parse( p, &data, encoding ); 760 | LinkEndChild( node ); 761 | } 762 | else 763 | { 764 | break; 765 | } 766 | 767 | // Did we get encoding info? 768 | if ( encoding == TIXML_ENCODING_UNKNOWN 769 | && node->ToDeclaration() ) 770 | { 771 | TiXmlDeclaration* dec = node->ToDeclaration(); 772 | const char* enc = dec->Encoding(); 773 | assert( enc ); 774 | 775 | if ( *enc == 0 ) 776 | encoding = TIXML_ENCODING_UTF8; 777 | else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) ) 778 | encoding = TIXML_ENCODING_UTF8; 779 | else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) ) 780 | encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice 781 | else 782 | encoding = TIXML_ENCODING_LEGACY; 783 | } 784 | 785 | p = SkipWhiteSpace( p, encoding ); 786 | } 787 | 788 | // Was this empty? 789 | if ( !firstChild ) { 790 | SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); 791 | return 0; 792 | } 793 | 794 | // All is well. 795 | return p; 796 | } 797 | 798 | void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding ) 799 | { 800 | // The first error in a chain is more accurate - don't set again! 801 | if ( error ) 802 | return; 803 | 804 | assert( err > 0 && err < TIXML_ERROR_STRING_COUNT ); 805 | error = true; 806 | errorId = err; 807 | errorDesc = errorString[ errorId ]; 808 | 809 | errorLocation.Clear(); 810 | if ( pError && data ) 811 | { 812 | data->Stamp( pError, encoding ); 813 | errorLocation = data->Cursor(); 814 | } 815 | } 816 | 817 | 818 | TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding ) 819 | { 820 | TiXmlNode* returnNode = 0; 821 | 822 | p = SkipWhiteSpace( p, encoding ); 823 | if( !p || !*p || *p != '<' ) 824 | { 825 | return 0; 826 | } 827 | 828 | p = SkipWhiteSpace( p, encoding ); 829 | 830 | if ( !p || !*p ) 831 | { 832 | return 0; 833 | } 834 | 835 | // What is this thing? 836 | // - Elements start with a letter or underscore, but xml is reserved. 837 | // - Comments: "; 1351 | 1352 | if ( !StringEqual( p, startTag, false, encoding ) ) 1353 | { 1354 | if ( document ) 1355 | document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); 1356 | return 0; 1357 | } 1358 | p += strlen( startTag ); 1359 | 1360 | // [ 1475201 ] TinyXML parses entities in comments 1361 | // Oops - ReadText doesn't work, because we don't want to parse the entities. 1362 | // p = ReadText( p, &value, false, endTag, false, encoding ); 1363 | // 1364 | // from the XML spec: 1365 | /* 1366 | [Definition: Comments may appear anywhere in a document outside other markup; in addition, 1367 | they may appear within the document type declaration at places allowed by the grammar. 1368 | They are not part of the document's character data; an XML processor MAY, but need not, 1369 | make it possible for an application to retrieve the text of comments. For compatibility, 1370 | the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity 1371 | references MUST NOT be recognized within comments. 1372 | 1373 | An example of a comment: 1374 | 1375 | 1376 | */ 1377 | 1378 | value = ""; 1379 | // Keep all the white space. 1380 | while ( p && *p && !StringEqual( p, endTag, false, encoding ) ) 1381 | { 1382 | value.append( p, 1 ); 1383 | ++p; 1384 | } 1385 | if ( p && *p ) 1386 | p += strlen( endTag ); 1387 | 1388 | return p; 1389 | } 1390 | 1391 | 1392 | const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) 1393 | { 1394 | p = SkipWhiteSpace( p, encoding ); 1395 | if ( !p || !*p ) return 0; 1396 | 1397 | if ( data ) 1398 | { 1399 | data->Stamp( p, encoding ); 1400 | location = data->Cursor(); 1401 | } 1402 | // Read the name, the '=' and the value. 1403 | const char* pErr = p; 1404 | p = ReadName( p, &name, encoding ); 1405 | if ( !p || !*p ) 1406 | { 1407 | if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); 1408 | return 0; 1409 | } 1410 | p = SkipWhiteSpace( p, encoding ); 1411 | if ( !p || !*p || *p != '=' ) 1412 | { 1413 | if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); 1414 | return 0; 1415 | } 1416 | 1417 | ++p; // skip '=' 1418 | p = SkipWhiteSpace( p, encoding ); 1419 | if ( !p || !*p ) 1420 | { 1421 | if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); 1422 | return 0; 1423 | } 1424 | 1425 | const char* end; 1426 | const char SINGLE_QUOTE = '\''; 1427 | const char DOUBLE_QUOTE = '\"'; 1428 | 1429 | if ( *p == SINGLE_QUOTE ) 1430 | { 1431 | ++p; 1432 | end = "\'"; // single quote in string 1433 | p = ReadText( p, &value, false, end, false, encoding ); 1434 | } 1435 | else if ( *p == DOUBLE_QUOTE ) 1436 | { 1437 | ++p; 1438 | end = "\""; // double quote in string 1439 | p = ReadText( p, &value, false, end, false, encoding ); 1440 | } 1441 | else 1442 | { 1443 | // All attribute values should be in single or double quotes. 1444 | // But this is such a common error that the parser will try 1445 | // its best, even without them. 1446 | value = ""; 1447 | while ( p && *p // existence 1448 | && !IsWhiteSpace( *p ) // whitespace 1449 | && *p != '/' && *p != '>' ) // tag end 1450 | { 1451 | if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) { 1452 | // [ 1451649 ] Attribute values with trailing quotes not handled correctly 1453 | // We did not have an opening quote but seem to have a 1454 | // closing one. Give up and throw an error. 1455 | if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); 1456 | return 0; 1457 | } 1458 | value += *p; 1459 | ++p; 1460 | } 1461 | } 1462 | return p; 1463 | } 1464 | 1465 | #ifdef TIXML_USE_STL 1466 | void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag ) 1467 | { 1468 | while ( in->good() ) 1469 | { 1470 | int c = in->peek(); 1471 | if ( !cdata && (c == '<' ) ) 1472 | { 1473 | return; 1474 | } 1475 | if ( c <= 0 ) 1476 | { 1477 | TiXmlDocument* document = GetDocument(); 1478 | if ( document ) 1479 | document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); 1480 | return; 1481 | } 1482 | 1483 | (*tag) += (char) c; 1484 | in->get(); // "commits" the peek made above 1485 | 1486 | if ( cdata && c == '>' && tag->size() >= 3 ) { 1487 | size_t len = tag->size(); 1488 | if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) { 1489 | // terminator of cdata. 1490 | return; 1491 | } 1492 | } 1493 | } 1494 | } 1495 | #endif 1496 | 1497 | const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) 1498 | { 1499 | value = ""; 1500 | TiXmlDocument* document = GetDocument(); 1501 | 1502 | if ( data ) 1503 | { 1504 | data->Stamp( p, encoding ); 1505 | location = data->Cursor(); 1506 | } 1507 | 1508 | const char* const startTag = ""; 1510 | 1511 | if ( cdata || StringEqual( p, startTag, false, encoding ) ) 1512 | { 1513 | cdata = true; 1514 | 1515 | if ( !StringEqual( p, startTag, false, encoding ) ) 1516 | { 1517 | if ( document ) 1518 | document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); 1519 | return 0; 1520 | } 1521 | p += strlen( startTag ); 1522 | 1523 | // Keep all the white space, ignore the encoding, etc. 1524 | while ( p && *p 1525 | && !StringEqual( p, endTag, false, encoding ) 1526 | ) 1527 | { 1528 | value += *p; 1529 | ++p; 1530 | } 1531 | 1532 | TIXML_STRING dummy; 1533 | p = ReadText( p, &dummy, false, endTag, false, encoding ); 1534 | return p; 1535 | } 1536 | else 1537 | { 1538 | bool ignoreWhite = true; 1539 | 1540 | const char* end = "<"; 1541 | p = ReadText( p, &value, ignoreWhite, end, false, encoding ); 1542 | if ( p && *p ) 1543 | return p-1; // don't truncate the '<' 1544 | return 0; 1545 | } 1546 | } 1547 | 1548 | #ifdef TIXML_USE_STL 1549 | void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag ) 1550 | { 1551 | while ( in->good() ) 1552 | { 1553 | int c = in->get(); 1554 | if ( c <= 0 ) 1555 | { 1556 | TiXmlDocument* document = GetDocument(); 1557 | if ( document ) 1558 | document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); 1559 | return; 1560 | } 1561 | (*tag) += (char) c; 1562 | 1563 | if ( c == '>' ) 1564 | { 1565 | // All is well. 1566 | return; 1567 | } 1568 | } 1569 | } 1570 | #endif 1571 | 1572 | const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding ) 1573 | { 1574 | p = SkipWhiteSpace( p, _encoding ); 1575 | // Find the beginning, find the end, and look for 1576 | // the stuff in-between. 1577 | TiXmlDocument* document = GetDocument(); 1578 | if ( !p || !*p || !StringEqual( p, "SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); 1581 | return 0; 1582 | } 1583 | if ( data ) 1584 | { 1585 | data->Stamp( p, _encoding ); 1586 | location = data->Cursor(); 1587 | } 1588 | p += 5; 1589 | 1590 | version = ""; 1591 | encoding = ""; 1592 | standalone = ""; 1593 | 1594 | while ( p && *p ) 1595 | { 1596 | if ( *p == '>' ) 1597 | { 1598 | ++p; 1599 | return p; 1600 | } 1601 | 1602 | p = SkipWhiteSpace( p, _encoding ); 1603 | if ( StringEqual( p, "version", true, _encoding ) ) 1604 | { 1605 | TiXmlAttribute attrib; 1606 | p = attrib.Parse( p, data, _encoding ); 1607 | version = attrib.Value(); 1608 | } 1609 | else if ( StringEqual( p, "encoding", true, _encoding ) ) 1610 | { 1611 | TiXmlAttribute attrib; 1612 | p = attrib.Parse( p, data, _encoding ); 1613 | encoding = attrib.Value(); 1614 | } 1615 | else if ( StringEqual( p, "standalone", true, _encoding ) ) 1616 | { 1617 | TiXmlAttribute attrib; 1618 | p = attrib.Parse( p, data, _encoding ); 1619 | standalone = attrib.Value(); 1620 | } 1621 | else 1622 | { 1623 | // Read over whatever it is. 1624 | while( p && *p && *p != '>' && !IsWhiteSpace( *p ) ) 1625 | ++p; 1626 | } 1627 | } 1628 | return 0; 1629 | } 1630 | 1631 | bool TiXmlText::Blank() const 1632 | { 1633 | for ( unsigned i=0; i 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {ED30C015-5EB9-48F7-9B59-C2D4DA0F8F0E} 15 | Win32Proj 16 | XMLLuaToCPP 17 | 18 | 19 | 20 | Application 21 | true 22 | v140 23 | MultiByte 24 | 25 | 26 | Application 27 | false 28 | v140 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | .\Bin 45 | 46 | 47 | false 48 | 49 | 50 | 51 | 52 | 53 | Level3 54 | Disabled 55 | WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 56 | true 57 | .\TinyXML 58 | 59 | 60 | Console 61 | true 62 | 63 | 64 | 65 | 66 | Level3 67 | 68 | 69 | MaxSpeed 70 | true 71 | true 72 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 73 | true 74 | 75 | 76 | Console 77 | true 78 | true 79 | true 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /XMLLuaToCPP/XMLLuaToCPP.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {3efb6b37-f710-4e55-88af-168cdf97898d} 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 头文件 26 | 27 | 28 | 头文件 29 | 30 | 31 | TinyXML 32 | 33 | 34 | TinyXML 35 | 36 | 37 | 头文件 38 | 39 | 40 | 头文件 41 | 42 | 43 | 头文件 44 | 45 | 46 | 头文件 47 | 48 | 49 | 头文件 50 | 51 | 52 | 53 | 54 | 源文件 55 | 56 | 57 | 源文件 58 | 59 | 60 | TinyXML 61 | 62 | 63 | TinyXML 64 | 65 | 66 | TinyXML 67 | 68 | 69 | TinyXML 70 | 71 | 72 | 源文件 73 | 74 | 75 | 源文件 76 | 77 | 78 | 源文件 79 | 80 | 81 | 源文件 82 | 83 | 84 | -------------------------------------------------------------------------------- /XMLLuaToCPP/XMLLuaToCPP.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | .\Bin 5 | WindowsLocalDebugger 6 | 7 | -------------------------------------------------------------------------------- /XMLLuaToCPP/XmlOpeation.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freeeyes/XMLLua2Cpp/3dad76a8eb95ab80f2bed588ef93d5220085e208/XMLLuaToCPP/XmlOpeation.cpp -------------------------------------------------------------------------------- /XMLLuaToCPP/XmlOpeation.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freeeyes/XMLLua2Cpp/3dad76a8eb95ab80f2bed588ef93d5220085e208/XMLLuaToCPP/XmlOpeation.h -------------------------------------------------------------------------------- /XMLLuaToCPP/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freeeyes/XMLLua2Cpp/3dad76a8eb95ab80f2bed588ef93d5220085e208/XMLLuaToCPP/stdafx.cpp -------------------------------------------------------------------------------- /XMLLuaToCPP/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freeeyes/XMLLua2Cpp/3dad76a8eb95ab80f2bed588ef93d5220085e208/XMLLuaToCPP/stdafx.h -------------------------------------------------------------------------------- /XMLLuaToCPP/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freeeyes/XMLLua2Cpp/3dad76a8eb95ab80f2bed588ef93d5220085e208/XMLLuaToCPP/targetver.h --------------------------------------------------------------------------------