scalar

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2022 License: MIT Imports: 4 Imported by: 2

Documentation

Overview

Code below generated from scalar_gen.go.tmpl

Index

Constants

This section is empty.

Variables

View Source
var Bin = Fn(func(s S) (S, error) { s.ActualDisplay = NumberBinary; return s, nil })
View Source
var Dec = Fn(func(s S) (S, error) { s.ActualDisplay = NumberDecimal; return s, nil })
View Source
var Hex = Fn(func(s S) (S, error) { s.ActualDisplay = NumberHex; return s, nil })
View Source
var Oct = Fn(func(s S) (S, error) { s.ActualDisplay = NumberOctal; return s, nil })
View Source
var RawHex = Fn(func(s S) (S, error) {
	return rawSym(s, -1, func(b []byte) string { return fmt.Sprintf("%x", b) })
})
View Source
var RawHexReverse = Fn(func(s S) (S, error) {
	return rawSym(s, -1, func(b []byte) string {
		return fmt.Sprintf("%x", bitio.ReverseBytes(append([]byte{}, b...)))
	})
})
View Source
var RawSym = Fn(func(s S) (S, error) {
	return rawSym(s, -1, func(b []byte) string {
		return fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:])
	})
})
View Source
var RawUUID = Fn(func(s S) (S, error) {
	return rawSym(s, -1, func(b []byte) string {
		return fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:])
	})
})
View Source
var SymBin = Fn(func(s S) (S, error) { s.SymDisplay = NumberBinary; return s, nil })
View Source
var SymDec = Fn(func(s S) (S, error) { s.SymDisplay = NumberDecimal; return s, nil })
View Source
var SymHex = Fn(func(s S) (S, error) { s.SymDisplay = NumberHex; return s, nil })
View Source
var SymOct = Fn(func(s S) (S, error) { s.SymDisplay = NumberOctal; return s, nil })
View Source
var TrimSpace = Fn(func(s S) (S, error) {
	s.Actual = strings.TrimSpace(s.ActualStr())
	return s, nil
})

Functions

This section is empty.

Types

type BoolToScalar

type BoolToScalar map[bool]S

func (BoolToScalar) MapScalar

func (m BoolToScalar) MapScalar(s S) (S, error)

type BoolToSymBool

type BoolToSymBool map[bool]bool

func (BoolToSymBool) MapScalar

func (m BoolToSymBool) MapScalar(s S) (S, error)

type BoolToSymF

type BoolToSymF map[bool]float64

func (BoolToSymF) MapScalar

func (m BoolToSymF) MapScalar(s S) (S, error)

type BoolToSymS

type BoolToSymS map[bool]int64

func (BoolToSymS) MapScalar

func (m BoolToSymS) MapScalar(s S) (S, error)

type BoolToSymStr

type BoolToSymStr map[bool]string

func (BoolToSymStr) MapScalar

func (m BoolToSymStr) MapScalar(s S) (S, error)

type BoolToSymU

type BoolToSymU map[bool]uint64

func (BoolToSymU) MapScalar

func (m BoolToSymU) MapScalar(s S) (S, error)

type BytesToScalar

type BytesToScalar []struct {
	Bytes  []byte
	Scalar S
}

func (BytesToScalar) MapScalar

func (m BytesToScalar) MapScalar(s S) (S, error)

type DisplayFormat

type DisplayFormat int
const (
	NumberDecimal DisplayFormat = iota
	NumberBinary
	NumberOctal
	NumberHex
)

func (DisplayFormat) FormatBase

func (df DisplayFormat) FormatBase() int

type Fn

type Fn func(S) (S, error)

func (Fn) MapScalar

func (fn Fn) MapScalar(s S) (S, error)

type Mapper

type Mapper interface {
	MapScalar(S) (S, error)
}

func Actual

func Actual(v interface{}) Mapper

func Description

func Description(v string) Mapper

func SAdd

func SAdd(n int) Mapper

func Sym

func Sym(v interface{}) Mapper

func Trim

func Trim(cutset string) Mapper

TODO: nicer api?

func UAdd

func UAdd(n int) Mapper

type S

type S struct {
	Actual        interface{} // int, int64, uint64, float64, string, bool, []byte, *bitio.Buffer
	ActualDisplay DisplayFormat
	Sym           interface{}
	SymDisplay    DisplayFormat
	Description   string
	Unknown       bool
}

func (S) ActualBitBuf

func (s S) ActualBitBuf() *bitio.Buffer

ActualBitBuf asserts actual value is a BitBuf and returns it

func (S) ActualBool

func (s S) ActualBool() bool

ActualBool asserts actual value is a Bool and returns it

func (S) ActualF

