-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathed_search.h
51 lines (43 loc) · 1.8 KB
/
ed_search.h
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
//
// Copyright 2015-2016 by Kevin L. Goodwin [[email protected]]; All rights reserved
//
// This file is part of K.
//
// K is free software: you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later
// version.
//
// K is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details.
//
// You should have received a copy of the GNU General Public License along
// with K. If not, see <http://www.gnu.org/licenses/>.
//
#pragma once
class RegexMatchCapture {
sridx d_ofs;
stref d_value;
public:
RegexMatchCapture() : d_ofs( eosr ), d_value( ) {}
RegexMatchCapture( int ofs_, stref val_ ) : d_ofs(ofs_ < 0 ? eosr : ofs_), d_value(val_) {}
bool valid() const { return d_ofs != eosr; }
stref value() const { return d_value; }
sridx offset() const { return d_ofs ; }
};
typedef std::vector<RegexMatchCapture> RegexMatchCaptures;
extern int DbgDumpCaptures( RegexMatchCaptures &captures, PCChar tag );
#if USE_PCRE
#include "pcre2.h"
class CompiledRegex;
extern CompiledRegex *Regex_Compile( stref pszSearchStr, bool fCase );
extern CompiledRegex *Regex_Delete0( CompiledRegex *pcr );
extern RegexMatchCaptures::size_type Regex_Match( CompiledRegex *pcr, RegexMatchCaptures &captures, stref haystack, COL haystack_offset, int pcre_exec_options );
extern void register_atexit_search();
extern stref RegexVersion();
#else
#define register_atexit_search()
STIL stref RegexVersion() { return ""; }
#endif