MCPcopy
hub / github.com/davyxu/tabtoy / ParseRow

Function ParseRow

v3/compiler/resolverow.go:24–57  ·  view source on GitHub ↗

将一行数据解析为具体的类型

(ret interface{}, tab *model.DataTable, row int, symbols *model.TypeTable)

Source from the content-addressed store, hash-verified

22
23// 将一行数据解析为具体的类型
24func ParseRow(ret interface{}, tab *model.DataTable, row int, symbols *model.TypeTable) bool {
25
26 vobj := reflect.ValueOf(ret).Elem()
27
28 tobj := reflect.TypeOf(ret).Elem()
29
30 // 这一行可能被注释
31 if tab.GetCell(row, 0) == nil {
32 return false
33 }
34
35 for _, header := range tab.Headers {
36
37 valueCell := tab.GetValueByName(row, header.Cell.Value)
38
39 if valueCell == nil {
40 continue
41 }
42
43 index := matchField(tobj, header.Cell.Value)
44
45 if index == -1 {
46 report.ReportError("HeaderNotMatchFieldName", header.Cell.String())
47 }
48
49 fieldValue := vobj.Field(index)
50
51 if err := StringToValue(valueCell.Value, fieldValue.Addr().Interface(), header.TypeInfo, symbols); err != nil {
52 panic(err)
53 }
54 }
55
56 return true
57}

Callers 2

parseIndexRowFunction · 0.85
LoadTypeTableFunction · 0.85

Calls 6

ReportErrorFunction · 0.92
matchFieldFunction · 0.85
StringToValueFunction · 0.85
GetCellMethod · 0.80
GetValueByNameMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected