lua table打印
来源:互联网 发布:linux关闭oracle服务 编辑:程序博客网 时间:2024/06/06 14:24
function table.tostring(t, forStr, tPt) if type(t) == "string" or type(t) == "number" then return t elseif type(t) ~= "table" then return type(t) end local oForStr = forStr or "" local cForStr = forStr and forStr .. "\t" or "\t" local szRet = forStr and "{\n" or "\n{\n" local function formatPrint(key, value) local function dealWithKey() if "number" == type(key) then szRet = szRet .. cForStr .. "[" .. key .. "]" .. " = " elseif "string" == type(key) then szRet = szRet .. cForStr .. "[\"" .. key .. "\"]" .. " = " elseif "table" == type(key) then if key == t then szRet = szRet .. cForStr .. "[self]" .. " = " else szRet = szRet .. cForStr .. "[" .. table.tostring(key, cForStr) .. "]" .. " = " end else--if "userdata" == type(key) then szRet = szRet .. cForStr .. "[" .. type(key) .. "]" .. " = " end end local function dealWithValue() if "number" == type(value) then szRet = szRet .. value .. ",\n" elseif "string" == type(value) then szRet = szRet .. "\"" .. value .. "\"" .. ",\n" elseif "table" == type(value) then if value == t then szRet = szRet .. "self" .. ",\n" else szRet = szRet .. table.tostring(value, cForStr, {t}) .. ",\n" end elseif "boolean" == type(value) then szRet = szRet .. (value and "true" or "false") .. ",\n" else--if "userdata" == type(value) then szRet = szRet .. type(value) .. ",\n" end end dealWithKey() dealWithValue() end table.foreach(t, formatPrint) szRet = szRet .. oForStr .. "}" return szRetend
0 0
- lua table 格式化打印
- 打印lua中的table
- lua 打印 table
- Lua打印table
- lua table打印
- lua调试打印table算法
- Lua打印Table内容(日期)
- Lua打印Table内容(日期)
- Lua打印table升级版
- Lua封装打印Table函数
- lua树型打印table
- Lua 自定义打印table函数
- [福利]Lua 打印table代码
- cocos2dx 打印table,打印lua堆栈,重载lua代码
- Lua中打印Table的方法
- 【步兵 lua】尾递归 打印table
- lua中打印所以类型功能实现table嵌套table
- lua中打印所以类型功能实现table嵌套table
- 2017京东春招C/C++编程题(1)——站队
- Spring框架
- Python通过pymsql操作Mysql数据库环境搭建
- 《后台开发核心技术与应用实践》(三)
- Qt分割窗口QSplitter类
- lua table打印
- csharp 003引用类型及string下面常用方法
- JavaScript函数绑定Demo以及函数Currying柯里化
- 学习Javascript闭包(Closure)
- Android开发——ListView局部刷新的实现
- javaSE_07Java中类和对象-封装特性--练习
- 基于贪心算法的区间问题
- 快速排序
- SplayTree--BZOJ1500