KVIrc 5.2.0
Developer APIs
KviRegExp.h
Go to the documentation of this file.
1#ifndef _KVI_REGEXP_H_
2#define _KVI_REGEXP_H_
3//=============================================================================
4//
5// File : KviRegExp.h
6// Creation date : Tue Oct 3 2023 17:25:21 CEST by Fabio Bas
7//
8// This file is part of the KVIrc IRC client distribution
9// Copyright (C) 2000-2023 Szymon Stefanek (pragma at kvirc dot net)
10//
11// This program is FREE software. You can redistribute it and/or
12// modify it under the terms of the GNU General Public License
13// as published by the Free Software Foundation; either version 2
14// of the License, or (at your option) any later version.
15//
16// This program is distributed in the HOPE that it will be USEFUL,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19// See the GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program. If not, write to the Free Software Foundation,
23// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24//
25//=============================================================================
26
27#include "kvi_settings.h"
28
29#include <QString>
30#include <QRegularExpression>
31#include <QRegularExpressionMatch>
32
34{
35public:
37 {
38 CaseInsensitive = 0,
39 CaseSensitive = 1,
40 };
41
43 {
44 RegExp = 0,
45 Wildcard = 1,
46 };
47
48 KviRegExp(const QString & szPattern = QString(), const KviRegExp::CaseSensitivity cs = CaseSensitive, const KviRegExp::PatternSyntax ps = RegExp);
49
50 operator QRegularExpression() const {
51 QRegularExpression re(getCompletePattern(), getPatternOptions());
52 return re;
53 }
54
55private:
56 QString m_szPattern;
57 QRegularExpressionMatch m_oLastMatch;
61
62 QString getCompletePattern() const;
63 QRegularExpression::PatternOptions getPatternOptions() const;
64
65public:
66 const QString & pattern() const { return m_szPattern; };
67 void setPattern(const QString & szPattern) { m_szPattern = szPattern; };
69 void setMinimal(bool bMinimal) { m_bMinimal = bMinimal; };
70 bool exactMatch(const QString & szStr);
71 int indexIn(const QString & szStr, int offset = 0);
72 int matchedLength() const;
73 QString cap(int iNth = 0) const;
74 QStringList capturedTexts() const;
75 static QString escape(const QString &szStr) { return QRegularExpression::escape(szStr); };
76};
77
78#endif
Definition KviRegExp.h:34
const QString & pattern() const
Definition KviRegExp.h:66
void setMinimal(bool bMinimal)
Definition KviRegExp.h:69
void setCaseSensitivity(KviRegExp::CaseSensitivity cs)
Definition KviRegExp.h:68
bool m_bMinimal
Definition KviRegExp.h:60
KviRegExp::CaseSensitivity m_eCs
Definition KviRegExp.h:58
CaseSensitivity
Definition KviRegExp.h:37
QRegularExpressionMatch m_oLastMatch
Definition KviRegExp.h:57
PatternSyntax
Definition KviRegExp.h:43
QString m_szPattern
Definition KviRegExp.h:56
void setPattern(const QString &szPattern)
Definition KviRegExp.h:67
static QString escape(const QString &szStr)
Definition KviRegExp.h:75
KviRegExp::PatternSyntax m_ePs
Definition KviRegExp.h:59
This file contains compile time settings.
#define KVILIB_API
Definition kvi_settings.h:124