00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file string.h 00024 * \version $Id: string.h 1256 2006-10-01 23:40:24Z edmanm $ 00025 * \brief Common string manipulation functions 00026 */ 00027 00028 #ifndef __STRING_H 00029 #define __STRING_H 00030 00031 #include <QStringList> 00032 00033 /** Creates a QStringList from the array of C strings. */ 00034 QStringList char_array_to_stringlist(char **arr, int len); 00035 00036 /** Ensures all characters in str are in validChars. If a character appears 00037 * in str but not in validChars, it will be removed and the resulting 00038 * string returned. */ 00039 QString ensure_valid_chars(QString str, QString validChars); 00040 00041 /** Scrubs an email address by replacing "@" with " at " and "." with " dot ". */ 00042 QString scrub_email_addr(QString email); 00043 00044 /** Conditionally assigns errmsg to string if str is not null and returns 00045 * false. */ 00046 bool err(QString *str, QString errmsg); 00047 00048 /** Wraps <b>str</b> at <b>width</b> characters wide, using <b>sep</b> as the 00049 * word separator (" ", for example), and placing the line ending <b>le</b> at 00050 * the end of each line, except the last.*/ 00051 QString string_wrap(QString str, int width, QString sep, QString le); 00052 00053 #endif 00054