pattern

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: BSD-3-Clause Imports: 5 Imported by: 6

Documentation

Overview

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

This file was auto-generated by the vanadium vdl tool. Package: pattern

Index

Constants

View Source
const (
	// DefaultEscapeChar is the default escape character sequence.
	DefaultEscapeChar = '\\'
)

Variables

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

Functions

func ErrorfIllegalEscapeChar added in v0.1.10

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

ErrorfIllegalEscapeChar calls ErrIllegalEscapeChar.Errorf with the supplied arguments.

func ErrorfInvalidEscape added in v0.1.10

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

ErrorfInvalidEscape calls ErrInvalidEscape.Errorf with the supplied arguments.

func Escape

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

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 added in v0.1.10

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

MessageIllegalEscapeChar calls ErrIllegalEscapeChar.Message with the supplied arguments.

func MessageInvalidEscape added in v0.1.10

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

MessageInvalidEscape calls ErrInvalidEscape.Message with the supplied arguments.

func ParamsErrIllegalEscapeChar added in v0.1.10

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

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

func ParamsErrInvalidEscape added in v0.1.10

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

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

Types

type Pattern

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

Pattern is a parsed LIKE-style glob pattern.

func Parse

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

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

func ParseWithEscapeChar

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

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

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

MatchString returns true iff the pattern matches the entire string.

Jump to

Keyboard shortcuts

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