tag_scanner

package module
v0.0.0-...-98ec530 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: MIT Imports: 3 Imported by: 1

README

tag-scanner

Advanced golang tag scanner

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = Scanner{';', ':', '{', '}'}

Functions

func Flags

func Flags(s Scanner, v string) (names []string)

func KeyValuePairs

func KeyValuePairs(s Scanner, v string) (values [][]string)

func NonFlags

func NonFlags(s Scanner, v string) (names []string)

func Parse

func Parse(s Scanner, v string, flag ...ParseFlag) (tags Map, flags Set)

func Strings

func Strings(v string) (values []string)

Types

type Map

type Map map[string]string

func (Map) Clone

func (this Map) Clone() (clone Map)

func (Map) Empty

func (this Map) Empty() bool

func (Map) Enable

func (this Map) Enable(key string)

func (Map) Flag

func (this Map) Flag(name string) bool

func (Map) Flags

func (this Map) Flags() (flags []string)

func (Map) Get

func (this Map) Get(key string) (v string)

func (Map) GetAny

func (this Map) GetAny(key ...string) (v string)

func (Map) GetAnyOk

func (this Map) GetAnyOk(key ...string) (v string, ok bool)

func (Map) GetAnyString

func (this Map) GetAnyString(key ...string) (v string)

func (Map) GetOk

func (this Map) GetOk(key string) (v string, ok bool)

func (Map) GetString

func (this Map) GetString(key string) (v string)

func (Map) GetStringAlias

func (this Map) GetStringAlias(key string, alias ...string) (v string)

func (Map) GetTags

func (this Map) GetTags(name string, flags ...ParseFlag) (tags Map)

func (*Map) Parse

func (this *Map) Parse(tags StructTag, key string, flag ParseFlag, keyAlias ...string) (ok bool)

func (*Map) ParseCallback

func (this *Map) ParseCallback(tags StructTag, keys []string, flag ParseFlag, cb ...func(dest Map, n Node)) (ok bool)

func (*Map) ParseCallbackDefault

func (this *Map) ParseCallbackDefault(tags StructTag, keys []string, cb ...func(dest Map, n Node)) (ok bool)

func (*Map) ParseDefault

func (this *Map) ParseDefault(tags StructTag, key string, keyAlias ...string) (ok bool)

func (*Map) ParseString

func (this *Map) ParseString(s string, flags ParseFlag, cb ...func(dest Map, n Node))

func (*Map) ParseStringDefault

func (this *Map) ParseStringDefault(s string, cb ...func(dest Map, n Node))

func (*Map) Scanner

func (this *Map) Scanner() Scanner

func (*Map) Set

func (this *Map) Set(key, value string)

func (Map) SetFlag

func (this Map) SetFlag(flagName ...string) Map

func (Map) SetParseFlag

func (this Map) SetParseFlag(name ...string) Map

func (Map) String

func (this Map) String() string

func (Map) TagsOf

func (this Map) TagsOf(value string, flags ...ParseFlag) (tags Map)

func (Map) Update

func (this Map) Update(setting ...map[string]string)

type Node

type Node interface {
	fmt.Stringer
	Type() NodeType
}

type NodeFlag

type NodeFlag string

func (NodeFlag) String

func (this NodeFlag) String() string

func (NodeFlag) Type

func (NodeFlag) Type() NodeType

type NodeKeyValue

type NodeKeyValue struct {
	Key, Value string
	KeyArgs    []string
}

func (NodeKeyValue) String

func (this NodeKeyValue) String() string

func (NodeKeyValue) Type

func (NodeKeyValue) Type() NodeType

type NodeTags

type NodeTags string

func (NodeTags) String

func (this NodeTags) String() string

func (NodeTags) Type

func (NodeTags) Type() NodeType

func (NodeTags) Value

func (this NodeTags) Value() string

type NodeType

type NodeType uint8
const (
	KeyValue NodeType = iota + 1
	Tags
	Flag
)

type ParseFlag

type ParseFlag uint8
const (
	FlagPreserveKeys ParseFlag = 1 << iota
	FlagForceTags
	FlagTags
	FlagNotNil
)

func JoinParseFlags

func JoinParseFlags(flag ...ParseFlag) (f ParseFlag)

func (ParseFlag) Clear

func (b ParseFlag) Clear(flag ParseFlag) ParseFlag

func (ParseFlag) Has

func (b ParseFlag) Has(flag ParseFlag) bool

func (ParseFlag) Set

func (b ParseFlag) Set(flag ParseFlag) ParseFlag

func (ParseFlag) Toggle

func (b ParseFlag) Toggle(flag ParseFlag) ParseFlag

type Scanner

type Scanner struct {
	Fields,
	Key,
	Start,
	End uint8
}

func (Scanner) IsTags

func (this Scanner) IsTags(value string) bool

func (Scanner) Scan

func (this Scanner) Scan(s string) (key, value, news string, keyArgs []string)

func (Scanner) ScanAll

func (this Scanner) ScanAll(s string, cb func(node Node))

func (Scanner) ScanAllFlags

func (this Scanner) ScanAllFlags(s string, flags ParseFlag, cb func(flag bool, key string, value string))

func (Scanner) ScanValue

func (this Scanner) ScanValue(s string, keyArgs *[]string) (value, news string)

func (Scanner) String

func (this Scanner) String(value string) string

func (Scanner) ToTags

func (this Scanner) ToTags(value string) string

type Set

type Set map[string]void

func (*Set) Add

func (s *Set) Add(key ...string) *Set

func (*Set) Del

func (s *Set) Del(key ...string) *Set

func (Set) Has

func (s Set) Has(key string) (ok bool)

func (Set) Strings

func (s Set) Strings() (keys []string)

type StructTag

type StructTag string

func (StructTag) Get

func (tag StructTag) Get(key string) string

Get returns the value associated with key in the tag string. If there is no such key in the tag, Get returns the empty string. If the tag does not have the conventional format, the value returned by Get is unspecified. To determine whether a tag is explicitly set to the empty string, use Lookup.

func (StructTag) Lookup

func (tag StructTag) Lookup(key string) (value string, ok bool)

Jump to

Keyboard shortcuts

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