filter

package
v0.0.0-...-288c4de Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultParseBool

func DefaultParseBool(c Clause) (bool, error)

DefaultParseBool converts the value of the clause to boolean.

func DefaultParseInt

func DefaultParseInt(c Clause) (int64, error)

DefaultParseInt converts the value of the clause to int64.

func DefaultParseRegexp

func DefaultParseRegexp(c Clause) (*regexp.Regexp, error)

DefaultParseRegexp converts the value of the clause to regexp.

func DefaultParseString

func DefaultParseString(c Clause) (string, error)

DefaultParseString converts the value of the clause to string.

func DefaultParseUint

func DefaultParseUint(c Clause) (uint64, error)

DefaultParseUint converts the value of the clause to Uint64.

func Match

func Match(obj any, set ClauseSet) (bool, error)

Match returns true if the given object matches the given filter.

func ValueOf

func ValueOf(obj any, field string) any

ValueOf returns the value of the given field.

Types

type Clause

type Clause struct {
	PrevLogical string
	Not         bool
	Field       string
	Operator    string
	Value       string
}

Clause is a single filter clause in a filter string.

type ClauseSet

type ClauseSet struct {
	Clauses []Clause
	Ops     OperatorSet

	ParseInt    func(Clause) (int64, error)
	ParseUint   func(Clause) (uint64, error)
	ParseString func(Clause) (string, error)
	ParseBool   func(Clause) (bool, error)
	ParseRegexp func(Clause) (*regexp.Regexp, error)
}

ClauseSet is a set of clauses. There are configurable functions that can be used to perform unique parsing of the clauses.

func Parse

func Parse(s string, op OperatorSet) (*ClauseSet, error)

Parse a user-provided filter string.

type OperatorSet

type OperatorSet struct {
	And       string
	Or        string
	Equals    string
	NotEquals string

	GreaterThan  string
	LessThan     string
	GreaterEqual string
	LessEqual    string

	Negate string
	Quote  []string
}

OperatorSet is represents the types of operators and symbols that a filter can support.

func QueryOperatorSet

func QueryOperatorSet() OperatorSet

QueryOperatorSet returns the default operator set for LXD API queries.

Jump to

Keyboard shortcuts

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