github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/exp/locale/search/search.go (about) 1 // Copyright 2013 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Package search provides language-sensitive string search functionality. 6 package search // import "golang.org/x/exp/locale/search" 7 8 import ( 9 "golang.org/x/text/collate/colltab" 10 "golang.org/x/text/language" 11 ) 12 13 // An Option specifies a search-related feature. 14 type Option int 15 16 const ( 17 IgnoreCase Option = 1 << iota // Case-insensitive search. 18 IgnoreDiacritics // Ignore diacritics. ("รถ" == "o"). 19 IgnoreWidth // Ignore full versus normal width. 20 WholeWord // Only match at whole-word boundaries. 21 Literal // Exact equivalence. 22 23 Loose = IgnoreCase | IgnoreDiacritics | IgnoreWidth 24 ) 25 26 // Search provides language-sensitive search functionality. 27 type Search struct { 28 c colltab.Weigher 29 } 30 31 // New returns a new Search for the given language. 32 func New(l language.Tag) *Search { 33 return nil 34 } 35 36 // NewFromWeigher returns a Search given a Weigher. 37 func NewFromWeigher(t colltab.Weigher) *Search { 38 return nil 39 } 40 41 // SetOptions configures s to the options specified by mask. 42 func (s *Search) SetOptions(mask Option) error { 43 return nil 44 } 45 46 // Match checks whether a and b are equivalent. 47 func (s *Search) Match(a, b []byte) bool { 48 return false 49 } 50 51 // MatchString checks whether a and b are equivalent. 52 func (s *Search) MatchString(a, b string) bool { 53 return false 54 } 55 56 // HasPrefix tests whether the byte slice str begins with prefix. 57 func (s *Search) HasPrefix(str, prefix []byte) bool { 58 return false 59 } 60 61 // HasPrefixString tests whether the string str begins with prefix. 62 func (s *Search) HasPrefixString(str, prefix string) bool { 63 return false 64 } 65 66 // HasSuffix tests whether the byte slice str ends with suffix. 67 func (s *Search) HasSufix(str, suffix []byte) bool { 68 return false 69 } 70 71 // HasSuffixString tests whether the string str ends with suffix. 72 func (s *Search) HasSufixString(str, suffix string) bool { 73 return false 74 } 75 76 // CommonPrefix returns a[:n], where n is the largest value that 77 // satisfies s.Match(a[:n], b). 78 func (s *Search) CommonPrefix(a, b []byte) []byte { 79 return nil 80 } 81 82 // CommonPrefixString returns a[:n], where n is the largest value that 83 // satisfies s.Match(a[:n], b). 84 func (s *Search) CommonPrefixString(a, b string) string { 85 return "" 86 } 87 88 // Find returns a two-element slice of integers defining the leftmost 89 // match in b of pat. A return value of nil indicates no match. 90 func (s *Search) Find(b, pat []byte) []int { 91 return nil 92 } 93 94 // FindString returns a two-element slice of integers defining the leftmost 95 // match in str of pat. A return value of nil indicates no match. 96 func (s *Search) FindString(str, pat string) []int { 97 return nil 98 } 99 100 // FindLast returns a two-element slice of integers defining the rightmost 101 // match in b of pat. A return value of nil indicates no match. 102 func (s *Search) FindLast(b, pat []byte) []int { 103 return nil 104 } 105 106 // FindLastString returns a two-element slice of integers defining the rightmost 107 // match in str of pat. A return value of nil indicates no match. 108 func (s *Search) FindLastString(str, pat string) []int { 109 return nil 110 } 111 112 // FindAll returns a slice of successive matches of pat in b, each represented 113 // by a two-element slice of integers. A return value of nil indicates no match. 114 func (s *Search) FindAll(b, pat []byte) [][]int { 115 return nil 116 } 117 118 // FindAllString returns a slice of successive matches of pat in str, each represented 119 // by a two-element slice of integers. A return value of nil indicates no match. 120 func (s *Search) FindAllString(str, pat string) [][]int { 121 return nil 122 } 123 124 // Pattern holds a preprocessed search pattern. On repeated use of a search 125 // pattern, it will be more efficient to use Pattern than the direct methods. 126 type Pattern struct { 127 s *Search 128 colelems []colltab.Elem 129 } 130 131 // Compile creates a Pattern from b that can be used to match against text. 132 func (s *Search) Compile(b []byte) *Pattern { 133 return &Pattern{s, nil} 134 } 135 136 // CompileString creates a Pattern from b that can be used to match against text. 137 func (s *Search) CompileString(b string) *Pattern { 138 return &Pattern{s, nil} 139 } 140 141 // Match checks whether b matches p. 142 func (p *Pattern) Match(b []byte) bool { 143 return false 144 } 145 146 // MatchString checks whether b is equivalent to p. 147 func (p *Pattern) MatchString(b []byte) bool { 148 return false 149 } 150 151 // CommonPrefix returns b[:n], where n is the largest value that 152 // satisfies p.Match(b[:n]). 153 func (p *Pattern) CommonPrefix(b []byte) []byte { 154 return nil 155 } 156 157 // CommonPrefixString returns s[:n], where n is the largest value that 158 // satisfies p.Match(s[:n]). 159 func (p *Pattern) CommonPrefixString(s string) []byte { 160 return nil 161 } 162 163 // HasPrefix tests whether the byte slice b begins with p. 164 func (p *Pattern) HasPrefix(b []byte) bool { 165 return false 166 } 167 168 // HasPrefixString tests whether the string s begins with p. 169 func (p *Pattern) HasPrefixString(s string) bool { 170 return false 171 } 172 173 // HasSuffix tests whether the byte slice b ends with p. 174 func (p *Pattern) HasSuffix(b []byte) bool { 175 return false 176 } 177 178 // HasSuffixString tests whether the string s ends with p. 179 func (p *Pattern) HasSuffixString(s string) bool { 180 return false 181 } 182 183 // Find returns a two-element slice of integers defining the leftmost 184 // match of p in b. A return value of nil indicates no match. 185 func (p *Pattern) Find(b []byte) []int { 186 return nil 187 } 188 189 // FindString returns a two-element slice of integers defining the leftmost 190 // match of p in s. A return value of nil indicates no match. 191 func (p *Pattern) FindString(s string) []int { 192 return nil 193 } 194 195 // FindLast returns a two-element slice of integers defining the rightmost 196 // match of p in b. A return value of nil indicates no match. 197 func (p *Pattern) FindLast(b []byte) []int { 198 return nil 199 } 200 201 // FindLastString returns a two-element slice of integers defining the rightmost 202 // match of p in s. A return value of nil indicates no match. 203 func (p *Pattern) FindLastString(s string) []int { 204 return nil 205 } 206 207 // FindAll returns a slice of successive matches of p in b, each represented 208 // by a two-element slice of integers. A return value of nil indicates no match. 209 func (p *Pattern) FindAll(b []byte) [][]int { 210 return nil 211 } 212 213 // FindAllString returns a slice of successive matches of p in s, each represented 214 // by a two-element slice of integers. A return value of nil indicates no match. 215 func (p *Pattern) FindAllString(s string) [][]int { 216 return nil 217 }