TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
ttkregularexpression.h
Go to the documentation of this file.
1 #ifndef TTKREGULAREXPRESSION_H
2 #define TTKREGULAREXPRESSION_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Library Module project
6  * Copyright (C) 2015 - 2026 Greedysky Studio
7 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17 
18  * You should have received a copy of the GNU Lesser General Public License along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include "ttkmoduleexport.h"
23 #if TTK_QT_VERSION_CHECK(5,0,0)
24 # include <QRegularExpression>
25 #else
26 # include <QRegExp>
27 #endif
28 
33 {
34 public:
36  {
37  NoPatternOption = 0x0000,
38  CaseInsensitiveOption = 0x0001,
39  InvertedGreedinessOption = 0x0010,
40  };
41 
46  explicit TTKRegularExpression(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 
108 public:
112  static QString escape(const QString &str);
113 
114 #if TTK_QT_VERSION_CHECK(5,0,0)
115  const QRegularExpression &value() const;
116  operator QRegularExpression &();
117  operator const QRegularExpression &() const;
118 private:
119  QRegularExpression m_regular;
120  QRegularExpressionMatch m_match;
121 #else
122  const QRegExp &value() const;
123  operator QRegExp &();
124  operator const QRegExp &() const;
125 private:
126  QRegExp m_regular;
127 #endif
128 
129 };
130 
131 #endif // TTKREGULAREXPRESSION_H
#define TTK_MODULE_EXPORT
The class of the regular expression.