stringutil.h File Reference

#include <QStringList>
#include <QHash>

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, const QString &le)
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)


Function Documentation

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 113 of file stringutil.cpp.

References i().

Referenced by TorControl::authenticate(), 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 22 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 47 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 35 of file stringutil.cpp.

Referenced by TorControl::authenticate(), Circuit::Circuit(), ZlibByteArray::compress(), UPNPControlThread::configurePorts(), GeoIpCache::loadFromDisk(), LogFile::open(), ControlSocket::readLine(), ControlSocket::readLineData(), ControlSocket::readReply(), GeoIpCache::saveToDisk(), ControlConnection::send(), ControlSocket::sendCommand(), touch_file(), ZlibByteArray::uncompress(), and write_pidfile().

QString scrub_email_addr ( const QString &  email  ) 

Scrubs an email address by replacing "@" with " at " and "." with " dot ".

Definition at line 61 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 '\'.

Definition at line 126 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.

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 283 of file stringutil.cpp.

References string_escape().

Referenced by GeneralPage::load().

bool string_is_hex ( const QString &  str  ) 

Returns true if str is a valid hexademical string. Returns false otherwise.

Definition at line 298 of file stringutil.cpp.

References i().

Referenced by NetworkPage::validateBridge().

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 228 of file stringutil.cpp.

References tc::error(), i(), and string_unescape().

Referenced by GeneralPage::save().

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 167 of file stringutil.cpp.

References tc::error(), i(), and string_unescape().

Referenced by TorControl::bootstrapStatus(), TorEvents::handleStatusEvent(), and TorControl::protocolInfo().

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.

Definition at line 142 of file stringutil.cpp.

References i().

Referenced by 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.

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 73 of file stringutil.cpp.

Referenced by LogTreeItem::setMessage().


Generated on Wed Nov 26 21:02:42 2008 for Vidalia by  doxygen 1.5.7.1