Vidalia 0.3.1
|
#include <QStringList>
#include <QHash>
#include <QDateTime>
Go to the source code of this file.
Functions | |
QStringList | char_array_to_stringlist (char **arr, int len) |
QString | ensure_valid_chars (const QString &str, const QString &validChars) |
QString | scrub_email_addr (const QString &email) |
bool | err (QString *str, const QString &errmsg) |
QString | string_wrap (const QString &str, int width, const QString &sep=QString(" "), const QString &le=QString("\n")) |
QString | base16_encode (const QByteArray &buf) |
QString | string_escape (const QString &str) |
QString | string_unescape (const QString &str, bool *ok=0) |
QHash< QString, QString > | string_parse_keyvals (const QString &str, bool *ok=0) |
QStringList | string_parse_arguments (const QString &str, bool *ok=0) |
QString | string_format_arguments (const QStringList &args) |
bool | string_is_hex (const QString &str) |
QString | string_format_uptime (quint64 seconds) |
QString | string_format_datetime (const QDateTime &date) |
QString | string_format_bandwidth (quint64 bytes) |
QString base16_encode | ( | const QByteArray & | buf | ) |
Encodes the bytes in buf as an uppercase hexadecimal string and returns the result. This function is derived from base16_encode() in Tor's util.c. See LICENSE for details on Tor's license.
Definition at line 115 of file stringutil.cpp.
References i().
Referenced by TorControl::authenticate(), TorSettings::hashPassword(), and RouterStatus::RouterStatus().
QStringList char_array_to_stringlist | ( | char ** | arr, |
int | len | ||
) |
Creates a QStringList from the array of C strings.
Create a QStringList from the array of C-style strings.
Definition at line 24 of file stringutil.cpp.
References i().
Referenced by main().
QString ensure_valid_chars | ( | const QString & | str, |
const QString & | validChars | ||
) |
Ensures all characters in str are in validChars. If a character appears in str but not in validChars, it will be removed and the resulting string returned.
Definition at line 49 of file stringutil.cpp.
References i().
Referenced by ServerSettings::getNickname(), and NicknameValidator::validate().
bool err | ( | QString * | str, |
const QString & | errmsg | ||
) |
Conditionally assigns errmsg to string if str is not null and returns false.
Conditionally assigns errmsg to str if str is not null and returns false. This is a seemingly pointless function, but it saves some messiness in methods whose QString *errmsg parameter is optional.
Definition at line 37 of file stringutil.cpp.
Referenced by TorControl::authenticate(), Circuit::Circuit(), ZlibByteArray::compress(), UPNPControlThread::configurePorts(), MainWindow::connected(), ServerPage::displayBridgeUsage(), main(), LogFile::open(), UpdateProcess::packageInfoFromXml(), ControlSocket::readLine(), ControlSocket::readLineData(), ControlSocket::readReply(), Vidalia::retranslateUi(), TorControl::saveConf(), ControlConnection::send(), ControlSocket::sendCommand(), string_unescape(), touch_file(), ZlibByteArray::uncompress(), and write_pidfile().
QString scrub_email_addr | ( | const QString & | ) |
Scrubs an email address by replacing "@" with " at " and "." with " dot ".
Definition at line 63 of file stringutil.cpp.
Referenced by ServerSettings::confValues().
QString string_escape | ( | const QString & | str | ) |
Given a string str, this function returns a quoted string with all '"' and '\' characters escaped with a single '\'.
Given an ASCII string str, this function returns a quoted string with all escaped characters unescaped. Non-ASCII characters in the string will be converted to the local 8-bit character encoding and encoded using an escaped octal sequence. The returned string will thus contain only printable ASCII characters.
Definition at line 131 of file stringutil.cpp.
References i().
Referenced by TorControl::authenticate(), TorProcess::formatArguments(), TorControl::setConf(), ServicePage::startServicesInTor(), and string_format_arguments().
QString string_format_arguments | ( | const QStringList & | args | ) |
Formats the list of command line arguments in args as a string. Arguments that contain ' ', '\', or '"' tokens will be escaped and wrapped in double quotes.
Definition at line 360 of file stringutil.cpp.
References string_escape().
Referenced by CrashReporter::set_restart_options(), and HelperProcess::start().
QString string_format_bandwidth | ( | quint64 | bytes | ) |
Returns a string representation of bytes with the appropriate (localized) suffix of either "B/s", "KB/s", "MB/s" or "GB/s".
Returns a string representation of bytes with the appropriate suffix of either "B/s", "KB/s", "MB/s" or "GB/s".
Definition at line 419 of file stringutil.cpp.
Referenced by RouterDescriptorView::display(), and RouterInfoDialog::setRouterInfo().
QString string_format_datetime | ( | const QDateTime & | date | ) |
Returns a string representation of date formatted according to "yyyy-MM-dd HH:mm:ss".
Definition at line 411 of file stringutil.cpp.
Referenced by RouterDescriptorView::display(), and RouterInfoDialog::setRouterInfo().
QString string_format_uptime | ( | quint64 | seconds | ) |
Returns a human-readable description of the time elapsed given by seconds, broken down into days, hours, minutes and seconds.
Definition at line 388 of file stringutil.cpp.
Referenced by RouterDescriptorView::display(), and RouterInfoDialog::setRouterInfo().
bool string_is_hex | ( | const QString & | str | ) |
Returns true if str is a valid hexademical string. Returns false otherwise.
Definition at line 375 of file stringutil.cpp.
References i().
QStringList string_parse_arguments | ( | const QString & | str, |
bool * | ok | ||
) |
Parses a series of command line arguments from str. If str was unable to be parsed, ok is set to false.
Definition at line 305 of file stringutil.cpp.
References tc::error(), i(), and string_unescape().
Referenced by CrashReportDialog::accept().
QHash< QString, QString > string_parse_keyvals | ( | const QString & | str, |
bool * | ok | ||
) |
Parses a series of space-separated key[=value|="value"] tokens from str and returns the mappings in a QHash. If str was unable to be parsed, ok is set to false.
Definition at line 244 of file stringutil.cpp.
References tc::error(), i(), and string_unescape().
Referenced by TorControl::bootstrapStatus(), ServerPage::displayBridgeUsage(), TorControl::getBootstrapPhase(), TorEvents::handleStatusEvent(), TorControl::protocolInfo(), and UpdateProcess::readStandardError().
QString string_unescape | ( | const QString & | str, |
bool * | ok | ||
) |
Given a quoted string str, this function returns an unquoted, unescaped string. str must start and end with an unescaped quote.
Given a quoted string str, this function returns an unquoted, unescaped string. str must start and end with an unescaped DQUOTE, The input string must contain only ASCII characters; however, non-ASCII characters can be included by encoding their byte sequences in either escaped hexadecimal (e.g., "\xFF") or octal (e.g., "\301"). The result will be converted to a QString using the local 8-bit encoding.
Definition at line 177 of file stringutil.cpp.
Referenced by TorControl::getConf(), TorControl::getInfo(), string_parse_arguments(), and string_parse_keyvals().
QString string_wrap | ( | const QString & | str, |
int | width, | ||
const QString & | sep, | ||
const QString & | le | ||
) |
Wraps str at width characters wide, using sep as the word separator (" ", for example), and placing the line ending le at the end of each line, except the last.
Definition at line 75 of file stringutil.cpp.
Referenced by StatusEventWidget::addNotification(), and LogTreeItem::setMessage().