16 #include "qgis_core.h"
20 #include <QRegularExpression>
22 #include <QDomDocument>
24 #ifndef QGSSTRINGUTILS_H
25 #define QGSSTRINGUTILS_H
27 #define FUZZY_SCORE_WORD_MATCH 5
28 #define FUZZY_SCORE_NEW_MATCH 3
29 #define FUZZY_SCORE_CONSECUTIVE_MATCH 4
51 const QString &replacement,
52 bool caseSensitive =
false,
53 bool wholeWordOnly =
false );
56 QString
match()
const {
return mMatch; }
72 QString process(
const QString &input )
const;
76 return mMatch == other.mMatch
77 && mReplacement == other.mReplacement
78 && mCaseSensitive == other.mCaseSensitive
79 && mWholeWordOnly == other.mWholeWordOnly;
104 QRegularExpression mRx;
125 : mReplacements( replacements )
132 QList< QgsStringReplacement >
replacements()
const {
return mReplacements; }
142 mReplacements = replacements;
152 QString process(
const QString &input )
const;
160 void writeXml( QDomElement &elem, QDomDocument &doc )
const;
167 void readXml(
const QDomElement &elem );
171 QList< QgsStringReplacement > mReplacements;
204 static QString ampersandEncode(
const QString &
string );
215 static int levenshteinDistance(
const QString &string1,
const QString &string2,
bool caseSensitive =
false );
226 static QString longestCommonSubstring(
const QString &string1,
const QString &string2,
bool caseSensitive =
false );
237 static int hammingDistance(
const QString &string1,
const QString &string2,
bool caseSensitive =
false );
245 static QString soundex(
const QString &
string );
256 static double fuzzyScore(
const QString &candidate,
const QString &search );
266 static QString insertLinks(
const QString &
string,
bool *foundLinks =
nullptr );
274 static bool isUrl(
const QString &
string );
288 static QString wordWrap(
const QString &
string,
int length,
bool useMaxLineLength =
true,
const QString &customDelimiter = QString() );
296 static QString substituteVerticalCharacters( QString
string );
304 static QString htmlToMarkdown(
const QString &html );
312 static QString qRegExpEscape(
const QString &
string );
323 static QString truncateMiddleOfString(
const QString &
string,
int maxLength );
327 #endif //QGSSTRINGUTILS_H