functions

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgType

type ArgType uint8

ArgType is the type alias for the argument value type.

const (
	// String represents the string argument type.
	String ArgType = iota
	// Number represents the scalar argument type.
	Number
	// IP represents the IP argument type.
	IP
	// Field represents the argument type that is derived
	// from the field literal. Field literal values can
	// be simple primitive types.
	Field
	// Func represents the argument type that is derived
	// from the function return value.
	Func
	// Slice represents the string slice argument type.
	Slice
	// Unknown is the unknown argument type.
	Unknown
)

func (ArgType) String

func (typ ArgType) String() string

String returns the argument type as a string value.

type ArgsValidation added in v1.5.0

type ArgsValidation func(args []string) error

ArgsValidation is a function for the custom argument validation logic.

type CIDRContains

type CIDRContains struct{}

CIDRContains determines if the specified IP is contained within the block referenced by the given CIDR mask. The first argument in the slice represents the IP address and the rest of the args represent IP addresses in CIDR notation.

func (CIDRContains) Call

func (f CIDRContains) Call(args []interface{}) (interface{}, bool)

func (CIDRContains) Desc

func (f CIDRContains) Desc() FunctionDesc

func (CIDRContains) Name

func (f CIDRContains) Name() Fn

type Concat added in v1.5.0

type Concat struct{}

Concat returns a concatenated string of all input arguments.

func (Concat) Call added in v1.5.0

func (f Concat) Call(args []interface{}) (interface{}, bool)

func (Concat) Desc added in v1.5.0

func (f Concat) Desc() FunctionDesc

func (Concat) Name added in v1.5.0

func (f Concat) Name() Fn

type Entropy added in v1.5.0

type Entropy struct{}

Entropy measures the string entropy

func (Entropy) Call added in v1.5.0

func (f Entropy) Call(args []interface{}) (interface{}, bool)

func (Entropy) Desc added in v1.5.0

func (f Entropy) Desc() FunctionDesc

func (Entropy) Name added in v1.5.0

func (f Entropy) Name() Fn

type Fn

type Fn uint16

Fn is the type alias for function definitions.

const (
	// CIDRContainsFn identifies the CIDR_CONTAINS function
	CIDRContainsFn Fn = iota + 1
	// MD5Fn represents the MD5 function
	MD5Fn
	// ConcatFn represents the CONCAT function
	ConcatFn
	// LtrimFn represents the LTRIM function
	LtrimFn
	// RtrimFn represents the RTRIM function
	RtrimFn
	// LowerFn represents the LOWER function
	LowerFn
	// UpperFn represents the UPPER function
	UpperFn
	// ReplaceFn represents the REPLACE function
	ReplaceFn
	// SplitFn represents the SPLIT function
	SplitFn
	// LengthFn represents the LENGTH function
	LengthFn
	// IndexOfFn represents the INDEXOF function
	IndexOfFn
	// SubstrFn represents the SUBSTR function
	SubstrFn
	// EntropyFn represents the ENTROPY function
	EntropyFn
	// RegexFn represents the REGEX function
	RegexFn
)

func (Fn) String

func (f Fn) String() string

String returns the function name in upper case.

type FunctionArgDesc

type FunctionArgDesc struct {
	Keyword  string
	Required bool
	Types    []ArgType
}

FunctionArgDesc described each function argument.

func (FunctionArgDesc) ContainsType

func (arg FunctionArgDesc) ContainsType(typ ArgType) bool

ContainsType returns true if the argument satisfies the given argument type.

type FunctionDesc

type FunctionDesc struct {
	Name               Fn
	Args               []FunctionArgDesc
	ArgsValidationFunc ArgsValidation
}

FunctionDesc contains the function signature that particular filter function has to satisfy.

func (FunctionDesc) RequiredArgs

func (f FunctionDesc) RequiredArgs() int

RequiredArgs returns the number of the required function args.

type IndexOf added in v1.5.0

type IndexOf struct{}

IndexOf returns the index of the instance of substring in a given string depending on the provided search order.

func (IndexOf) Call added in v1.5.0

func (f IndexOf) Call(args []interface{}) (interface{}, bool)

func (IndexOf) Desc added in v1.5.0

