16 #include "qgis_core.h"
20 #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;
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;
190 MixedCase = QFont::MixedCase,
191 AllUppercase = QFont::AllUppercase,
192 AllLowercase = QFont::AllLowercase,
193 ForceFirstLetterToCapital = QFont::Capitalize,
194 TitleCase = QFont::Capitalize + 1000,
195 UpperCamelCase = QFont::Capitalize + 1001,
205 static QString capitalize(
const QString &
string, Capitalization capitalization );
215 static QString ampersandEncode(
const QString &
string );
226 static int levenshteinDistance(
const QString &string1,
const QString &string2,
bool caseSensitive =
false );
237 static QString longestCommonSubstring(
const QString &string1,
const QString &string2,
bool caseSensitive =
false );
248 static int hammingDistance(
const QString &string1,
const QString &string2,
bool caseSensitive =
false );
256 static QString soundex(
const QString &
string );
267 static double fuzzyScore(
const QString &candidate,
const QString &search );
277 static QString insertLinks(
const QString &
string,
bool *foundLinks =
nullptr );
291 static QString wordWrap(
const QString &
string,
int length,
bool useMaxLineLength =
true,
const QString &customDelimiter = QString() );
299 static QString substituteVerticalCharacters( QString
string );
307 static QString htmlToMarkdown(
const QString &html );
311 #endif //QGSSTRINGUTILS_H