v.io: v.io/v23/query/pattern Index | Files

package pattern

import "v.io/v23/query/pattern"

Package pattern handles parsing and matching SQL LIKE-style glob patterns.


Package Files

pattern.go pattern.vdl.go


const (
    DefaultEscapeChar = '\\'


var (
    ErrIllegalEscapeChar = verror.NewIDAction("v.io/v23/query/pattern.IllegalEscapeChar", verror.NoRetry)
    ErrInvalidEscape     = verror.NewIDAction("v.io/v23/query/pattern.InvalidEscape", verror.NoRetry)

func ErrorfIllegalEscapeChar Uses

func ErrorfIllegalEscapeChar(ctx *context.T, format string) error

ErrorfIllegalEscapeChar calls ErrIllegalEscapeChar.Errorf with the supplied arguments.

func ErrorfInvalidEscape Uses

func ErrorfInvalidEscape(ctx *context.T, format string, escaped string) error

ErrorfInvalidEscape calls ErrInvalidEscape.Errorf with the supplied arguments.

func Escape Uses

func Escape(s string) string

Escape escapes a literal string for inclusion in a LIKE-style pattern assuming '\' as escape character. See EscapeWithEscapeChar().

func EscapeWithEscapeChar Uses

func EscapeWithEscapeChar(s string, escChar rune) string

EscapeWithEscapeChar escapes a literal string for inclusion in a LIKE-style pattern. It inserts escChar before each '_', '%', and escChar in the string.

func MessageIllegalEscapeChar Uses

func MessageIllegalEscapeChar(ctx *context.T, message string) error

MessageIllegalEscapeChar calls ErrIllegalEscapeChar.Message with the supplied arguments.

func MessageInvalidEscape Uses

func MessageInvalidEscape(ctx *context.T, message string, escaped string) error

MessageInvalidEscape calls ErrInvalidEscape.Message with the supplied arguments.

func ParamsErrIllegalEscapeChar Uses

func ParamsErrIllegalEscapeChar(argumentError error) (verrorComponent string, verrorOperation string, returnErr error)

ParamsErrIllegalEscapeChar extracts the expected parameters from the error's ParameterList.

func ParamsErrInvalidEscape Uses

func ParamsErrInvalidEscape(argumentError error) (verrorComponent string, verrorOperation string, escaped string, returnErr error)

ParamsErrInvalidEscape extracts the expected parameters from the error's ParameterList.

type Pattern Uses

type Pattern struct {
    // contains filtered or unexported fields

Pattern is a parsed LIKE-style glob pattern.

func Parse Uses

func Parse(pattern string) (*Pattern, error)

Parse parses a LIKE-style glob pattern assuming '\' as escape character. See ParseWithEscapeChar().

func ParseWithEscapeChar Uses

func ParseWithEscapeChar(pattern string, escChar rune) (*Pattern, error)

ParseWithEscapeChar parses a LIKE-style glob pattern. Supported wildcards are '_' (match any one character) and '%' (match zero or more characters). They can be escaped by escChar; escChar can also escape itself. '_' and '%' cannot be used as escChar; '\x00' escChar disables escaping.

func (*Pattern) FixedPrefix Uses

func (p *Pattern) FixedPrefix() (string, bool)

FixedPrefix returns the unescaped fixed prefix that all matching strings must start with, and whether the prefix is the whole pattern.

func (*Pattern) MatchString Uses

func (p *Pattern) MatchString(s string) bool

MatchString returns true iff the pattern matches the entire string.

Package pattern imports 5 packages (graph) and is imported by 21 packages. Updated 2021-01-25. Refresh now. Tools for package owners.