Sophie

Sophie

distrib > Mandriva > 2009.0 > i586 > by-pkgid > 43ed067ef12dc23f248aedf5d56e3391 > files > 4

libdbmusic-devel-0.8.4-1mdv2008.0.i586.rpm

/***************************************************************************
                      dbmusicvalidator.h  -  description
                           -------------------
                  begin                : Wed Dec 19 2001
                  copyright            : (C) 2001 by Will DeRousse
                  email                : badhack@users.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef DBMUSICVALIDATOR_H
#define DBMUSICVALIDATOR_H

#include "dbmusicglobals.h"
#include <iostream>

/**
 * These functions are for parsing a QString for illegal/bad/dangerous/whatever characters
 * and returning something clean or suitable.
 * @short Validating QStrings
 * @author Will DeRousse <badhack@users.sourceforge.net>
 */


/**
 * Tracks parentheses in a string and returns TRUE if open, FALSE otherwise.
 * @param QString String
 */
bool openQuote(const QString &s);
/**
 * Returns the connect information string used by PostgreSQL.
 *
 * @param QString Host
 * @param QString Port
 * @param QString Dbname
 * @param QString User
 * @param QString Password
 */
QString returnConnectInfo(const QString &, const QString &, const QString &, const QString &, const QString &);
/**
 * Parses a QString for characters that a bash interface does not like (or could post a security problem)
 * and replaces them with '_'.
 * @param QString Name Of File
 */
QString validateFilename(const QString &);
/**
 * Makes sure the QString is in an acceptable type interval format.
 * @param QString String To Verify
 */
QString validateInterval(QString &);

/**
 * Makes sure the QString is in an acceptable type interval format. Const version.
 * @param QString String To Verify
 */
QString validateInterval(const QString &);
/**
 * Parses a QString for non-digit characters and converts them to a 1.
 * Returns a valid integer.
 *
 * Good for int submissions to a postgreSQL server.
 * @param QString String containing int value
 */
QString validateNumQString(QString &);
/**
 * Parses a QString for non-digit characters and converts them to a 1.
 * Returns a valid integer.
 *
 * Good for int submissions to a PostgreSQL server.
 * @param QString String containing int value
 */
QString validateNumQString(const QString &);

/**
 * Parses a QString for ' characters and escapes ('') them.
 *
 * This will prevent postgreSQL from generating errors with ' in the name.
 * For example "INSERT INTO table (name) VALUES ('Apostrophe's')" would generate an error while
 * "INSERT INTO table (name) VALUES ('Apostrohpe''s')" would not.
 * @param QString String containing text value
 */
QString validateQString(QString &);

/**
 * Parses a QString for ' characters and escapes ('') them.
 *
 * This will prevent postgreSQL from generating errors with ' in the name.
 * For example "INSERT INTO table (name) VALUES ('Apostrophe's')" would generate an error while
 * "INSERT INTO table (name) VALUES ('Apostrohpe''s')" would not.
 * @param QString String containing text value
 */
QString validateQString(const QString &);


#endif