func (s S) ActualF() float64

ActualF asserts actual value is a F and returns it

func (S) ActualS

func (s S) ActualS() int64

ActualS asserts actual value is a S and returns it

func (S) ActualStr

func (s S) ActualStr() string

ActualStr asserts actual value is a Str and returns it

func (S) ActualU

func (s S) ActualU() uint64

ActualU asserts actual value is a U and returns it

func (S) SymBitBuf

func (s S) SymBitBuf() *bitio.Buffer

SymBitBuf asserts symbolic value is a BitBuf and returns it

func (S) SymBool

func (s S) SymBool() bool

SymBool asserts symbolic value is a Bool and returns it

func (S) SymF

func (s S) SymF() float64

SymF asserts symbolic value is a F and returns it

func (S) SymS

func (s S) SymS() int64

SymS asserts symbolic value is a S and returns it

func (S) SymStr

func (s S) SymStr() string

SymStr asserts symbolic value is a Str and returns it

func (S) SymU

func (s S) SymU() uint64

SymU asserts symbolic value is a U and returns it

func (S) Value

func (s S) Value() interface{}

type SRangeEntry added in v0.0.3

type SRangeEntry struct {
	Range [2]int64
	S     S
}

SRangeToScalar maps ranges to a scalar, first in range is chosen

type SRangeToScalar

type SRangeToScalar []SRangeEntry

SRangeToScalar maps sint64 ranges to a scalar, first in range is chosen

func (SRangeToScalar) MapScalar

func (rs SRangeToScalar) MapScalar(s S) (S, error)

type SToScalar

type SToScalar map[int64]S

func (SToScalar) MapScalar

func (m SToScalar) MapScalar(s S) (S, error)

type SToSymBool

type SToSymBool map[int64]bool

func (SToSymBool) MapScalar

func (m SToSymBool) MapScalar(s S) (S, error)

type SToSymF

type SToSymF map[int64]float64

func (SToSymF) MapScalar

func (m SToSymF) MapScalar(s S) (S, error)

type SToSymS

type SToSymS map[int64]int64

func (SToSymS) MapScalar

func (m SToSymS) MapScalar(s S) (S, error)

type SToSymStr

type SToSymStr map[int64]string

func (SToSymStr) MapScalar

func (m SToSymStr) MapScalar(s S) (S, error)

type SToSymU

type SToSymU map[int64]uint64

func (SToSymU) MapScalar

func (m SToSymU) MapScalar(s S) (S, error)

type StrToScalar

type StrToScalar map[string]S

func (StrToScalar) MapScalar

func (m StrToScalar) MapScalar(s S) (S, error)

type StrToSymBool

type StrToSymBool map[string]bool

func (StrToSymBool) MapScalar

func (m StrToSymBool) MapScalar(s S) (S, error)

type StrToSymF

type StrToSymF map[string]float64

func (StrToSymF) MapScalar

func (m StrToSymF) MapScalar(s S) (S, error)

type StrToSymS

type StrToSymS map[string]int64

func (StrToSymS) MapScalar

func (m StrToSymS) MapScalar(s S) (S, error)

type StrToSymStr

type StrToSymStr map[string]string

func (StrToSymStr) MapScalar

func (m StrToSymStr) MapScalar(s S) (S, error)

type StrToSymU

type StrToSymU map[string]uint64

func (StrToSymU) MapScalar

func (m StrToSymU) MapScalar(s S) (S, error)

type URangeEntry added in v0.0.3

type URangeEntry struct {
	Range [2]uint64
	S     S
}

type URangeToScalar

type URangeToScalar []URangeEntry

URangeToScalar maps uint64 ranges to a scalar, first in range is chosen

func (URangeToScalar) MapScalar

func (rs URangeToScalar) MapScalar(s S) (S, error)

type UToScalar

type UToScalar map[uint64]S

func (UToScalar) MapScalar

func (m UToScalar) MapScalar(s S) (S, error)

type UToSymBool

type UToSymBool map[uint64]bool

func (UToSymBool) MapScalar

func (m UToSymBool) MapScalar(s S) (S, error)

type UToSymF

type UToSymF map[uint64]float64

func (UToSymF) MapScalar

func (m UToSymF) MapScalar(s S) (S, error)

type UToSymS

type UToSymS map[uint64]int64

func (UToSymS) MapScalar

func (m UToSymS) MapScalar(s S) (S, error)

type UToSymStr

type UToSymStr map[uint64]string

func (UToSymStr) MapScalar

func (m UToSymStr) MapScalar(s S) (S, error)

type UToSymU

type UToSymU map[uint64]uint64

func (UToSymU) MapScalar

func (m UToSymU) MapScalar(s S) (S, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL