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