keyop

package
v0.0.0-...-6295505 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ops

func Ops() []string

Types

type L

type L []T

L is a list of T

func ParseList

func ParseList(exprs ...string) L

func ParseOps

func ParseOps(kws []string) L

type Op

type Op int

Op is an integer representing an operation on a configuration key value

const (
	// Invalid is for invalid operator
	Invalid Op = iota
	// Set overwrites the value
	Set
	// Append appends an element, even if already present
	Append
	// Remove removes an element if present, do nothing if not present
	Remove
	// Merge adds an element if not present, do nothing if present
	Merge
	// Toggle adds an element if not present, removes it if present
	Toggle
	// Insert adds an element at the position specified by Index
	Insert
	// Exist tests the existance of a key
	Exist
	// Equal tests if the current value of the key is equal to the keyop.T value
	Equal
	// NotEqual tests if the current value of the key is not equal to the keyop.T value
	NotEqual
	// GreaterOrEqual tests if the current value of the key is greater or equal to the keyop.T value
	GreaterOrEqual
	// LesserOrEqual tests if the current value of the key is lesser or equal to the keyop.T value
	LesserOrEqual
	// Greater tests if the current value of the key is greater to the keyop.T value
	Greater
	// Lesser tests if the current value of the key is lesser to the keyop.T value
	Lesser
)

func ParseOp

func ParseOp(s string) Op

ParseOp returns an operator from its string representation.

func (Op) Is

func (t Op) Is(op Op) bool

func (Op) MarshalJSON

func (t Op) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (Op) String

func (t Op) String() string

func (*Op) UnmarshalJSON

func (t *Op) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

type T

type T struct {
	Key   key.T
	Op    Op
	Value string
	Index int
}

T defines a parsed key operation

func New

func New(key key.T, op Op, value string, idx int) *T

func Parse

func Parse(s string) *T

func (T) IsZero

func (t T) IsZero() bool

func (T) String

func (t T) String() string

Jump to

Keyboard shortcuts

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