|
ConfigParserManager = {}
|
|
|
|
--解析配置中的物品
|
|
--cfg_name:表名
|
|
--id:id索引
|
|
--prop:字段
|
|
function ConfigParserManager:GetConfigGoods(cfg_name,id,prop)
|
|
if not self[cfg_name] then
|
|
self[cfg_name] = {}
|
|
end
|
|
if not self[cfg_name][id] then
|
|
self[cfg_name][id] = {}
|
|
end
|
|
if not self[cfg_name][id][prop] then
|
|
assert(Config[cfg_name],"找不到配置:" .. cfg_name)
|
|
assert(Config[cfg_name][id],"找不到配置:[" .. cfg_name.."]中的key=>"..id)
|
|
assert(Config[cfg_name][id][prop],"找不到配置:[" .. cfg_name.."]中的key=>"..id.."中的字段=>"..prop)
|
|
local config_str = Config[cfg_name][id] and Config[cfg_name][id][prop] or ""
|
|
local tbl = ErlangParser:GetInstance():Parse(config_str) or {}
|
|
local tbl_goods = {}
|
|
for k,v in ipairs(tbl) do
|
|
table.insert(tbl_goods, {style = (v[1]),typeId = tonumber(v[2]),count = tonumber(v[3])})
|
|
end
|
|
self[cfg_name][id][prop] = tbl_goods
|
|
end
|
|
return self[cfg_name][id][prop]
|
|
end
|
|
|
|
--解析配置中的属性
|
|
--cfg_name:表名
|
|
--id:id索引
|
|
--prop:字段
|
|
function ConfigParserManager:GetConfigAttr(cfg_name,id,prop)
|
|
if not self[cfg_name] then
|
|
self[cfg_name] = {}
|
|
end
|
|
if not self[cfg_name][id] then
|
|
self[cfg_name][id] = {}
|
|
end
|
|
if not self[cfg_name][id][prop] then
|
|
assert(Config[cfg_name],"找不到配置:" .. cfg_name)
|
|
assert(Config[cfg_name][id],"找不到配置:[" .. cfg_name.."]中的key=>"..id)
|
|
assert(Config[cfg_name][id][prop],"找不到配置:[" .. cfg_name.."]中的key=>"..id.."中的字段=>"..prop)
|
|
local config_str = Config[cfg_name][id] and Config[cfg_name][id][prop] or ""
|
|
local tbl = ErlangParser:GetInstance():Parse(config_str) or {}
|
|
local attr_tbl = {}
|
|
for k,v in ipairs(tbl) do
|
|
table.insert(attr_tbl, {attr_id = tonumber(v[1]), val = tonumber(v[2])})
|
|
end
|
|
self[cfg_name][id][prop] = attr_tbl
|
|
end
|
|
return self[cfg_name][id][prop]
|
|
end
|
|
|
|
--解析配置 直接保存解析结果
|
|
--cfg_name:表名
|
|
--id:id索引
|
|
--prop:字段
|
|
function ConfigParserManager:GetConfigParse(cfg_name,id,prop)
|
|
if not self[cfg_name] then
|
|
self[cfg_name] = {}
|
|
end
|
|
if not self[cfg_name][id] then
|
|
self[cfg_name][id] = {}
|
|
end
|
|
if not self[cfg_name][id][prop] then
|
|
if not Config[cfg_name] then
|
|
if can_print_cmd then logWarn(string.format("找不到配置:%s", cfg_name)) end
|
|
return nil
|
|
end
|
|
if not Config[cfg_name][id] then
|
|
if can_print_cmd then logWarn(string.format("找不到配置:[%s]中的key=>%d", cfg_name, id)) end
|
|
return nil
|
|
end
|
|
if not Config[cfg_name][id][prop] then
|
|
if can_print_cmd then logWarn(string.format("找不到配置:[%s]中的key=>%d中的字段=>%s", cfg_name, id, prop)) end
|
|
return nil
|
|
end
|
|
local config_str = Config[cfg_name][id] and Config[cfg_name][id][prop] or ""
|
|
local tbl = ErlangParser:GetInstance():Parse(config_str) or {}
|
|
self[cfg_name][id][prop] = tbl
|
|
end
|
|
return self[cfg_name][id][prop]
|
|
end
|