func (f IndexOf) Desc() FunctionDesc

func (IndexOf) Name added in v1.5.0

func (f IndexOf) Name() Fn

type Length added in v1.5.0

type Length struct{}

Length returns the number of characters (runes) for string arguments and the size of the slice for slice arguments.

func (Length) Call added in v1.5.0

func (f Length) Call(args []interface{}) (interface{}, bool)

func (Length) Desc added in v1.5.0

func (f Length) Desc() FunctionDesc

func (Length) Name added in v1.5.0

func (f Length) Name() Fn

type Lower added in v1.5.0

type Lower struct{}

Lower converts the string with all Unicode letters mapped to their lower case.

func (Lower) Call added in v1.5.0

func (f Lower) Call(args []interface{}) (interface{}, bool)

func (Lower) Desc added in v1.5.0

func (f Lower) Desc() FunctionDesc

func (Lower) Name added in v1.5.0

func (f Lower) Name() Fn

type Ltrim added in v1.5.0

type Ltrim struct{}

Ltrim trims the specified prefix from a string.

func (Ltrim) Call added in v1.5.0

func (f Ltrim) Call(args []interface{}) (interface{}, bool)

func (Ltrim) Desc added in v1.5.0

func (f Ltrim) Desc() FunctionDesc

func (Ltrim) Name added in v1.5.0

func (f Ltrim) Name() Fn

type MD5

type MD5 struct{}

MD5 computes the MD5 hash of the given value.

func (MD5) Call

func (f MD5) Call(args []interface{}) (interface{}, bool)

func (MD5) Desc

func (f MD5) Desc() FunctionDesc

func (MD5) Name

func (f MD5) Name() Fn

type Regex added in v1.5.0

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

Regex applies single/multiple regular expressions on the provided string arguments.

func NewRegex added in v1.5.0

func NewRegex() *Regex

NewRegex creates a new regex function.

func (Regex) Call added in v1.5.0

func (f Regex) Call(args []interface{}) (interface{}, bool)

func (Regex) Desc added in v1.5.0

func (f Regex) Desc() FunctionDesc

func (Regex) Name added in v1.5.0

func (f Regex) Name() Fn

type Replace added in v1.5.0

type Replace struct{}

Replace replaces occurrences in the string as given by arbitrary old/new replacement pairs.

func (Replace) Call added in v1.5.0

func (f Replace) Call(args []interface{}) (interface{}, bool)

func (Replace) Desc added in v1.5.0

func (f Replace) Desc() FunctionDesc

func (Replace) Name added in v1.5.0

func (f Replace) Name() Fn

type Rtrim added in v1.5.0

type Rtrim struct{}

Rtrim trims the specified suffix from a string.

func (Rtrim) Call added in v1.5.0

func (f Rtrim) Call(args []interface{}) (interface{}, bool)

func (Rtrim) Desc added in v1.5.0

func (f Rtrim) Desc() FunctionDesc

func (Rtrim) Name added in v1.5.0

func (f Rtrim) Name() Fn

type Split added in v1.5.0

type Split struct{}

Split produces a slice of substrings separated by the given delimiter.

func (Split) Call added in v1.5.0

func (f Split) Call(args []interface{}) (interface{}, bool)

func (Split) Desc added in v1.5.0

func (f Split) Desc() FunctionDesc

func (Split) Name added in v1.5.0

func (f Split) Name() Fn

type Substr added in v1.5.0

type Substr struct{}

Substr creates a substring of a given string.

func (Substr) Call added in v1.5.0

func (f Substr) Call(args []interface{}) (interface{}, bool)

func (Substr) Desc added in v1.5.0

func (f Substr) Desc() FunctionDesc

func (Substr) Name added in v1.5.0

func (f Substr) Name() Fn

type Upper added in v1.5.0

type Upper struct{}

Upper converts the string with all Unicode letters mapped to their upper case.

func (Upper) Call added in v1.5.0

func (f Upper) Call(args []interface{}) (interface{}, bool)

func (Upper) Desc added in v1.5.0

func (f Upper) Desc() FunctionDesc

func (Upper) Name added in v1.5.0

func (f Upper) Name() Fn

Jump to

Keyboard shortcuts

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