Debian Codegraph @

dstream/convert.go

raw symbols SCIP
1 package dstream
2
3 import "fmt"
4
5 type convert struct {
6 xform
7
8 // The name of the variable to be converted
9 vname string
10
11 // The position of the variable to be converted
12 vpos int
13
14 // The new type of the variable
15 dtype Dtype
16 }
17
18 // Convert returns a Dstream in which the named variable is converted
19 // to the given type.
20 func Convert(da Dstream, vname string, dtype Dtype) Dstream {
21
22 vpos := -1
23 for k, na := range da.Names() {
24 if na == vname {
25 vpos = k
26 break
27 }
28 }
29 if vpos == -1 {
30 msg := fmt.Sprintf("Convert: no variable '%s'\n", vname)
31 panic(msg)
32 }
33
34 c := &convert{
35 xform: xform{
36 source: da,
37 },
38 vname: vname,
39 dtype: dtype,
40 vpos: vpos,
41 }
42
43 c.bdata = make([]interface{}, c.source.NumVar())
44
45 return c
46 }