Source: Config.h


Annotated List
Files
Globals
Hierarchy
Index
/***************************************************************************
 *
 * File:    Config.h
 * Created: Thu Jan 6 2000
 * (C) 2000 by David M. <captjay@superlink.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 CONFIG_H
#define CONFIG_H

#include <qobject.h>
#include <qstring.h>

#include "CustomException.h"

/**
* @short Handle the bot's configuration file and options.
*
* The Config class is used to parse the configuration file and keep track
* of the various options (dbase connection information, command levels, etc).
*
*/
class Config : public QObject  {
public: 
	~Config();
	
	/**
	* Get a pointer to the single instance of the Config class.
	*/
  static Config* instance();
	
	/**
	* Load configuration information from filename.
	* Throws a EConfigError if the file could not be open.
	*
	* @param filename The name of the config file to use.
	*/
	void readConfig(const QString& filename);
	/**
	* Get the value of the nick field in the config file.
	* @return The value of the nick field.
	*/
	const QString& getNick() const;
	/**
	* Get the value of the username field in the config file.
	* @return The value of the username field.
	*/
	const QString& getUserName() const;
	/**
	* Get the value of the realname field in the config file.
	* @return The value of the realname field.
	*/
	const QString& getRealName() const;
	/**
	* Get the value of the usermode field in the config file.
	* @return The value of the usermode field.
	*/
	const QString& getUserMode() const;
	/**
	* Get the value of the dbasehost field in the config file.
	* @return The value of the dbasehost field.
	*/
	const QString& getDbaseHost() const;
	/**
	* Get the value of the dbaseuser field in the config file.
	* @return The value of the dbaseuser field.
	*/
	const QString& getDbaseUser() const;
	/**
	* Get the value of the dbasepass field in the config file.
	* @return The value of the dbasepass field.
	*/
	const QString& getDbasePass() const;
	/**
	* Get the value of the dbasename field in the config file.
	* @return The value of the dbasename field.
	*/
	const QString& getDbaseName() const;
	/**
	* Get the value of the language field in the config file.
	* @return The value of the language field.
	*/
	const QString& getLanguage() const;
	
	/**
	* Determine wether the config file turned debug mode on.
	* @return true if debug mode is activated, false otherwise.
	*/
	bool debugOn() const;
protected:
	Config();
  static Config* _instance;
private:
	bool setOption(const QString& optionName,const QString& optionValue);
  QString _nick;
  QString _userName;
  QString _realName;
  QString _userMode;
  QString _dbaseHost;
  QString _dbaseUser;
  QString _dbasePass;
  QString _dbaseName;
  QString _lang;
  bool    _debug;
};

class EConfigError: public CustomException {
Q_OBJECT
public:
  EConfigError(QString message);
};


#endif

Generated by: nightsky@centauri on Sat Jan 15 23:06:10 2000, using kdoc 2.0a30.