Static Public Member Functions | |
static QString | colorizeString (const QString &str, int def=4) |
static QStringList | combineManyPaths (const QStringList &fronts, const QString &pathEnd) |
Combines path suffix with all fronts, returns new list. More... | |
static QString | combinePaths (QString pathFront, QString pathEnd) |
static QString | createRandomAlphaNumericString (unsigned numChars) |
Creates a random string with specified length. More... | |
static QString | createRandomAlphaNumericStringWithNewLines (unsigned numCharsPerLine, unsigned numLines) |
static const QString & | escape (QString &str) |
Adds escape characters to a string. More... | |
static QString | formatDataAmount (qint64 bytes) |
Similar to formatDataSpeed(). More... | |
static QString | formatDataSpeed (float speedInBytesPerSecond) |
Formats a numerical speed value into a string. More... | |
static QString | formatTime (float seconds) |
Formats a numerical time value into a string. More... | |
static bool | isCharOnCharList (char c, const QString &charList) |
static bool | isUrlSafe (const QString &url) |
Unsafe URLs begin with file:// and this functions returns false for such URLs. More... | |
static QString | normalizePath (QString path) |
Creates a clean path. More... | |
static QByteArray | readUntilByte (QDataStream &stream, unsigned char stopByte) |
Reads raw data from the current position of passed QDataStream until a specified byte is encountered. More... | |
static QString | timestamp (const QString &format) |
static void | translateServerAddress (const QString &addressString, QString &hostname, unsigned short &port, const QString &defaultAddress) |
Translates string in format "hostname:port" to atomic values. More... | |
static QString & | trim (QString &str, const QString &charList) |
static QString & | triml (QString &str, const QString &charList) |
static QString & | trimr (QString &str, const QString &charList) |
static const QString & | unescape (QString &str) |
static QString | wrapUrlsWithHtmlATags (const QString &str) |
Detects all links within a given string and wraps them in <a href> tags. More... | |
Protected Types | |
enum | DataUnit { Byte = 0, Kilobyte = 1, Megabyte = 2, Gigabyte = 3 } |
Static Protected Member Functions | |
static float | scaleDataUnit (float bytes, DataUnit &outUnit) |
Static Protected Attributes | |
static const char | RANDOM_CHAR_POOL [RANDOM_CHAR_POOL_SIZE] |
static const unsigned | RANDOM_CHAR_POOL_SIZE = 36 |
|
static |
Colorizes the given string. Most useful for displaying colored names.
Definition at line 48 of file strings.cpp.
|
static |
Combines path suffix with all fronts, returns new list.
This is done by calling combinePaths on all elements of 'fronts' with 'pathEnd' as the second argument.
Definition at line 135 of file strings.cpp.
|
static |
Combines two strings into single path making sure there are no redundant slahes/backslashes present. Paths will be combined using backslash ('\') on Windows systems and slash ('/') on non-Windows systems. Example:
pathFront | - base path |
pathEnd | - part of the path that will be appended |
Definition at line 145 of file strings.cpp.
|
static |
Creates a random string with specified length.
The created string consists of lowercase letters and digits.
Definition at line 169 of file strings.cpp.
|
static |
Adds escape characters to a string.
Definition at line 194 of file strings.cpp.
|
static |
Similar to formatDataSpeed().
The only difference is the unit type appended to the end of the returned string.
Definition at line 217 of file strings.cpp.
|
static |
Formats a numerical speed value into a string.
This expects the parameter to represent speed in bytes per second. Data will be formatted into human readable format, ie. if speed is high enough it will be translated into kilobytes per second or megabytes per second. Also a string representing the type of value is appended: MB/s, kB/s or B/s.
Definition at line 251 of file strings.cpp.
|
static |
Formats a numerical time value into a string.
Parameter is expected to be an amount of seconds. Output is transformed into a number of hours, minutes and seconds. The function will always try to generate the shortest possible string, ie. there will be no hour information if seconds parameter is smaller than 3600. The same goes for minutes. Factorial part in the parameter represents miliseconds and is always rounded up to a full second.
Definition at line 284 of file strings.cpp.
|
static |
Unsafe URLs begin with file:// and this functions returns false for such URLs.
Someone might prepare such URL to make Doomseeker activate files on user's local drive and possibly cause damage to the system.
Definition at line 343 of file strings.cpp.
|
static |
Creates a clean path.
Calls both QDir::fromNativeSeparators() and QDir::cleanPath(). The returned string will have only '/' separators, no '.' or '..' markers and no double separators.
Definition at line 357 of file strings.cpp.
|
static |
Reads raw data from the current position of passed QDataStream until a specified byte is encountered.
The primary use for this method is to read '\0' terminated strings.
The operator>>(char*&) in QDataStream expects the size of the string to be written first in a quint32 variable. Because this data not always exists, a custom method must be used. This is this method.
The read will occur from current position until the stopByte byte is encountered. Read may also stop when an end of stream is encountered in which case the data read up to this point will be returned.
stream | Stream to read from. |
stopByte | When method encounters this byte, then the read will stop and the currently read data is returned. |
Definition at line 365 of file strings.cpp.
|
static |
Translates string in format "hostname:port" to atomic values.
addressString | - string to be translated. | |
[out] | hostname | - hostname output. |
[out] | port | - port output. |
defaultHostname | - default hostname to use if translation fails. | |
defaultPort | - default port to use if translation fails or no port inside addressString is specified. |
Definition at line 404 of file strings.cpp.
|
static |
Detects all links within a given string and wraps them in <a href> tags.
Valid URLs are found by seeking continuous no-whitespace substrings starting either with http://, ftp:// or REGEX: www..*+
Furthermore, all URLs that begin with 'www.' will be forced to use the http:// scheme. Leaving them as they are causes problems with opening external URLs in QTextBrowser.
Definition at line 458 of file strings.cpp.
|
staticprotected |