Fix building libgit with Windows 11 SDK 10.0.26100.0
[TortoiseGit.git] / ext / scintilla / src / RESearch.h
bloba232d4506ee314d18a901f147dfd7a4bb91e16dc
1 // Scintilla source code edit control
2 /** @file RESearch.h
3 ** Interface to the regular expression search library.
4 **/
5 // Written by Neil Hodgson <neilh@scintilla.org>
6 // Based on the work of Ozan S. Yigit.
7 // This file is in the public domain.
9 #ifndef RESEARCH_H
10 #define RESEARCH_H
12 namespace Scintilla::Internal {
14 class CharacterIndexer {
15 public:
16 virtual char CharAt(Sci::Position index) const=0;
17 virtual Sci::Position MovePositionOutsideChar(Sci::Position pos, [[maybe_unused]] Sci::Position moveDir) const noexcept=0;
20 class RESearch {
22 public:
23 explicit RESearch(CharClassify *charClassTable);
24 // No dynamic allocation so default copy constructor and assignment operator are OK.
25 void Clear();
26 const char *Compile(const char *pattern, Sci::Position length, bool caseSensitive, bool posix);
27 int Execute(const CharacterIndexer &ci, Sci::Position lp, Sci::Position endp);
28 void SetLineRange(Sci::Position startPos, Sci::Position endPos) noexcept {
29 lineStartPos = startPos;
30 lineEndPos = endPos;
33 static constexpr int MAXTAG = 10;
34 static constexpr int NOTFOUND = -1;
36 using MatchPositions = std::array<Sci::Position, MAXTAG>;
37 MatchPositions bopat;
38 MatchPositions eopat;
40 private:
42 static constexpr int MAXNFA = 4096;
43 // The following constants are not meant to be changeable.
44 // They are for readability only.
45 static constexpr int MAXCHR = 256;
46 static constexpr int CHRBIT = 8;
47 static constexpr int BITBLK = MAXCHR / CHRBIT;
49 void ChSet(unsigned char c) noexcept;
50 void ChSetWithCase(unsigned char c, bool caseSensitive) noexcept;
51 int GetBackslashExpression(const char *pattern, int &incr) noexcept;
53 Sci::Position PMatch(const CharacterIndexer &ci, Sci::Position lp, Sci::Position endp, const char *ap);
55 // positions to match line start and line end
56 Sci::Position lineStartPos;
57 Sci::Position lineEndPos;
58 char nfa[MAXNFA]; /* automaton */
59 int sta;
60 int failure;
61 std::array<unsigned char, BITBLK> bittab {}; /* bit table for CCL pre-set bits */
62 CharClassify *charClass;
63 bool iswordc(unsigned char x) const noexcept {
64 return charClass->IsWord(x);
70 #endif