models

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

View Source
const (
	StateRepeat = iota
	StateLength
	StateFormat
	StateSeparator
	StateTerminator
	StateEnd
)

Variables

This section is empty.

Functions

func DurationFormat

func DurationFormat(d time.Duration) string

func DurationFormatLong

func DurationFormatLong(d time.Duration) string

func FormatAsListString

func FormatAsListString() []string

func FormatIsValid

func FormatIsValid(t Format) bool

func IntegerDisplayHint

func IntegerDisplayHint(format string, value int64) (formatted string)

func StringDisplayHint

func StringDisplayHint(format string, value []byte) (formatted string)

func ToInt64

func ToInt64(value interface{}) (val int64, err error)

Types

type BaseNode

type BaseNode struct {
	Name         string
	Oid          types.Oid
	OidFormatted string
	OidLen       uint
}

func (BaseNode) ChildOf

func (b BaseNode) ChildOf(n BaseNode) bool

func (BaseNode) ParentOf

func (b BaseNode) ParentOf(n BaseNode) bool

type ColumnNode

type ColumnNode ScalarNode

func (ColumnNode) FormatValue

func (n ColumnNode) FormatValue(value interface{}, flags ...Format) Value

func (ColumnNode) GetValueFormatter

func (n ColumnNode) GetValueFormatter(flags ...Format) ValueFormatter

type Enum

type Enum struct {
	BaseType types.BaseType
	Values   []NamedNumber
	// contains filtered or unexported fields
}

func (*Enum) Name

func (e *Enum) Name(value int64) string

func (*Enum) Value

func (e *Enum) Value(name string) (int64, error)

type Format

type Format byte
const (
	FormatNone     Format = 0
	FormatEnumName Format = 1 << iota
	FormatEnumValue
	FormatBits
	FormatString
	FormatUnits
	FormatDurationShort
	FormatAll Format = 0xff & ^FormatUnits
)

func FormatAsList

func FormatAsList() []Format

func FormatFromString

func FormatFromString(s string) (Format, error)

func ResolveFormat

func ResolveFormat(formats []Format, defaultFormat ...Format) (format Format)

func (Format) MarshalJSON

func (i Format) MarshalJSON() ([]byte, error)

func (Format) String

func (i Format) String() string

func (*Format) UnmarshalJSON

func (i *Format) UnmarshalJSON(data []byte) error

type Import

type Import struct {
	Module string
	Name   string
}

type Module

type Module struct {
	ContactInfo  string
	Description  string
	Language     types.Language
	Name         string
	Organization string
	Path         string
	Reference    string
}

type NamedNumber

type NamedNumber struct {
	Name  string
	Value int64
}

type Node

type Node struct {
	Access      types.Access
	Decl        types.Decl
	Description string
	Kind        types.NodeKind
	Name        string
	Oid         types.Oid
	OidLen      int
	Status      types.Status
	Type        *Type
}

func (Node) FormatValue

func (n Node) FormatValue(value interface{}, flags ...Format) Value

func (Node) GetValueFormatter

func (n Node) GetValueFormatter(flags ...Format) ValueFormatter

type NotificationNode

type NotificationNode struct {
	BaseNode
	Objects []ScalarNode
}

type Range

type Range struct {
	BaseType types.BaseType
	MinValue int64
	MaxValue int64
}

type Revision

type Revision struct {
	Date        time.Time
	Description string
}

type RowNode

type RowNode struct {
	BaseNode
	Columns []ColumnNode
	Implied bool
	Index   []ColumnNode
}

type ScalarNode

type ScalarNode struct {
	BaseNode
	Type Type
}

func (ScalarNode) FormatValue

func (n ScalarNode) FormatValue(value interface{}, flags ...Format) Value

func (ScalarNode) GetValueFormatter

func (n ScalarNode) GetValueFormatter(flags ...Format) ValueFormatter

type StringHint

type StringHint struct {
	Repeat     bool
	Length     int
	Format     string
	Separator  byte
	Terminator byte
	Numeric    bool
}

type TableNode

type TableNode struct {
	BaseNode
	Row RowNode
}

func (TableNode) BuildIndex

func (t TableNode) BuildIndex(index ...interface{}) (types.Oid, error)

func (TableNode) Columns

func (t TableNode) Columns() []ColumnNode

func (TableNode) Implied

func (t TableNode) Implied() bool

func (TableNode) Index

func (t TableNode) Index() []ColumnNode

type Type

type Type struct {
	BaseType    types.BaseType
	Decl        types.Decl
	Description string
	Enum        *Enum
	Format      string
	Name        string
	Ranges      []Range
	Reference   string
	Status      types.Status
	Units       string
}

func (Type) FormatValue

func (t Type) FormatValue(value interface{}, flags ...Format) Value

func (Type) GetValueFormatter

func (t Type) GetValueFormatter(flags ...Format) ValueFormatter

func (Type) IndexValue

func (t Type) IndexValue(value interface{}, implied bool) (types.Oid, error)

func (Type) String

func (t Type) String() string

type Value

type Value struct {
	Format    Format
	Formatted string
	Raw       interface{}
}

func GetBitsFormatted

func GetBitsFormatted(value interface{}, flags Format) (v Value)

func GetDurationFormatted

func GetDurationFormatted(value interface{}, flags Format) (v Value)

func GetEnumBitsFormatted

func GetEnumBitsFormatted(value interface{}, flags Format, enum *Enum) (v Value)

func GetEnumFormatted

func GetEnumFormatted(value interface{}, flags Format, enum *Enum) (v Value)

func GetInetAddressFormatted

func GetInetAddressFormatted(value interface{}, flags Format) (v Value)

func GetIntFormatted

func GetIntFormatted(value interface{}, flags Format, format string) Value

func GetOctetStringFormatted

func GetOctetStringFormatted(value interface{}, flags Format, format string) (v Value)

func (Value) Bytes

func (v Value) Bytes() []byte

func (Value) Duration

func (v Value) Duration() time.Duration

func (Value) Int64

func (v Value) Int64() int64

func (Value) String

func (v Value) String() string

func (Value) Uint64

func (v Value) Uint64() uint64

type ValueFormatter

type ValueFormatter func(interface{}) Value

func GetBitsFormatter

func GetBitsFormatter(flags Format) (f ValueFormatter)

func GetDurationFormatter

func GetDurationFormatter(flags Format) (f ValueFormatter)

func GetEnumBitsFormatter

func GetEnumBitsFormatter(flags Format, enum *Enum) (f ValueFormatter)

func GetEnumFormatter

func GetEnumFormatter(flags Format, enum *Enum) (f ValueFormatter)

func GetInetAddressFormatter

func GetInetAddressFormatter(flags Format) (f ValueFormatter)

func GetIntFormatter

func GetIntFormatter(flags Format, format string) (f ValueFormatter)

func GetOctetStringFormatter

func GetOctetStringFormatter(flags Format, format string) (f ValueFormatter)

Jump to

Keyboard shortcuts

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