enumset

package
v0.0.0-...-55524bd Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package enumset is enumset define provider

NOTE: must call FinishReg in init()

func init() {
	enumset.FinishReg()
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindContent

func FindContent(e string, sets ...*EnumSet) (string, string, bool)

FindContent find content from multi enumset

func FinishReg

func FinishReg()

FinishReg sort the enums. NOTE: must call this at init() in customer package.

Types

type Enum

type Enum string

Enum represents a enum

func (Enum) Equal

func (e Enum) Equal(s string) bool

Equal judege if enum equals to string

func (Enum) String

func (e Enum) String() string

String converts an enum to string

type EnumSet

type EnumSet struct {
	// contains filtered or unexported fields
}

EnumSet represents a set of enum

func New

func New(exists *EnumSet) *EnumSet

New create a new EnumSet

func (*EnumSet) Content

func (es *EnumSet) Content(e string) (string, string, bool)

Content get content of the enum

func (*EnumSet) GetAll

func (es *EnumSet) GetAll() []string

GetAll return enum list of the set

func (*EnumSet) MustReg

func (es *EnumSet) MustReg(val string) Enum

MustReg regist a new enum to the set. It panic if val duplicate.

func (*EnumSet) MustRegWithContent

func (es *EnumSet) MustRegWithContent(val string, op, title string) Enum

MustRegWithContent regist a new enum with content to the set. eg ("eq", "="). It panic if val duplicate.

func (*EnumSet) Reg

func (es *EnumSet) Reg(val string) (Enum, error)

Reg regist a new enum to the set

func (*EnumSet) RegWithContent

func (es *EnumSet) RegWithContent(val string, op, title string) (Enum, error)

RegWithContent regist a new enum with content to the set. eg ("eq", "=")

func (*EnumSet) ShowAll

func (es *EnumSet) ShowAll() string

ShowAll show enum list of the set

func (*EnumSet) ShowSorted

func (es *EnumSet) ShowSorted() string

ShowSorted show enum list of the set with sort

func (*EnumSet) Sort

func (es *EnumSet) Sort()

Sort sort the enums

func (*EnumSet) Verify

func (es *EnumSet) Verify(e string) bool

Verify check if a enum is valid, binary search

Jump to

Keyboard shortcuts

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