gitee.com/zhongguo168a/gocodes@v0.0.0-20230609140523-e1828349603f/datax/schemax/type.go (about) 1 package schemax 2 3 import ( 4 "gitee.com/zhongguo168a/gocodes/datax/schemax/basickind" 5 ) 6 7 type IType interface { 8 String() string 9 } 10 11 type MapType struct { 12 Key IType 13 Value IType 14 } 15 16 func (typ *MapType) RefType() string { 17 return "map" 18 } 19 func (typ *MapType) String() string { 20 return "map[" + typ.Key.String() + "]" + typ.Value.String() 21 } 22 23 type FuncType struct { 24 Args []*Field 25 Results []*Field 26 } 27 28 func (typ *FuncType) RefType() string { 29 return "func" 30 } 31 func (typ *FuncType) String() string { 32 return "func" 33 //return "func(" + func() (x string) { 34 // var a []string 35 // for _, val := range typ.Args { 36 // a = append(a, val.String()) 37 // } 38 // return strings.Join(a, ",") 39 //}() + ")" + func() (x string) { 40 // if len(typ.Results) == 0 { 41 // return 42 // } 43 // var a []string 44 // for _, val := range typ.Results { 45 // a = append(a, val.String()) 46 // } 47 // return "(" + strings.Join(a, ",") + ")" 48 //}() 49 } 50 51 type ClassType struct { 52 Decl string 53 } 54 55 func (typ *ClassType) RefType() string { 56 return "class" 57 } 58 59 func (typ *ClassType) String() string { 60 return typ.Decl 61 } 62 63 type EnumType struct { 64 Decl string 65 } 66 67 func (typ *EnumType) RefType() string { 68 return "enum" 69 } 70 func (typ *EnumType) String() string { 71 return typ.Decl 72 } 73 74 type ArrayType struct { 75 Elem IType 76 } 77 78 func (typ *ArrayType) RefType() string { 79 return "array" 80 } 81 func (typ *ArrayType) String() string { 82 return typ.Elem.String() 83 } 84 85 type BasicType struct { 86 Kind basickind.Kind 87 } 88 89 func (typ *BasicType) RefType() string { 90 return "basic" 91 } 92 func (typ *BasicType) String() string { 93 return typ.Kind.String() 94 } 95 96 type AnyType struct { 97 } 98 99 func (typ *AnyType) RefType() string { 100 return "any" 101 } 102 func (typ *AnyType) String() string { 103 return "any" 104 }