File indexing completed on 2024-04-21 05:51:40
0001 /* 0002 * SPDX-FileCopyrightText: 2002-2003 Jesper K. Pedersen <blackie@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-only 0005 **/ 0006 0007 #ifndef __TEXTRANGEREGEXP_H 0008 #define __TEXTRANGEREGEXP_H 0009 0010 #include "regexp.h" 0011 0012 #include <QList> 0013 #include <QPair> 0014 #include <QStringList> 0015 0016 typedef QPair<QString, QString> StringPair; 0017 0018 /** 0019 Abstract syntax node for `text range' regular expression 0020 0021 @internal 0022 */ 0023 class TextRangeRegExp : public RegExp 0024 { 0025 public: 0026 TextRangeRegExp(bool selected); 0027 ~TextRangeRegExp() override; 0028 0029 void addCharacter(const QString &ch); 0030 QStringList chars() const 0031 { 0032 return _chars; 0033 } 0034 0035 void clearChars() 0036 { 0037 _chars.clear(); 0038 } 0039 0040 void addRange(const QString &from, const QString &to); 0041 QList<StringPair> range() const 0042 { 0043 return _ranges; 0044 } 0045 0046 void clearRange() 0047 { 0048 _ranges.clear(); 0049 } 0050 0051 void setNegate(bool set) 0052 { 0053 _negate = set; 0054 } 0055 0056 void setDigit(bool set) 0057 { 0058 _digit = set; 0059 } 0060 0061 void setNonDigit(bool set) 0062 { 0063 _nonDigit = set; 0064 } 0065 0066 void setSpace(bool set) 0067 { 0068 _space = set; 0069 } 0070 0071 void setNonSpace(bool set) 0072 { 0073 _nonSpace = set; 0074 } 0075 0076 void setWordChar(bool set) 0077 { 0078 _wordChar = set; 0079 } 0080 0081 void setNonWordChar(bool set) 0082 { 0083 _nonWordChar = set; 0084 } 0085 0086 bool negate() const 0087 { 0088 return _negate; 0089 } 0090 0091 bool digit() const 0092 { 0093 return _digit; 0094 } 0095 0096 bool nonDigit() const 0097 { 0098 return _nonDigit; 0099 } 0100 0101 bool space() const 0102 { 0103 return _space; 0104 } 0105 0106 bool nonSpace() const 0107 { 0108 return _nonSpace; 0109 } 0110 0111 bool wordChar() const 0112 { 0113 return _wordChar; 0114 } 0115 0116 bool nonWordChar() const 0117 { 0118 return _nonWordChar; 0119 } 0120 0121 bool check(ErrorMap &, bool first, bool last) override; 0122 int precedence() const override 0123 { 0124 return 4; 0125 } 0126 0127 QDomNode toXml(QDomDocument *doc) const override; 0128 bool load(const QDomElement &, const QString &version) override; 0129 RegExpType type() const override 0130 { 0131 return TEXTRANGE; 0132 } 0133 0134 bool operator==(const RegExp &other) const override; 0135 0136 private: 0137 bool _negate, _digit, _nonDigit, _space, _nonSpace, _wordChar, _nonWordChar; 0138 QStringList _chars; 0139 QList<StringPair> _ranges; 0140 }; 0141 0142 #endif // __TEXTRANGEREGEXP_H