mirror of
https://github.com/wader/fq.git
synced 2024-12-25 14:23:18 +03:00
93 lines
3.9 KiB
Cheetah
93 lines
3.9 KiB
Cheetah
package decode
|
|
|
|
// Generated with numbers.go.tmpl
|
|
|
|
// Integer readers
|
|
|
|
{{- range $s := $.signs }}
|
|
{{- range $e := $.endians }}
|
|
|
|
// {{$s.short}}{{$e.short}} read a nBits {{$s.desc}} {{$e.desc}} integer
|
|
func (d *D) {{$s.short}}{{$e.short}}(nBits int) {{$s.type}} { return d.{{$s.short}}E(nBits, {{$e.var}}) }
|
|
|
|
// Try{{$s.short}}{{$e.short}} try read a nBits {{$s.desc}} {{$e.desc}} integer
|
|
func (d *D) Try{{$s.short}}{{$e.short}}(nBits int) ({{$s.type}}, error) { return d.Try{{$s.short}}E(nBits, {{$e.var}}) }
|
|
|
|
{{- range $bits := xrange $e.from 64}}
|
|
// {{$s.short}}{{$bits}}{{$e.short}} read {{$bits}} bit {{$s.desc}} {{$e.desc}} integer
|
|
func (d *D) {{$s.short}}{{$bits}}{{$e.short}}() {{$s.type}} { return d.{{$s.short}}E({{$bits}}, {{$e.var}}) }
|
|
|
|
// Try{{$s.short}}{{$bits}}{{$e.short}} try read {{$bits}} bit {{$s.desc}} {{$e.desc}} integer
|
|
func (d *D) Try{{$s.short}}{{$bits}}{{$e.short}}() ({{$s.type}}, error) { return d.Try{{$s.short}}E({{$bits}}, {{$e.var}}) }
|
|
{{- end}}
|
|
|
|
// Field{{$s.short}}{{$e.short}} read a nBits {{$s.desc}} {{$e.desc}} integer and add a field
|
|
func (d *D) Field{{$s.short}}{{$e.short}}(name string, nBits int) {{$s.type}} { return d.Field{{$s.short}}E(name, nBits, {{$e.var}}) }
|
|
{{- range $bits := xrange $e.from 64}}
|
|
// Field{{$s.short}}{{$bits}}{{$e.short}} read {{$bits}} bit {{$s.desc}} {{$e.desc}} integer and add a field
|
|
func (d *D) Field{{$s.short}}{{$bits}}{{$e.short}}(name string) {{$s.type}} { return d.Field{{$s.short}}E(name, {{$bits}}, {{$e.var}}) }
|
|
{{- end}}
|
|
|
|
{{- end}}
|
|
{{- end}}
|
|
|
|
|
|
// Float readers
|
|
|
|
|
|
{{ range $e := $.endians }}
|
|
|
|
// F{{$e.short}} read a nBits {{$e.desc}} float
|
|
func (d *D) F{{$e.short}}(nBits int) float64 { return d.FE(nBits, {{$e.var}}) }
|
|
|
|
// TryF{{$e.short}} try read a nBits {{$e.desc}} float
|
|
func (d *D) TryF{{$e.short}}(nBits int) (float64, error) { return d.TryFE(nBits, {{$e.var}}) }
|
|
|
|
{{- range $bits := $.bits }}
|
|
// F{{$bits}}{{$e.short}} read {{$bits}} bit {{$e.desc}} float
|
|
func (d *D) F{{$bits}}{{$e.short}}() float64 { return d.FE({{$bits}}, {{$e.var}}) }
|
|
|
|
// TryF{{$bits}}{{$e.short}} try read {{$bits}} bit {{$e.desc}} float
|
|
func (d *D) TryF{{$bits}}{{$e.short}}() (float64, error) { return d.TryFE({{$bits}}, {{$e.var}}) }
|
|
{{- end}}
|
|
|
|
// FieldF{{$e.short}} read a nBits {{$e.desc}} float and add a field
|
|
func (d *D) FieldF{{$e.short}}(name string, nBits int) float64 { return d.FieldFE(name, nBits, {{$e.var}}) }
|
|
|
|
{{- range $bits := $.bits }}
|
|
// FieldF{{$bits}}{{$e.short}} read {{$bits}} bit {{$e.desc}} float and add a field
|
|
func (d *D) FieldF{{$bits}}{{$e.short}}(name string) float64 { return d.FieldFE(name, {{$bits}}, {{$e.var}}) }
|
|
{{- end}}
|
|
|
|
{{- end}}
|
|
|
|
|
|
// Fixed-point readers
|
|
|
|
{{ range $e :=$.endians }}
|
|
|
|
// FP{{$e.short}} read a nBits {{$e.desc}} fBits fraction bits fixed-point number
|
|
func (d *D) FP{{$e.short}}(nBits int, fBits int64) float64 { return d.FPE(nBits, fBits, {{$e.var}}) }
|
|
|
|
// TryFP{{$e.short}} try read a nBits {{$e.desc}} fBits fraction bits fixed-point number
|
|
func (d *D) TryFP{{$e.short}}(nBits int, fBits int64) (float64, error) { return d.TryFPE(nBits, fBits, {{$e.var}}) }
|
|
|
|
{{- range $fp := $.fpbits }}
|
|
// FP{{$fp.bits}}{{$e.short}} read {{$fp.bits}} bit {{$e.desc}} fixed-point number
|
|
func (d *D) FP{{$fp.bits}}{{$e.short}}() float64 { return d.FPE({{$fp.bits}}, {{$fp.d}}, {{$e.var}}) }
|
|
|
|
// TryFP{{$fp.bits}}{{$e.short}} try read {{$fp.bits}} bit {{$e.desc}} fixed-point number
|
|
func (d *D) TryFP{{$fp.bits}}{{$e.short}}() (float64, error) { return d.TryFPE({{$fp.bits}}, {{$fp.d}}, {{$e.var}}) }
|
|
{{- end}}
|
|
|
|
// FieldFP{{$e.short}} read a nBits {{$e.desc}} fBits fraction fixed-point number and add a field
|
|
func (d *D) FieldFP{{$e.short}}(name string, nBits int, fBits int64) float64 { return d.FieldFPE(name, nBits, fBits, {{$e.var}}) }
|
|
|
|
{{- range $fp := $.fpbits }}
|
|
// FieldFP{{$fp.bits}}{{$e.short}} read {{$fp.bits}} bit {{$e.desc}} fixed-point number and add a field
|
|
func (d *D) FieldFP{{$fp.bits}}{{$e.short}}(name string) float64 { return d.FieldFPE(name, {{$fp.bits}}, {{$fp.d}}, {{$e.var}}) }
|
|
{{- end}}
|
|
|
|
{{- end}}
|
|
|