string.cpp File Reference

Common string manipulation functions. More...

#include "string.h"

Go to the source code of this file.

Functions

QStringList char_array_to_stringlist (char **arr, int len)
bool err (QString *str, QString errmsg)
QString ensure_valid_chars (QString str, QString validChars)
QString scrub_email_addr (QString email)
QString string_wrap (QString str, int width, QString sep, QString le)
QString base16_encode (const QByteArray buf)
QString string_escape (const QString str)
QString string_unescape (const QString str, bool *ok)
QHash< QString, QString > string_parse_keyvals (const QString str, bool *ok)


Detailed Description

Common string manipulation functions.

Version:
Id

Definition in file string.cpp.


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 123 of file string.cpp.

Referenced by TorControl::authenticate().

QStringList char_array_to_stringlist ( char **  arr,
int  len 
)

Create a QStringList from the array of C-style strings.

Definition at line 33 of file string.cpp.

Referenced by main().

QString ensure_valid_chars ( QString  str,
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 58 of file string.cpp.

Referenced by ServerSettings::getNickname(), and NicknameValidator::validate().

bool err ( QString *  str,
QString  errmsg 
)

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 46 of file string.cpp.

Referenced by TorControl::authenticate(), ZlibByteArray::compress(), ControlSocket::connect(), ControlSocket::disconnect(), 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 ( QString  email  ) 

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

Definition at line 72 of file string.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 136 of file string.cpp.

Referenced by TorControl::authenticate(), and TorProcess::formatArguments().

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 177 of file string.cpp.

Referenced by 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 152 of file string.cpp.

Referenced by string_parse_keyvals().

QString string_wrap ( QString  str,
int  width,
QString  sep,
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 84 of file string.cpp.

Referenced by LogTreeItem::setMessage().


Generated on Wed Sep 5 15:49:28 2007 for Vidalia by  doxygen 1.5.3