1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
|
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsstringutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsStringReplacement
{
%Docstring(signature="appended")
A representation of a single string replacement.
%End
%TypeHeaderCode
#include "qgsstringutils.h"
%End
public:
QgsStringReplacement( const QString &match,
const QString &replacement,
bool caseSensitive = false,
bool wholeWordOnly = false );
%Docstring
Constructor for QgsStringReplacement.
:param match: string to match
:param replacement: string to replace match with
:param caseSensitive: set to ``True`` for a case sensitive match
:param wholeWordOnly: set to ``True`` to match complete words only, or
``False`` to allow partial word matches
%End
QString match() const;
%Docstring
Returns the string matched by this object
%End
QString replacement() const;
%Docstring
Returns the string to replace matches with
%End
bool caseSensitive() const;
%Docstring
Returns ``True`` if match is case sensitive
%End
bool wholeWordOnly() const;
%Docstring
Returns ``True`` if match only applies to whole words, or ``False`` if
partial word matches are permitted
%End
QString process( const QString &input ) const;
%Docstring
Processes a given input string, applying any valid replacements which
should be made.
:param input: input string
:return: input string with any matches replaced by replacement string
%End
bool operator==( const QgsStringReplacement &other ) const;
QgsStringMap properties() const;
%Docstring
Returns a map of the replacement properties.
.. seealso:: :py:func:`fromProperties`
%End
static QgsStringReplacement fromProperties( const QgsStringMap &properties );
%Docstring
Creates a new QgsStringReplacement from an encoded properties map.
.. seealso:: :py:func:`properties`
%End
};
class QgsStringReplacementCollection
{
%Docstring(signature="appended")
A collection of string replacements (specified using
:py:class:`QgsStringReplacement` objects).
%End
%TypeHeaderCode
#include "qgsstringutils.h"
%End
public:
QgsStringReplacementCollection( const QList< QgsStringReplacement > &replacements = QList< QgsStringReplacement >() );
%Docstring
Constructor for QgsStringReplacementCollection
:param replacements: initial list of string replacements
%End
QList< QgsStringReplacement > replacements() const;
%Docstring
Returns the list of string replacements in this collection.
.. seealso:: :py:func:`setReplacements`
%End
void setReplacements( const QList< QgsStringReplacement > &replacements );
%Docstring
Sets the list of string replacements in this collection.
:param replacements: list of string replacements to apply. Replacements
are applied in the order they are specified here.
.. seealso:: :py:func:`replacements`
%End
QString process( const QString &input ) const;
%Docstring
Processes a given input string, applying any valid replacements which
should be made using :py:class:`QgsStringReplacement` objects contained
by this collection. Replacements are made in order of the
:py:class:`QgsStringReplacement` objects contained in the collection.
:param input: input string
:return: input string with any matches replaced by replacement string
%End
void writeXml( QDomElement &elem, QDomDocument &doc ) const;
%Docstring
Writes the collection state to an XML element.
:param elem: target DOM element
:param doc: DOM document
.. seealso:: :py:func:`readXml`
%End
void readXml( const QDomElement &elem );
%Docstring
Reads the collection state from an XML element.
:param elem: DOM element
.. seealso:: :py:func:`writeXml`
%End
};
class QgsStringUtils
{
%Docstring(signature="appended")
Utility functions for working with strings.
%End
%TypeHeaderCode
#include "qgsstringutils.h"
%End
public:
static QString capitalize( const QString &string, Qgis::Capitalization capitalization );
%Docstring
Converts a string by applying capitalization rules to the string.
:param string: input string
:param capitalization: capitalization type to apply
:return: capitalized string
%End
static QString ampersandEncode( const QString &string );
%Docstring
Makes a raw string safe for inclusion as a HTML/XML string literal.
This includes replacing '<' with '<', '>' with '>', '&' with
'&', and any extended unicode characters with the XML style é
encoded versions of these characters.
.. versionadded:: 3.2
%End
static int levenshteinDistance( const QString &string1, const QString &string2, bool caseSensitive = false );
%Docstring
Returns the Levenshtein edit distance between two strings. This equates
to the minimum number of character edits (insertions, deletions or
substitutions) required to change one string to another.
:param string1: first string
:param string2: second string
:param caseSensitive: set to ``True`` for case sensitive comparison
:return: edit distance. Lower distances indicate more similar strings.
%End
static QString longestCommonSubstring( const QString &string1, const QString &string2, bool caseSensitive = false );
%Docstring
Returns the longest common substring between two strings. This substring
is the longest string that is a substring of the two input strings. For
example, the longest common substring of "ABABC" and "BABCA" is "ABC".
:param string1: first string
:param string2: second string
:param caseSensitive: set to ``True`` for case sensitive comparison
:return: longest common substring
%End
static int hammingDistance( const QString &string1, const QString &string2, bool caseSensitive = false );
%Docstring
Returns the Hamming distance between two strings. This equates to the
number of characters at corresponding positions within the input strings
where the characters are different. The input strings must be the same
length.
:param string1: first string
:param string2: second string
:param caseSensitive: set to ``True`` for case sensitive comparison
:return: Hamming distance between strings, or -1 if strings are
different lengths.
%End
static QString soundex( const QString &string );
%Docstring
Returns the Soundex representation of a string. Soundex is a phonetic
matching algorithm, so strings with similar sounds should be represented
by the same Soundex code.
:param string: input string
:return: 4 letter Soundex code
%End
static double fuzzyScore( const QString &candidate, const QString &search );
%Docstring
Tests a ``candidate`` string to see how likely it is a match for a
specified ``search`` string. Values are normalized between 0 and 1.
:param candidate: candidate string
:param search: search term string
:return: Normalized value of how likely is the ``search`` to be in the
``candidate``
.. note::
Use this function only to calculate the fuzzy score between two strings and later compare these values, but do not depend on the actual numbers. They are implementation detail that may change in a future release.
.. versionadded:: 3.14
%End
static QString insertLinks( const QString &string, bool *foundLinks = 0 );
%Docstring
Returns a string with any URL (e.g., http(s)/ftp) and mailto: text
converted to valid HTML <a ...> links.
:param string: string to insert links into
:param foundLinks: if specified, will be set to ``True`` if any links
were inserted into the string
:return: string with inserted links
%End
static bool isUrl( const QString &string );
%Docstring
Returns whether the string is a URL (http,https,ftp,file)
:param string: the string to check
:return: whether the string is an URL
.. versionadded:: 3.22
%End
static QString wordWrap( const QString &string, int length, bool useMaxLineLength = true, const QString &customDelimiter = QString() );
%Docstring
Automatically wraps a ``string`` by inserting new line characters at
appropriate locations in the string.
The ``length`` argument specifies either the minimum or maximum length
of lines desired, depending on whether ``useMaxLineLength`` is ``True``.
If ``useMaxLineLength`` is ``True``, then the string will be wrapped so
that each line ideally will not exceed ``length`` of characters. If
``useMaxLineLength`` is ``False``, then the string will be wrapped so
that each line will ideally exceed ``length`` of characters.
A custom delimiter can be specified to use instead of space characters.
.. versionadded:: 3.4
%End
static QString substituteVerticalCharacters( QString string );
%Docstring
Returns a string with characters having vertical representation form
substituted.
:param string: input string
:return: string with substitution applied
.. versionadded:: 3.10
%End
static QString htmlToMarkdown( const QString &html );
%Docstring
Convert simple HTML to markdown. Only br, b and link are supported.
:param html: HTML to convert to markdown
:return: String formatted as markdown
.. versionadded:: 3.10
%End
static QString qRegExpEscape( const QString &string );
%Docstring
Returns an escaped string matching the behavior of QRegExp.escape.
:param string: String to escape
:return: Escaped string
.. versionadded:: 3.22
%End
static QString truncateMiddleOfString( const QString &string, int maxLength );
%Docstring
Truncates a ``string`` to the specified maximum character length.
If the ``string`` exceeds the maximum character length, then the string
will be truncated by removing characters from the middle of the string
and replacing them with a horizontal ellipsis character.
.. versionadded:: 3.22
%End
static bool containsByWord( const QString &candidate, const QString &words, Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive );
%Docstring
Given a ``candidate`` string, returns ``True`` if the ``candidate``
contains all the individual words from another string, regardless of
their order.
.. note::
The search does NOT need to match whole words in the ``candidate`` string,
so eg a candidate string of "Worldmap_Winkel_II" will return ``True`` for ``words`` "winkle world"
.. versionadded:: 3.42
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsstringutils.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
|