TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
regularexpression.h
Go to the documentation of this file.
1 /***************************************************************************
2  * This file is part of the TTK qmmp plugin project
3  * Copyright (C) 2015 - 2026 Greedysky Studio
4 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14 
15  * You should have received a copy of the GNU General Public License along
16  * with this program; If not, see <http://www.gnu.org/licenses/>.
17  ***************************************************************************/
18 
19 #ifndef REGULAREXPRESSION_H
20 #define REGULAREXPRESSION_H
21 
22 #include "qmmp_export.h"
23 #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
24 # include <QRegExp>
25 #else
26 # include <QRegularExpression>
27 #endif
28 
33 {
34 public:
36  {
37  NoPatternOption = 0x0000,
38  CaseInsensitiveOption = 0x0001,
39  InvertedGreedinessOption = 0x0010,
40  };
41 
46  explicit RegularExpression(const QString &pattern, int option = NoPatternOption);
47 
51  QString pattern() const;
55  void setPattern(const QString &v);
56 
60  int patternOptions() const;
64  void setPatternOptions(const int option);
65 
66 public:
70  bool hasMatch(const QString &str);
71 
75  int match(const QString &str, int pos = 0);
76 
80  QString captured(int index) const;
81 
85  int capturedLength() const;
86 
87 public:
91  bool isGreediness() const;
92 
96  void setGreediness(bool v);
97 
101  bool isCaseSensitivity() const;
102 
106  void setCaseSensitivity(bool v);
107 
111  static QString escape(const QString &str);
112 
113 #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
114  const QRegExp &value() const;
115  operator QRegExp &();
116  operator const QRegExp &() const;
117 private:
118  QRegExp m_regular;
119 #else
120  const QRegularExpression &value() const;
121  operator QRegularExpression &();
122  operator const QRegularExpression &() const;
123 private:
124  QRegularExpression m_regular;
125  QRegularExpressionMatch m_match;
126 #endif
127 
128 };
129 
130 #endif // REGULAREXPRESSION_H
QRegularExpressionMatch m_match
QRegularExpression m_regular
#define RegularExpression
#define QMMP_EXPORT
Definition: qmmp_export.h:29
The class of the regular expression.