![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
Pure string helpers with no dependencies on QDoc driver types. More...
Functions | |
| QString | separator (qsizetype wordPosition, qsizetype numberOfWords) |
| QString | comma (qsizetype wordPosition, qsizetype numberOfWords) |
| QString | asAsciiPrintable (const QString &str) |
| Returns an ASCII-printable representation of str, preserving alphanumeric (alnum) characters ([a-zA-Z0-9]) and hyphens, but replacing all other characters with hyphens unless this would result in multiple adjacent hyphens. | |
| QString | protect (const QString &string) |
Variables | |
| static constexpr QLatin1StringView | samp = "&"_L1 |
| static constexpr QLatin1StringView | slt = "<"_L1 |
| static constexpr QLatin1StringView | sgt = ">"_L1 |
| static constexpr QLatin1StringView | squot = """_L1 |
Pure string helpers with no dependencies on QDoc driver types.
TextUtils groups text-manipulation helpers that the IR builders, the template generator, and the legacy generators all need, but that do not touch Node, Tree, Config, or Generator. Keeping them here lets QDocLib components call them without dragging in the rest of QDoc.
Returns an ASCII-printable representation of str, preserving alphanumeric (alnum) characters ([a-zA-Z0-9]) and hyphens, but replacing all other characters with hyphens unless this would result in multiple adjacent hyphens.
Upper case characters are converted to lower case.
The string that is returned is normalized for use where ASCII-printable strings are required, such as in file names or fragment identifiers in URLs.
We distinguish between hyphens in str and hyphens used as placeholders for non-alphanumeric characters.
Placeholder hyphens are removed from the start and end of the output string, such that the resulting string does not start or end with a hyphen unless the original string included them. Placeholder hyphens are only generated to separate spans of alphanumeric characters.
If any character in str is non-latin, or latin and not found in the aforementioned subset (e.g. 'ß', 'å', or 'ö'), a hash of str is appended to the final string.
{Implementation note}
Previously, an optimized implementation was used that was equivalent to this code for the basic translation to an ASCII-printable representation:
Although it was measured to be approximately four times faster than this simple sequence of transformations, it could not distinguish between hyphens that were intentionally part of the input string and those that were generated by the implementation.
Definition at line 100 of file textutils.cpp.
Returns the inter-item punctuation for a list of numberOfWords words at wordPosition.
For a list of length one, returns an empty QString. For a list of length two, returns " and ". For longer lists, returns ", " for early items and ", and " for the item before the last. The last position returns an empty QString; its punctuation is the period returned by separator().
Definition at line 51 of file textutils.cpp.
HTML-escapes the ampersand, less-than, greater-than, and double-quote characters in str, leaving other characters untouched.
Definition at line 163 of file textutils.cpp.
Returns the punctuation character for the word at wordPosition in a list of numberOfWords length. For the last position, returns "." (full stop). For any other word, delegates to comma().
Definition at line 30 of file textutils.cpp.
|
staticconstexpr |
Definition at line 37 of file textutils.h.
|
staticconstexpr |
Definition at line 39 of file textutils.h.
|
staticconstexpr |
Definition at line 38 of file textutils.h.
|
staticconstexpr |
Definition at line 40 of file textutils.h.