【新增】 能够从excel,json,xml,lua等类型文件中加载 text 类型数据
parent
2b28e4de74
commit
35bafee063
|
|
@ -267,3 +267,4 @@ __pycache__/
|
||||||
|
|
||||||
/config/output_code
|
/config/output_code
|
||||||
/config/output_data
|
/config/output_data
|
||||||
|
/config/output_lua
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -13,6 +13,7 @@
|
||||||
"x12": { "x1":10},
|
"x12": { "x1":10},
|
||||||
"x13":"B",
|
"x13":"B",
|
||||||
"x14":{"__type__": "DemoD2", "x1":1, "x2":2},
|
"x14":{"__type__": "DemoD2", "x1":1, "x2":2},
|
||||||
|
"s1": {"key":"/asfa", "text":"aabbcc"},
|
||||||
"v2":{"x":1, "y":2},
|
"v2":{"x":1, "y":2},
|
||||||
"v3":{"x":1.1, "y":2.2, "z":3.4},
|
"v3":{"x":1.1, "y":2.2, "z":3.4},
|
||||||
"v4":{"x":10.1, "y":11.2, "z":12.3, "w":13.4},
|
"v4":{"x":10.1, "y":11.2, "z":12.3, "w":13.4},
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
"x12": { "x1":10},
|
"x12": { "x1":10},
|
||||||
"x13":"B",
|
"x13":"B",
|
||||||
"x14":{"__type__": "DemoD2", "x1":1, "x2":2},
|
"x14":{"__type__": "DemoD2", "x1":1, "x2":2},
|
||||||
|
"s1": {"key":"/asfa32", "text":"aabbcc22"},
|
||||||
"v2":{"x":1, "y":2},
|
"v2":{"x":1, "y":2},
|
||||||
"v3":{"x":1.1, "y":2.2, "z":3.4},
|
"v3":{"x":1.1, "y":2.2, "z":3.4},
|
||||||
"v4":{"x":10.1, "y":11.2, "z":12.3, "w":13.4},
|
"v4":{"x":10.1, "y":11.2, "z":12.3, "w":13.4},
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ return
|
||||||
x12 = {x1=1},
|
x12 = {x1=1},
|
||||||
x13 = "D",
|
x13 = "D",
|
||||||
x14 = { __type__="DemoD2", x1 = 1, x2=3},
|
x14 = { __type__="DemoD2", x1 = 1, x2=3},
|
||||||
|
s1 = { key="lua/key1", text="lua text "},
|
||||||
v2 = {x= 1,y = 2},
|
v2 = {x= 1,y = 2},
|
||||||
v3 = {x=0.1, y= 0.2,z=0.3},
|
v3 = {x=0.1, y= 0.2,z=0.3},
|
||||||
v4 = {x=1,y=2,z=3.5,w=4},
|
v4 = {x=1,y=2,z=3.5,w=4},
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -18,7 +18,7 @@
|
||||||
<x1>1</x1>
|
<x1>1</x1>
|
||||||
<x2>2</x2>
|
<x2>2</x2>
|
||||||
</x14>
|
</x14>
|
||||||
|
<s1><key>xml_key1</key><text>xml text</text></s1>
|
||||||
<v2>1,2</v2>
|
<v2>1,2</v2>
|
||||||
<v3>1.2,2.3,3.4</v3>
|
<v3>1.2,2.3,3.4</v3>
|
||||||
<v4>1.2,2.2,3.2,4.3</v4>
|
<v4>1.2,2.2,3.2,4.3</v4>
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
<x1>1</x1>
|
<x1>1</x1>
|
||||||
<x2>2</x2>
|
<x2>2</x2>
|
||||||
</x14>
|
</x14>
|
||||||
|
<s1><key>xml_key2</key><text>xml text222</text></s1>
|
||||||
<v2>1,2</v2>
|
<v2>1,2</v2>
|
||||||
<v3>1.2,2.3,3.4</v3>
|
<v3>1.2,2.3,3.4</v3>
|
||||||
<v4>1.2,2.2,3.2,4.3</v4>
|
<v4>1.2,2.2,3.2,4.3</v4>
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@
|
||||||
<var name="x13" type="DemoEnum"/>
|
<var name="x13" type="DemoEnum"/>
|
||||||
<var name="x14" type="DemoDynamic" sep=","/>多态数据结构
|
<var name="x14" type="DemoDynamic" sep=","/>多态数据结构
|
||||||
|
|
||||||
|
<var name="s1" type="text"/>
|
||||||
|
|
||||||
<var name="v2" type="vector2"/>
|
<var name="v2" type="vector2"/>
|
||||||
<var name="v3" type="vector3"/>
|
<var name="v3" type="vector3"/>
|
||||||
<var name="v4" type="vector4"/>
|
<var name="v4" type="vector4"/>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
return
|
|
||||||
{
|
|
||||||
[1] = {x4=1,x1=true,x2=3,x3=128,x5=11223344,x6=1.2,x7=1.23432,x8_0=12312,x8=112233,x9=223344,x10='hq',x12={x1=10,},x13=2,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=1.1,y=2.2,z=3.4},v4={x=10.1,y=11.2,z=12.3,w=13.4},t1=-28800,k1={1,2,},k2={2,3,},k3={1,3,},k4={1,5,},k5={1,6,},k6={1,7,},k7={2,3,},k8={[2]=2,[4]=10,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},},},
|
|
||||||
[2] = {x4=2,x1=true,x2=3,x3=128,x5=11223344,x6=1.2,x7=1.23432,x8_0=12312,x8=112233,x9=223344,x10='hq',x12={x1=10,},x13=2,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=1.1,y=2.2,z=3.4},v4={x=10.1,y=11.2,z=12.3,w=13.4},t1=-28800,k1={1,2,},k2={2,3,},k3={1,3,},k4={1,5,},k5={1,6,},k6={1,7,},k7={2,3,},k8={[2]=2,[4]=10,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},},},
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
return
|
|
||||||
{
|
|
||||||
[1122] = {x4=1122,x1=false,x2=2,x3=128,x5=112233445566,x6=1.3,x7=1122,x8_0=13,x8=12,x9=123,x10='yf',x12={x1=1,},x13=5,x14={ _name='test.DemoD2',x1=1,x2=3,},v2={x=1,y=2},v3={x=0.1,y=0.2,z=0.3},v4={x=1,y=2,z=3.5,w=4},t1=-28800,k1={1,2,},k2={2,3,},k3={3,4,},k4={1,2,},k5={1,3,},k6={1,2,},k7={1,8,},k8={[2]=10,[3]=12,},k9={{y1=1,y2=true,},{y1=10,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=3,},},},
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
return
|
|
||||||
{
|
|
||||||
[1] = {x4=1,x1=true,x2=4,x3=128,x5=112233445566,x6=1.3,x7=1112232.43123,x8_0=123,x8=112233,x9=112334,x10='yf',x12={x1=1,},x13=4,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=1.2,y=2.3,z=3.4},v4={x=1.2,y=2.2,z=3.2,w=4.3},t1=-28800,k1={1,2,},k2={1,2,},k3={1,2,},k4={1,2,},k5={1,2,},k6={1,2,},k7={1,3,},k8={[2]=10,[3]=30,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},},},
|
|
||||||
[2] = {x4=2,x1=true,x2=4,x3=128,x5=112233445566,x6=1.3,x7=1112232.43123,x8_0=123,x8=112233,x9=112334,x10='yf',x12={x1=1,},x13=4,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=1.2,y=2.3,z=3.4},v4={x=1.2,y=2.2,z=3.2,w=4.3},t1=-28800,k1={1,2,},k2={1,2,},k3={1,2,},k4={1,2,},k5={1,2,},k6={1,2,},k7={1,3,},k8={[2]=10,[3]=30,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},},},
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
return
|
|
||||||
{
|
|
||||||
[1] = {x4=10000,x1=true,x2=5,x3=1,x5=13234234234,x6=1.28,x7=1.23457891,x8_0=1234,x8=1234,x9=111111111,x10='huang',x12={x1=1988,},x13=1,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=2,y=3,z=4},v4={x=10.2,y=2.3,z=3.4,w=12.8},t1=935460549,k1={1,2,3,},k2={1,2,4,},k3={1,2,5,},k4={1,2,6,},k5={1,2,7,},k6={1,2,8,},k7={1,2,9,},k8={[1]=2,[3]=4,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},{ _name='test.DemoE1',x1=1,x3=2,x4=3,},},},
|
|
||||||
[3] = {x4=10001,x1=true,x2=5,x3=3,x5=13234234234,x6=1.28,x7=1.23457891,x8_0=1234,x8=1234,x9=111111111,x10='huang',x12={x1=1988,},x13=1,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=2,y=3,z=4},v4={x=10.2,y=2.3,z=3.4,w=12.8},t1=935460549,k1={1,2,3,},k2={1,2,4,},k3={1,2,5,},k4={1,2,6,},k5={1,2,7,},k6={1,2,8,},k7={1,2,9,},k8={[1]=2,[3]=4,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},{ _name='test.DemoE1',x1=1,x3=2,x4=5,},},},
|
|
||||||
[4] = {x4=10002,x1=true,x2=5,x3=4,x5=13234234234,x6=1.28,x7=1.23457891,x8_0=1234,x8=1234,x9=111111111,x10='huang',x12={x1=1988,},x13=1,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=2,y=3,z=4},v4={x=10.2,y=2.3,z=3.4,w=12.8},t1=1577808000,k1={1,2,3,},k2={1,2,4,},k3={1,2,5,},k4={1,2,6,},k5={1,2,7,},k6={1,2,8,},k7={1,2,9,},k8={[1]=2,[3]=4,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},{ _name='test.DemoE1',x1=1,x3=2,x4=6,},},},
|
|
||||||
[5] = {x4=10003,x1=true,x2=5,x3=5,x5=13234234234,x6=1.28,x7=1.23457891,x8_0=1234,x8=1234,x9=111111111,x10='huang',x12={x1=1988,},x13=1,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=2,y=3,z=4},v4={x=10.2,y=2.3,z=3.4,w=12.8},t1=935460549,k1={1,2,3,},k2={1,2,4,},k3={1,2,5,},k4={1,2,6,},k5={1,2,7,},k6={1,2,8,},k7={1,2,9,},k8={[1]=2,[3]=4,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},{ _name='test.DemoE1',x1=1,x3=2,x4=7,},},},
|
|
||||||
[6] = {x4=10001,x1=true,x2=5,x3=6,x5=13234234234,x6=1.28,x7=1.23457891,x8_0=1234,x8=1234,x9=111111111,x10='huang',x12={x1=1988,},x13=1,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=2,y=3,z=4},v4={x=10.2,y=2.3,z=3.4,w=12.8},t1=1577808000,k1={1,2,3,},k2={1,2,4,},k3={1,2,5,},k4={1,2,6,},k5={1,2,7,},k6={1,2,8,},k7={1,2,9,},k8={[1]=2,[3]=4,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},{ _name='test.DemoE1',x1=1,x3=2,x4=8,},},},
|
|
||||||
[7] = {x4=10002,x1=true,x2=5,x3=7,x5=13234234234,x6=1.28,x7=1.23457891,x8_0=1234,x8=1234,x9=111111111,x10='huang',x12={x1=1988,},x13=1,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=2,y=3,z=4},v4={x=10.2,y=2.3,z=3.4,w=12.8},t1=935460549,k1={1,2,3,},k2={1,2,4,},k3={1,2,5,},k4={1,2,6,},k5={1,2,7,},k6={1,2,8,},k7={1,2,9,},k8={[1]=2,[3]=4,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},{ _name='test.DemoE1',x1=1,x3=2,x4=9,},},},
|
|
||||||
[8] = {x4=10003,x1=true,x2=5,x3=8,x5=2,x6=1.28,x7=1.23457891,x8_0=1234,x8=1234,x9=111111111,x10='huang',x12={x1=1988,},x13=1,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=2,y=3,z=4},v4={x=10.2,y=2.3,z=3.4,w=12.8},t1=1577808000,k1={1,2,3,},k2={1,2,4,},k3={1,2,5,},k4={1,2,6,},k5={1,2,7,},k6={1,2,8,},k7={1,2,9,},k8={[1]=2,[3]=4,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},{ _name='test.DemoE1',x1=1,x3=2,x4=10,},},},
|
|
||||||
[9] = {x4=1,x1=true,x2=5,x3=9,x5=13234234234,x6=1.28,x7=1.23457891,x8_0=1234,x8=1234,x9=111111111,x10='huang',x12={x1=1988,},x13=1,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=2,y=3,z=4},v4={x=10.2,y=2.3,z=3.4,w=12.8},t1=935460549,k1={1,2,3,},k2={1,2,4,},k3={1,2,5,},k4={1,2,6,},k5={1,2,7,},k6={1,2,8,},k7={1,2,9,},k8={[1]=2,[3]=4,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},{ _name='test.DemoE1',x1=1,x3=2,x4=11,},},},
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
return
|
|
||||||
{
|
|
||||||
[1] = {id=1,name='xxx',one_rows={{id=1,x=2,},},multi_rows1={{id=1,x=2,},},multi_rows2={{id=1,x=2,},},multi_rows3={{id=1,x=2,y=3,},},multi_rows4={[1]={id=1,x=2,y=3,},},},
|
|
||||||
[2] = {id=2,name='xxx',one_rows={{id=2,x=4,},},multi_rows1={{id=2,x=4,},},multi_rows2={{id=3,x=4,},{id=3,x=4,},},multi_rows3={{id=2,x=3,y=4,},{id=2,x=3,y=4,},},multi_rows4={[2]={id=4,x=5,y=4,},},},
|
|
||||||
[3] = {id=3,name='ds',one_rows={{id=1,x=2,},},multi_rows1={{id=1,x=2,},{id=2,x=4,},},multi_rows2={{id=3,x=4,},{id=3,x=4,},},multi_rows3={{id=1,x=2,y=3,},{id=2,x=3,y=4,},},multi_rows4={[1]={id=1,x=2,y=3,},[2]={id=4,x=5,y=4,},[3]={id=4,x=5,y=4,},},},
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
return
|
|
||||||
{
|
|
||||||
[1] = {id=1,name='xxx',x1={y2={z2=2,z3=3,},y3=4,},x2={{z2=1,z3=2,},{z2=3,z3=4,},},x3={{z2=1,z3=2,},{z2=3,z3=4,},},},
|
|
||||||
}
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
return
|
|
||||||
{id=5,name='aabbcc',date={ _name='test.DemoD5',x1=1,time={start_time=398966400,end_time=936806400,},},}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
return
|
|
||||||
{
|
|
||||||
[128] =
|
|
||||||
{
|
|
||||||
[1] = {x4=1,x1=true,x2=3,x3=128,x5=11223344,x6=1.2,x7=1.23432,x8_0=12312,x8=112233,x9=223344,x10='hq',x12={x1=10,},x13=2,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=1.1,y=2.2,z=3.4},v4={x=10.1,y=11.2,z=12.3,w=13.4},t1=-28800,k1={1,2,},k2={2,3,},k3={1,3,},k4={1,5,},k5={1,6,},k6={1,7,},k7={2,3,},k8={[2]=2,[4]=10,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},},},
|
|
||||||
[2] = {x4=2,x1=true,x2=3,x3=128,x5=11223344,x6=1.2,x7=1.23432,x8_0=12312,x8=112233,x9=223344,x10='hq',x12={x1=10,},x13=2,x14={ _name='test.DemoD2',x1=1,x2=2,},v2={x=1,y=2},v3={x=1.1,y=2.2,z=3.4},v4={x=10.1,y=11.2,z=12.3,w=13.4},t1=-28800,k1={1,2,},k2={2,3,},k3={1,3,},k4={1,5,},k5={1,6,},k6={1,7,},k7={2,3,},k8={[2]=2,[4]=10,},k9={{y1=1,y2=true,},{y1=2,y2=false,},},k15={{ _name='test.DemoD2',x1=1,x2=2,},},},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
@ -1,331 +0,0 @@
|
||||||
|
|
||||||
--[[------------------------------------------------------------------------------
|
|
||||||
-- <auto-generated>
|
|
||||||
-- This code was generated by a tool.
|
|
||||||
-- Changes to this file may cause incorrect behavior and will be lost if
|
|
||||||
-- the code is regenerated.
|
|
||||||
-- </auto-generated>
|
|
||||||
--]]------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local consts =
|
|
||||||
{
|
|
||||||
---@class test.DemoConst
|
|
||||||
---@field public x1 int
|
|
||||||
---@field public x2 long
|
|
||||||
---@field public x3 float
|
|
||||||
---@field public x4 double
|
|
||||||
['test.DemoConst'] = { x1=0, x2=3242, x3=444.3, x4=55.3, };
|
|
||||||
}
|
|
||||||
|
|
||||||
local enums =
|
|
||||||
{
|
|
||||||
---@class test.DemoEnum
|
|
||||||
---@field public A int
|
|
||||||
---@field public B int
|
|
||||||
---@field public C int
|
|
||||||
---@field public D int
|
|
||||||
['test.DemoEnum'] = { A=1, B=2, C=4, D=5, };
|
|
||||||
---@class test.ETestUeType
|
|
||||||
---@field public WHITE int
|
|
||||||
---@field public BLACK int
|
|
||||||
['test.ETestUeType'] = { WHITE=0, BLACK=1, };
|
|
||||||
---@class test.ETestEmptyEnum
|
|
||||||
['test.ETestEmptyEnum'] = { };
|
|
||||||
---@class test.ETestEmptyEnum2
|
|
||||||
---@field public SMALL_THAN_256 int
|
|
||||||
---@field public X_256 int
|
|
||||||
---@field public X_257 int
|
|
||||||
['test.ETestEmptyEnum2'] = { SMALL_THAN_256=255, X_256=256, X_257=257, };
|
|
||||||
}
|
|
||||||
|
|
||||||
local beans = {}
|
|
||||||
---@class test.DemoType1
|
|
||||||
---@field public x1 int
|
|
||||||
beans['test.DemoType1'] =
|
|
||||||
{
|
|
||||||
{ name='x1', type='int'},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@class test.DemoDynamic
|
|
||||||
---@field public x1 int
|
|
||||||
beans['test.DemoDynamic'] =
|
|
||||||
{
|
|
||||||
{ name='x1', type='int'},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@class test.DemoD2 :test.DemoDynamic
|
|
||||||
---@field public x2 int
|
|
||||||
beans['test.DemoD2'] =
|
|
||||||
{
|
|
||||||
{ name='x1', type='int'},
|
|
||||||
{ name='x2', type='int'},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@class test.DemoD3 :test.DemoDynamic
|
|
||||||
---@field public x3 int
|
|
||||||
beans['test.DemoD3'] =
|
|
||||||
{
|
|
||||||
{ name='x1', type='int'},
|
|
||||||
{ name='x3', type='int'},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@class test.DemoE1 :test.DemoD3
|
|
||||||
---@field public x4 int
|
|
||||||
beans['test.DemoE1'] =
|
|
||||||
{
|
|
||||||
{ name='x1', type='int'},
|
|
||||||
{ name='x3', type='int'},
|
|
||||||
{ name='x4', type='int'},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@class test.DemoD5 :test.DemoDynamic
|
|
||||||
---@field public time test.DateTimeRange
|
|
||||||
beans['test.DemoD5'] =
|
|
||||||
{
|
|
||||||
{ name='x1', type='int'},
|
|
||||||
{ name='time', type='test.DateTimeRange'},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@class test.DemoE2
|
|
||||||
---@field public y1 int
|
|
||||||
---@field public y2 bool
|
|
||||||
beans['test.DemoE2'] =
|
|
||||||
{
|
|
||||||
{ name='y1', type='int'},
|
|
||||||
{ name='y2', type='bool'},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@class test.DemoType2
|
|
||||||
---@field public x4 int
|
|
||||||
---@field public x1 bool
|
|
||||||
---@field public x2 byte
|
|
||||||
---@field public x3 short
|
|
||||||
---@field public x5 long
|
|
||||||
---@field public x6 float
|
|
||||||
---@field public x7 double
|
|
||||||
---@field public x8_0 short
|
|
||||||
---@field public x8 int
|
|
||||||
---@field public x9 long
|
|
||||||
---@field public x10 string
|
|
||||||
---@field public x12 test.DemoType1
|
|
||||||
---@field public x13 test.DemoEnum
|
|
||||||
---@field public x14 test.DemoDynamic
|
|
||||||
---@field public v2 vector2
|
|
||||||
---@field public v3 vector3
|
|
||||||
---@field public v4 vector4
|
|
||||||
---@field public t1 int
|
|
||||||
---@field public k1 int[]
|
|
||||||
---@field public k2 int[]
|
|
||||||
---@field public k3 int[]
|
|
||||||
---@field public k4 int[]
|
|
||||||
---@field public k5 int[]
|
|
||||||
---@field public k6 int[]
|
|
||||||
---@field public k7 int[]
|
|
||||||
---@field public k8 table<int,int>
|
|
||||||
---@field public k9 test.DemoE2[]
|
|
||||||
---@field public k15 test.DemoDynamic[]
|
|
||||||
beans['test.DemoType2'] =
|
|
||||||
{
|
|
||||||
{ name='x4', type='int'},
|
|
||||||
{ name='x1', type='bool'},
|
|
||||||
{ name='x2', type='byte'},
|
|
||||||
{ name='x3', type='short'},
|
|
||||||
{ name='x5', type='long'},
|
|
||||||
{ name='x6', type='float'},
|
|
||||||
{ name='x7', type='double'},
|
|
||||||
{ name='x8_0', type='short'},
|
|
||||||
{ name='x8', type='int'},
|
|
||||||
{ name='x9', type='long'},
|
|
||||||
{ name='x10', type='string'},
|
|
||||||
{ name='x12', type='test.DemoType1'},
|
|
||||||
{ name='x13', type='test.DemoEnum'},
|
|
||||||
{ name='x14', type='test.DemoDynamic'},
|
|
||||||
{ name='v2', type='vector2'},
|
|
||||||
{ name='v3', type='vector3'},
|
|
||||||
{ name='v4', type='vector4'},
|
|
||||||
{ name='t1', type='int'},
|
|
||||||
{ name='k1', type='int[]'},
|
|
||||||
{ name='k2', type='int[]'},
|
|
||||||
{ name='k3', type='int[]'},
|
|
||||||
{ name='k4', type='int[]'},
|
|
||||||
{ name='k5', type='int[]'},
|
|
||||||
{ name='k6', type='int[]'},
|
|
||||||
{ name='k7', type='int[]'},
|
|
||||||
{ name='k8', type='table<int,int>'},
|
|
||||||
{ name='k9', type='test.DemoE2[]'},
|
|
||||||
{ name='k15', type='test.DemoDynamic[]'},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@class test.DateTimeRange
|
|
||||||
---@field public start_time int
|
|
||||||
---@field public end_time int
|
|
||||||
beans['test.DateTimeRange'] =
|
|
||||||
{
|
|
||||||
{ name='start_time', type='int'},
|
|
||||||
{ name='end_time', type='int'},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@class test.DemoSingletonType
|
|
||||||
---@field public id int
|
|
||||||
---@field public name string
|
|
||||||
---@field public date test.DemoDynamic
|
|
||||||
beans['test.DemoSingletonType'] =
|
|
||||||
{
|
|
||||||
{ name='id', type='int'},
|
|
||||||
{ name='name', type='string'},
|
|
||||||
{ name='date', type='test.DemoDynamic'},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@class test.MultiRowType1
|
|
||||||
---@field public id int
|
|
||||||
---@field public x int
|
|
||||||
beans['test.MultiRowType1'] =
|
|
||||||
{
|
|
||||||
{ name='id', type='int'},
|
|
||||||
{ name='x', type='int'},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@class test.MultiRowType2
|
|
||||||
---@field public id int
|
|
||||||
---@field public x int
|
|
||||||
---@field public y float
|
|
||||||
beans['test.MultiRowType2'] =
|
|
||||||
{
|
|
||||||
{ name='id', type='int'},
|
|
||||||
{ name='x', type='int'},
|
|
||||||
{ name='y', type='float'},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@class test.MultiRowRecord
|
|
||||||
---@field public id int
|
|
||||||
---@field public name string
|
|
||||||
---@field public one_rows test.MultiRowType1[]
|
|
||||||
---@field public multi_rows1 test.MultiRowType1[]
|
|
||||||
---@field public multi_rows2 test.MultiRowType1[]
|
|
||||||
---@field public multi_rows3 test.MultiRowType2[]
|
|
||||||
---@field public multi_rows4 table<int,test.MultiRowType2>
|
|
||||||
beans['test.MultiRowRecord'] =
|
|
||||||
{
|
|
||||||
{ name='id', type='int'},
|
|
||||||
{ name='name', type='string'},
|
|
||||||
{ name='one_rows', type='test.MultiRowType1[]'},
|
|
||||||
{ name='multi_rows1', type='test.MultiRowType1[]'},
|
|
||||||
{ name='multi_rows2', type='test.MultiRowType1[]'},
|
|
||||||
{ name='multi_rows3', type='test.MultiRowType2[]'},
|
|
||||||
{ name='multi_rows4', type='table<int,test.MultiRowType2>'},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@class test.TestUeType
|
|
||||||
---@field public x1 bool
|
|
||||||
---@field public x2 byte
|
|
||||||
---@field public x3 short
|
|
||||||
---@field public x4 int
|
|
||||||
---@field public x5 long
|
|
||||||
---@field public x6 float
|
|
||||||
---@field public x10 string
|
|
||||||
---@field public x12 test.DemoType1
|
|
||||||
---@field public x13 test.ETestUeType
|
|
||||||
---@field public v2 vector2
|
|
||||||
---@field public v3 vector3
|
|
||||||
---@field public v4 vector4
|
|
||||||
---@field public t1 int
|
|
||||||
---@field public k1 int[]
|
|
||||||
---@field public k2 int[]
|
|
||||||
---@field public k3 int[]
|
|
||||||
---@field public k4 int[]
|
|
||||||
---@field public k5 int[]
|
|
||||||
---@field public k6 int[]
|
|
||||||
---@field public k7 int[]
|
|
||||||
---@field public k8 table<int,int>
|
|
||||||
---@field public k9 test.DemoE2[]
|
|
||||||
beans['test.TestUeType'] =
|
|
||||||
{
|
|
||||||
{ name='x1', type='bool'},
|
|
||||||
{ name='x2', type='byte'},
|
|
||||||
{ name='x3', type='short'},
|
|
||||||
{ name='x4', type='int'},
|
|
||||||
{ name='x5', type='long'},
|
|
||||||
{ name='x6', type='float'},
|
|
||||||
{ name='x10', type='string'},
|
|
||||||
{ name='x12', type='test.DemoType1'},
|
|
||||||
{ name='x13', type='test.ETestUeType'},
|
|
||||||
{ name='v2', type='vector2'},
|
|
||||||
{ name='v3', type='vector3'},
|
|
||||||
{ name='v4', type='vector4'},
|
|
||||||
{ name='t1', type='int'},
|
|
||||||
{ name='k1', type='int[]'},
|
|
||||||
{ name='k2', type='int[]'},
|
|
||||||
{ name='k3', type='int[]'},
|
|
||||||
{ name='k4', type='int[]'},
|
|
||||||
{ name='k5', type='int[]'},
|
|
||||||
{ name='k6', type='int[]'},
|
|
||||||
{ name='k7', type='int[]'},
|
|
||||||
{ name='k8', type='table<int,int>'},
|
|
||||||
{ name='k9', type='test.DemoE2[]'},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@class test.H1
|
|
||||||
---@field public y2 test.H2
|
|
||||||
---@field public y3 int
|
|
||||||
beans['test.H1'] =
|
|
||||||
{
|
|
||||||
{ name='y2', type='test.H2'},
|
|
||||||
{ name='y3', type='int'},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@class test.H2
|
|
||||||
---@field public z2 int
|
|
||||||
---@field public z3 int
|
|
||||||
beans['test.H2'] =
|
|
||||||
{
|
|
||||||
{ name='z2', type='int'},
|
|
||||||
{ name='z3', type='int'},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@class test.MultiRowTitle
|
|
||||||
---@field public id int
|
|
||||||
---@field public name string
|
|
||||||
---@field public x1 test.H1
|
|
||||||
---@field public x2 test.H2[]
|
|
||||||
---@field public x3 test.H2[]
|
|
||||||
beans['test.MultiRowTitle'] =
|
|
||||||
{
|
|
||||||
{ name='id', type='int'},
|
|
||||||
{ name='name', type='string'},
|
|
||||||
{ name='x1', type='test.H1'},
|
|
||||||
{ name='x2', type='test.H2[]'},
|
|
||||||
{ name='x3', type='test.H2[]'},
|
|
||||||
}
|
|
||||||
|
|
||||||
---@class test.login.RoleInfo
|
|
||||||
---@field public role_id long
|
|
||||||
beans['test.login.RoleInfo'] =
|
|
||||||
{
|
|
||||||
{ name='role_id', type='long'},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
local tables =
|
|
||||||
{
|
|
||||||
{ name='TbFullTypes', file='test.TbFullTypes.bin', mode='map', index='x3', value_type='test.DemoType2' },
|
|
||||||
|
|
||||||
{ name='TbSingleton', file='test.TbSingleton.bin', mode='one', value_type='test.DemoSingletonType'},
|
|
||||||
|
|
||||||
{ name='TbDataFromJson', file='test.TbDataFromJson.bin', mode='map', index='x4', value_type='test.DemoType2' },
|
|
||||||
|
|
||||||
{ name='TbDataFromXml', file='test.TbDataFromXml.bin', mode='map', index='x4', value_type='test.DemoType2' },
|
|
||||||
|
|
||||||
{ name='TbDataFromLua', file='test.TbDataFromLua.bin', mode='map', index='x4', value_type='test.DemoType2' },
|
|
||||||
|
|
||||||
{ name='TbTwoKey', file='test.TbTwoKey.bin', mode='bmap', index1='x3', index2='x4', value_type='test.DemoType2' },
|
|
||||||
|
|
||||||
{ name='TbMultiRowRecord', file='test.TbMultiRowRecord.bin', mode='map', index='id', value_type='test.MultiRowRecord' },
|
|
||||||
|
|
||||||
{ name='TbMultiRowTitle', file='test.TbMultiRowTitle.bin', mode='map', index='id', value_type='test.MultiRowTitle' },
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return { consts = consts, enums = enums, beans = beans, tables = tables }
|
|
||||||
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
-h %LUBAN_SERVER_IP% ^
|
-h %LUBAN_SERVER_IP% ^
|
||||||
-j cfg ^
|
-j cfg ^
|
||||||
-- ^
|
-- ^
|
||||||
-d Defines/root.xml ^
|
-d Defines/__root__.xml ^
|
||||||
--input_data_dir Datas ^
|
--input_data_dir Datas ^
|
||||||
--output_data_dir output_lua ^
|
--output_data_dir output_lua ^
|
||||||
-s client ^
|
-s client ^
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,8 @@ namespace Luban.Job.Cfg.DataSources.Excel
|
||||||
|
|
||||||
public string CurrentExcelPosition => _datas[Math.Min(_curIndex, _datas.Count - 1)].ToString();
|
public string CurrentExcelPosition => _datas[Math.Min(_curIndex, _datas.Count - 1)].ToString();
|
||||||
|
|
||||||
|
public int IncludeNullAndEmptySize => _toIndex - _curIndex + 1;
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,13 @@ namespace Luban.Job.Cfg.Datas
|
||||||
{
|
{
|
||||||
public class DText : DType<string>
|
public class DText : DType<string>
|
||||||
{
|
{
|
||||||
public DText(string x) : base(x)
|
public string Key { get; }
|
||||||
|
|
||||||
|
public DText(string key, string x) : base(x)
|
||||||
{
|
{
|
||||||
|
Key = key;
|
||||||
|
|
||||||
|
System.Console.WriteLine("== text. key:{0} text:{1}", key, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply<T>(IDataActionVisitor<T> visitor, T x)
|
public override void Apply<T>(IDataActionVisitor<T> visitor, T x)
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ namespace Luban.Job.Cfg.Defs
|
||||||
|
|
||||||
public Dictionary<string, DefTable> CfgTables { get; } = new Dictionary<string, DefTable>();
|
public Dictionary<string, DefTable> CfgTables { get; } = new Dictionary<string, DefTable>();
|
||||||
|
|
||||||
|
private readonly ConcurrentDictionary<string, string> _texts = new ConcurrentDictionary<string, string>();
|
||||||
|
|
||||||
public void AddCfgTable(DefTable table)
|
public void AddCfgTable(DefTable table)
|
||||||
{
|
{
|
||||||
if (!CfgTables.TryAdd(table.FullName, table))
|
if (!CfgTables.TryAdd(table.FullName, table))
|
||||||
|
|
@ -109,6 +111,22 @@ namespace Luban.Job.Cfg.Defs
|
||||||
return refTypes.Values.ToList();
|
return refTypes.Values.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddText(string key, string text)
|
||||||
|
{
|
||||||
|
if (key == null || text == null)
|
||||||
|
{
|
||||||
|
throw new Exception("text的key或text属性不能为null");
|
||||||
|
}
|
||||||
|
if (key == "" && text != "")
|
||||||
|
{
|
||||||
|
throw new InvalidExcelDataException($"text key为空, 但text:{text}不为空");
|
||||||
|
}
|
||||||
|
if (!_texts.TryAdd(key, text) && _texts[key] != text)
|
||||||
|
{
|
||||||
|
throw new Exception($"text key:{key} 出现多次,但值不相同. 当前:{text} 之前:{_texts[key]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Load(string outputService, Defines defines, RemoteAgent agent)
|
public void Load(string outputService, Defines defines, RemoteAgent agent)
|
||||||
{
|
{
|
||||||
this.Agent = agent;
|
this.Agent = agent;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using Luban.Job.Common.Types;
|
||||||
using Luban.Job.Common.TypeVisitors;
|
using Luban.Job.Common.TypeVisitors;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace Luban.Job.Cfg.TypeVisitors
|
namespace Luban.Job.Cfg.TypeVisitors
|
||||||
{
|
{
|
||||||
|
|
@ -18,6 +19,25 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
NULL_STR_AS_NULL = 0x8,
|
NULL_STR_AS_NULL = 0x8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class InvalidExcelDataException : Exception
|
||||||
|
{
|
||||||
|
public InvalidExcelDataException()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public InvalidExcelDataException(string message) : base(message)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public InvalidExcelDataException(string message, Exception innerException) : base(message, innerException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected InvalidExcelDataException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ExcelDataCreator : ITypeFuncVisitor<object, ExcelStream, DefAssembly, DType>
|
class ExcelDataCreator : ITypeFuncVisitor<object, ExcelStream, DefAssembly, DType>
|
||||||
{
|
{
|
||||||
public static ExcelDataCreator Ins { get; } = new ExcelDataCreator();
|
public static ExcelDataCreator Ins { get; } = new ExcelDataCreator();
|
||||||
|
|
@ -32,7 +52,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception($"单元格没有填有效数据");
|
throw new InvalidExcelDataException($"单元格没有填有效数据");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -51,7 +71,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
case "是": return true;
|
case "是": return true;
|
||||||
case "false":
|
case "false":
|
||||||
case "否": return false;
|
case "否": return false;
|
||||||
default: throw new Exception($"{s} 不是 bool 类型的值 (true 或 false)");
|
default: throw new InvalidExcelDataException($"{s} 不是 bool 类型的值 (true 或 false)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,7 +94,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
}
|
}
|
||||||
if (!byte.TryParse(d.ToString(), out byte v))
|
if (!byte.TryParse(d.ToString(), out byte v))
|
||||||
{
|
{
|
||||||
throw new Exception($"{d} 不是 byte 类型值");
|
throw new InvalidExcelDataException($"{d} 不是 byte 类型值");
|
||||||
}
|
}
|
||||||
return new DByte(v);
|
return new DByte(v);
|
||||||
}
|
}
|
||||||
|
|
@ -88,7 +108,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
}
|
}
|
||||||
if (!short.TryParse(d.ToString(), out short v))
|
if (!short.TryParse(d.ToString(), out short v))
|
||||||
{
|
{
|
||||||
throw new Exception($"{d} 不是 short 类型值");
|
throw new InvalidExcelDataException($"{d} 不是 short 类型值");
|
||||||
}
|
}
|
||||||
return new DShort(v);
|
return new DShort(v);
|
||||||
}
|
}
|
||||||
|
|
@ -102,7 +122,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
}
|
}
|
||||||
if (!short.TryParse(d.ToString(), out short v))
|
if (!short.TryParse(d.ToString(), out short v))
|
||||||
{
|
{
|
||||||
throw new Exception($"{d} 不是 short 类型值");
|
throw new InvalidExcelDataException($"{d} 不是 short 类型值");
|
||||||
}
|
}
|
||||||
return new DFshort(v);
|
return new DFshort(v);
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +144,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
}
|
}
|
||||||
if (!int.TryParse(ds, out var v))
|
if (!int.TryParse(ds, out var v))
|
||||||
{
|
{
|
||||||
throw new Exception($"{d} 不是 int 类型值");
|
throw new InvalidExcelDataException($"{d} 不是 int 类型值");
|
||||||
}
|
}
|
||||||
return new DInt(v);
|
return new DInt(v);
|
||||||
}
|
}
|
||||||
|
|
@ -146,7 +166,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
}
|
}
|
||||||
if (!int.TryParse(ds, out var v))
|
if (!int.TryParse(ds, out var v))
|
||||||
{
|
{
|
||||||
throw new Exception($"{d} 不是 int 类型值");
|
throw new InvalidExcelDataException($"{d} 不是 int 类型值");
|
||||||
}
|
}
|
||||||
return new DFint(v);
|
return new DFint(v);
|
||||||
}
|
}
|
||||||
|
|
@ -168,7 +188,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
}
|
}
|
||||||
if (!long.TryParse(ds, out var v))
|
if (!long.TryParse(ds, out var v))
|
||||||
{
|
{
|
||||||
throw new Exception($"{d} 不是 long 类型值");
|
throw new InvalidExcelDataException($"{d} 不是 long 类型值");
|
||||||
}
|
}
|
||||||
return new DLong(v);
|
return new DLong(v);
|
||||||
}
|
}
|
||||||
|
|
@ -190,7 +210,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
}
|
}
|
||||||
if (!long.TryParse(ds, out var v))
|
if (!long.TryParse(ds, out var v))
|
||||||
{
|
{
|
||||||
throw new Exception($"{d} 不是 long 类型值");
|
throw new InvalidExcelDataException($"{d} 不是 long 类型值");
|
||||||
}
|
}
|
||||||
return new DFlong(v);
|
return new DFlong(v);
|
||||||
}
|
}
|
||||||
|
|
@ -204,7 +224,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
}
|
}
|
||||||
if (!float.TryParse(d.ToString(), out var v))
|
if (!float.TryParse(d.ToString(), out var v))
|
||||||
{
|
{
|
||||||
throw new Exception($"{d} 不是 float 类型值");
|
throw new InvalidExcelDataException($"{d} 不是 float 类型值");
|
||||||
}
|
}
|
||||||
return new DFloat(v);
|
return new DFloat(v);
|
||||||
}
|
}
|
||||||
|
|
@ -218,7 +238,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
}
|
}
|
||||||
if (!double.TryParse(d.ToString(), out var v))
|
if (!double.TryParse(d.ToString(), out var v))
|
||||||
{
|
{
|
||||||
throw new Exception($"{d} 不是 double 类型值");
|
throw new InvalidExcelDataException($"{d} 不是 double 类型值");
|
||||||
}
|
}
|
||||||
return new DDouble(v);
|
return new DDouble(v);
|
||||||
}
|
}
|
||||||
|
|
@ -235,16 +255,11 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
|
|
||||||
public DType Accept(TString type, object converter, ExcelStream x, DefAssembly ass)
|
public DType Accept(TString type, object converter, ExcelStream x, DefAssembly ass)
|
||||||
{
|
{
|
||||||
var d = x.Read(x.NamedMode);
|
if (x.NamedMode && x.IncludeNullAndEmptySize != 1)
|
||||||
if (d == null)
|
|
||||||
{
|
{
|
||||||
return new DString("");
|
throw new InvalidExcelDataException("excel string类型在标题头对应模式下必须正好占据一个单元格");
|
||||||
}
|
}
|
||||||
if (d is string s)
|
return new DString(ParseString(x.Read(x.NamedMode)));
|
||||||
{
|
|
||||||
return new DString(DataUtil.UnEscapeString(s));
|
|
||||||
}
|
|
||||||
return new DString(d.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DType Accept(TBytes type, object converter, ExcelStream x, DefAssembly ass)
|
public DType Accept(TBytes type, object converter, ExcelStream x, DefAssembly ass)
|
||||||
|
|
@ -252,18 +267,32 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DType Accept(TText type, object converter, ExcelStream x, DefAssembly ass)
|
private static string ParseString(object d)
|
||||||
{
|
{
|
||||||
var d = x.Read(x.NamedMode);
|
|
||||||
if (d == null)
|
if (d == null)
|
||||||
{
|
{
|
||||||
return new DString("");
|
return "";
|
||||||
}
|
}
|
||||||
if (d is string s)
|
else if (d is string s)
|
||||||
{
|
{
|
||||||
return new DString(DataUtil.UnEscapeString(s));
|
return DataUtil.UnEscapeString(s);
|
||||||
}
|
}
|
||||||
return new DString(d.ToString());
|
else
|
||||||
|
{
|
||||||
|
return d.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DType Accept(TText type, object converter, ExcelStream x, DefAssembly ass)
|
||||||
|
{
|
||||||
|
if (x.NamedMode && x.IncludeNullAndEmptySize != 2)
|
||||||
|
{
|
||||||
|
throw new InvalidExcelDataException("excel text 类型在标题头对应模式下必须正好占据2个单元格");
|
||||||
|
}
|
||||||
|
string key = ParseString(x.Read(x.NamedMode));
|
||||||
|
string text = ParseString(x.Read(x.NamedMode));
|
||||||
|
ass.AddText(key, text);
|
||||||
|
return new DText(key, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DType> CreateBeanFields(DefBean bean, ExcelStream stream, DefAssembly ass)
|
private List<DType> CreateBeanFields(DefBean bean, ExcelStream stream, DefAssembly ass)
|
||||||
|
|
@ -285,7 +314,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new Exception($"读取结构:{bean.FullName} 字段:{f.Name} 出错 ==> {e.Message}", e);
|
throw new InvalidExcelDataException($"读取结构:{bean.FullName} 字段:{f.Name} 出错 ==> {e.Message}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
|
@ -306,7 +335,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
DefBean implType = (DefBean)originBean.GetNotAbstractChildType(subType);
|
DefBean implType = (DefBean)originBean.GetNotAbstractChildType(subType);
|
||||||
if (implType == null)
|
if (implType == null)
|
||||||
{
|
{
|
||||||
throw new Exception($"type:{fullType} 不是bean类型");
|
throw new InvalidExcelDataException($"type:{fullType} 不是bean类型");
|
||||||
}
|
}
|
||||||
return new DBean(originBean, implType, CreateBeanFields(implType, x, ass));
|
return new DBean(originBean, implType, CreateBeanFields(implType, x, ass));
|
||||||
}
|
}
|
||||||
|
|
@ -364,7 +393,7 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
var value = string.IsNullOrWhiteSpace(sep) ? type.ValueType.Apply(this, null, x, ass) : type.ValueType.Apply(this, null, new ExcelStream(x.ReadCell(), sep, false), ass);
|
var value = string.IsNullOrWhiteSpace(sep) ? type.ValueType.Apply(this, null, x, ass) : type.ValueType.Apply(this, null, new ExcelStream(x.ReadCell(), sep, false), ass);
|
||||||
if (!datas.TryAdd(key, value))
|
if (!datas.TryAdd(key, value))
|
||||||
{
|
{
|
||||||
throw new Exception($"map 的 key:{key} 重复");
|
throw new InvalidExcelDataException($"map 的 key:{key} 重复");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new DMap(type, datas);
|
return new DMap(type, datas);
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,27 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
|
|
||||||
public DType Accept(TText type, JsonElement x, DefAssembly ass)
|
public DType Accept(TText type, JsonElement x, DefAssembly ass)
|
||||||
{
|
{
|
||||||
return new DText(x.GetString());
|
if (!x.TryGetProperty("key", out var keyEle))
|
||||||
|
{
|
||||||
|
throw new Exception("text 缺失 key属性");
|
||||||
|
}
|
||||||
|
if (!x.TryGetProperty("text", out var textEle))
|
||||||
|
{
|
||||||
|
throw new Exception("text 缺失 text属性");
|
||||||
|
}
|
||||||
|
string key = keyEle.GetString();
|
||||||
|
if (key == null)
|
||||||
|
{
|
||||||
|
throw new Exception("text key不是字符串");
|
||||||
|
}
|
||||||
|
string text = textEle.GetString();
|
||||||
|
if (text == null)
|
||||||
|
{
|
||||||
|
throw new Exception("text text不是字符串");
|
||||||
|
}
|
||||||
|
|
||||||
|
ass.AddText(key, text);
|
||||||
|
return new DText(key, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DType Accept(TBean type, JsonElement x, DefAssembly ass)
|
public DType Accept(TBean type, JsonElement x, DefAssembly ass)
|
||||||
|
|
|
||||||
|
|
@ -108,17 +108,40 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
|
|
||||||
public DType Accept(TString type, object x, DefAssembly ass)
|
public DType Accept(TString type, object x, DefAssembly ass)
|
||||||
{
|
{
|
||||||
return new DString(x?.ToString());
|
if (x is string s)
|
||||||
|
{
|
||||||
|
return new DString(s);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"{x} 不是 double 类型数据");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DType Accept(TBytes type, object x, DefAssembly ass)
|
public DType Accept(TBytes type, object x, DefAssembly ass)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DType Accept(TText type, object x, DefAssembly ass)
|
public DType Accept(TText type, object x, DefAssembly ass)
|
||||||
{
|
{
|
||||||
return new DText(x?.ToString());
|
var table = (LuaTable)x;
|
||||||
|
if (table == null)
|
||||||
|
{
|
||||||
|
throw new Exception($"字段不是 text类型({{key=xx,text=yy}}}})");
|
||||||
|
}
|
||||||
|
string key = (string)table["key"];
|
||||||
|
string text = (string)table["text"];
|
||||||
|
if (key == null)
|
||||||
|
{
|
||||||
|
throw new Exception("text缺失key属性");
|
||||||
|
}
|
||||||
|
if (text == null)
|
||||||
|
{
|
||||||
|
throw new Exception("text缺失text属性");
|
||||||
|
}
|
||||||
|
ass.AddText(key, text);
|
||||||
|
return new DText(key, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DType Accept(TBean type, object x, DefAssembly ass)
|
public DType Accept(TBean type, object x, DefAssembly ass)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Luban.Job.Cfg.Datas;
|
using Luban.Job.Cfg.Datas;
|
||||||
|
using Luban.Job.Cfg.Utils;
|
||||||
using Luban.Job.Common.Types;
|
using Luban.Job.Common.Types;
|
||||||
using Luban.Job.Common.TypeVisitors;
|
using Luban.Job.Common.TypeVisitors;
|
||||||
using System;
|
using System;
|
||||||
|
|
@ -141,57 +142,59 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
|
|
||||||
public DType Accept(TBytes type, string x)
|
public DType Accept(TBytes type, string x)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DType Accept(TText type, string x)
|
public DType Accept(TText type, string x)
|
||||||
{
|
{
|
||||||
return new DText(x);
|
//var (key, text) = DataUtil.ExtractText(x);
|
||||||
|
//return new DText(key, text);
|
||||||
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DType Accept(TBean type, string x)
|
public DType Accept(TBean type, string x)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DType Accept(TArray type, string x)
|
public DType Accept(TArray type, string x)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DType Accept(TList type, string x)
|
public DType Accept(TList type, string x)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DType Accept(TSet type, string x)
|
public DType Accept(TSet type, string x)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DType Accept(TMap type, string x)
|
public DType Accept(TMap type, string x)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DType Accept(TVector2 type, string x)
|
public DType Accept(TVector2 type, string x)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DType Accept(TVector3 type, string x)
|
public DType Accept(TVector3 type, string x)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DType Accept(TVector4 type, string x)
|
public DType Accept(TVector4 type, string x)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DType Accept(TDateTime type, string x)
|
public DType Accept(TDateTime type, string x)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,10 @@ namespace Luban.Job.Cfg.TypeVisitors
|
||||||
|
|
||||||
public DType Accept(TText type, XElement x, DefAssembly ass)
|
public DType Accept(TText type, XElement x, DefAssembly ass)
|
||||||
{
|
{
|
||||||
return new DText(x.Value);
|
var key = x.Element("key").Value;
|
||||||
|
var text = x.Element("text").Value;
|
||||||
|
ass.AddText(key, text);
|
||||||
|
return new DText(key, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DType Accept(TBean type, XElement x, DefAssembly ass)
|
public DType Accept(TBean type, XElement x, DefAssembly ass)
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,16 @@ namespace Luban.Job.Cfg.Utils
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static (string Key, string Text) ExtractText(string rawKeyAndText)
|
||||||
|
{
|
||||||
|
string[] keyAndText = rawKeyAndText.Split('|');
|
||||||
|
if (keyAndText.Length != 2)
|
||||||
|
{
|
||||||
|
throw new Exception("text data should like <key>|<text>");
|
||||||
|
}
|
||||||
|
return (keyAndText[0], keyAndText[1]);
|
||||||
|
}
|
||||||
|
|
||||||
//public static string Data2String(DType data)
|
//public static string Data2String(DType data)
|
||||||
//{
|
//{
|
||||||
// var s = new StringBuilder();
|
// var s = new StringBuilder();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue