My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes | List of all members
ConfigImpl Class Reference

#include <configimpl.h>

Public Member Functions

QListIterator< ConfigOptioniterator ()
 
void writeTemplate (FTextStream &t, bool shortIndex, bool updateOnly)
 
void setHeader (const char *header)
 
void convertStrToVal ()
 
void substituteEnvironmentVars ()
 
void init ()
 
bool parseString (const char *fn, const char *str, bool upd=FALSE)
 
bool parse (const char *fn, bool upd=FALSE)
 
void create ()
 
void appendStartComment (const QCString &u)
 
void appendUserComment (const QCString &u)
 
QCString takeStartComment ()
 
QCString takeUserComment ()
 
Getting configuration values.
QCString & getString (const char *fileName, int num, const char *name) const
 
QStrList & getList (const char *fileName, int num, const char *name) const
 
QCString & getEnum (const char *fileName, int num, const char *name) const
 
int & getInt (const char *fileName, int num, const char *name) const
 
bool & getBool (const char *fileName, int num, const char *name) const
 
ConfigOptionget (const char *name) const
 
Adding configuration options.
ConfigInfoaddInfo (const char *name, const char *doc)
 
ConfigStringaddString (const char *name, const char *doc)
 
ConfigEnumaddEnum (const char *name, const char *doc, const char *defVal)
 
ConfigListaddList (const char *name, const char *doc)
 
ConfigIntaddInt (const char *name, const char *doc, int minVal, int maxVal, int defVal)
 
ConfigBooladdBool (const char *name, const char *doc, bool defVal)
 
ConfigOptionaddObsolete (const char *name)
 
ConfigOptionaddDisabled (const char *name)
 

Static Public Member Functions

static ConfigImplinstance ()
 
static void deleteInstance ()
 

Protected Member Functions

 ConfigImpl ()
 
 ~ConfigImpl ()
 

Private Attributes

QList< ConfigOption > * m_options
 
QList< ConfigOption > * m_obsolete
 
QList< ConfigOption > * m_disabled
 
QDict< ConfigOption > * m_dict
 
QCString m_startComment
 
QCString m_userComment
 
bool m_initialized
 
QCString m_header
 

Static Private Attributes

static ConfigImplm_instance
 

Detailed Description

Singleton for configuration variables.

This object holds the global static variables read from a user-supplied configuration file. The static member instance() can be used to get a pointer to the one and only instance.

Set all variables to their default values by calling Config::instance()->init()

Definition at line 292 of file configimpl.h.

Constructor & Destructor Documentation

ConfigImpl::ConfigImpl ( )
inlineprotected

Definition at line 539 of file configimpl.h.

References create(), m_dict, m_disabled, m_initialized, m_obsolete, and m_options.

Referenced by instance().

{
m_options = new QList<ConfigOption>;
m_obsolete = new QList<ConfigOption>;
m_disabled = new QList<ConfigOption>;
m_dict = new QDict<ConfigOption>(257);
m_options->setAutoDelete(TRUE);
m_obsolete->setAutoDelete(TRUE);
m_disabled->setAutoDelete(TRUE);
m_initialized = FALSE;
create();
}
ConfigImpl::~ConfigImpl ( )
inlineprotected

Definition at line 551 of file configimpl.h.

References m_dict, m_disabled, m_obsolete, and m_options.

{
delete m_options;
delete m_obsolete;
delete m_disabled;
delete m_dict;
}

Member Function Documentation

ConfigBool* ConfigImpl::addBool ( const char *  name,
const char *  doc,
bool  defVal 
)
inline

Adds a new boolean option with name and documentation doc. The boolean has a default value of defVal.

Returns
An object representing the option.

Definition at line 436 of file configimpl.h.

References m_dict, and m_options.

{
ConfigBool *result = new ConfigBool(name,doc,defVal);
m_options->append(result);
m_dict->insert(name,result);
return result;
}
ConfigOption* ConfigImpl::addDisabled ( const char *  name)
inline

Adds an option that has been disabled at compile time.

Definition at line 454 of file configimpl.h.

References m_dict, and m_disabled.

{
ConfigDisabled *option = new ConfigDisabled(name);
m_dict->insert(name,option);
m_disabled->append(option);
return option;
}
ConfigEnum* ConfigImpl::addEnum ( const char *  name,
const char *  doc,
const char *  defVal 
)
inline

Adds a new enumeration option with name and documentation doc and initial value defVal.

Returns
An object representing the option.

Definition at line 395 of file configimpl.h.

References m_dict, and m_options.

{
ConfigEnum *result = new ConfigEnum(name,doc,defVal);
m_options->append(result);
m_dict->insert(name,result);
return result;
}
ConfigInfo* ConfigImpl::addInfo ( const char *  name,
const char *  doc 
)
inline

Starts a new configuration section with name and description doc.

Returns
An object representing the option.

Definition at line 372 of file configimpl.h.

References m_options.

{
ConfigInfo *result = new ConfigInfo(name,doc);
m_options->append(result);
return result;
}
ConfigInt* ConfigImpl::addInt ( const char *  name,
const char *  doc,
int  minVal,
int  maxVal,
int  defVal 
)
inline

Adds a new integer option with name and documentation doc. The integer has a range between minVal and maxVal and a default value of defVal.

Returns
An object representing the option.

Definition at line 422 of file configimpl.h.

References m_dict, and m_options.

{
ConfigInt *result = new ConfigInt(name,doc,minVal,maxVal,defVal);
m_options->append(result);
m_dict->insert(name,result);
return result;
}
ConfigList* ConfigImpl::addList ( const char *  name,
const char *  doc 
)
inline

Adds a new string option with name and documentation doc.

Returns
An object representing the option.

Definition at line 408 of file configimpl.h.

References m_dict, and m_options.

{
ConfigList *result = new ConfigList(name,doc);
m_options->append(result);
m_dict->insert(name,result);
return result;
}
ConfigOption* ConfigImpl::addObsolete ( const char *  name)
inline

Adds an option that has become obsolete.

Definition at line 446 of file configimpl.h.

References m_dict, and m_obsolete.

{
ConfigObsolete *option = new ConfigObsolete(name);
m_dict->insert(name,option);
m_obsolete->append(option);
return option;
}
ConfigString* ConfigImpl::addString ( const char *  name,
const char *  doc 
)
inline

Adds a new string option with name and documentation doc.

Returns
An object representing the option.

Definition at line 382 of file configimpl.h.

References m_dict, and m_options.

{
ConfigString *result = new ConfigString(name,doc);
m_options->append(result);
m_dict->insert(name,result);
return result;
}
void ConfigImpl::appendStartComment ( const QCString &  u)
inline

Append user start comment

Definition at line 508 of file configimpl.h.

References m_startComment.

{
}
void ConfigImpl::appendUserComment ( const QCString &  u)
inline

Append user comment

Definition at line 514 of file configimpl.h.

References m_userComment.

{
}
void ConfigImpl::convertStrToVal ( )

Converts the string values read from the configuration file to real values for non-string type options (like int, and bools)

void ConfigImpl::create ( )

Called from the constructor, will add doxygen's default options to the configuration object

Referenced by ConfigImpl().

static void ConfigImpl::deleteInstance ( )
inlinestatic

Delete the instance

Definition at line 306 of file configimpl.h.

References m_instance.

{
delete m_instance;
}
ConfigOption* ConfigImpl::get ( const char *  name) const
inline

Returns the ConfigOption corresponding with name or 0 if the option is not supported.

Definition at line 358 of file configimpl.h.

References m_dict.

{
return m_dict->find(name);
}
bool& ConfigImpl::getBool ( const char *  fileName,
int  num,
const char *  name 
) const

Returns the value of the boolean option with name fileName. The arguments num and name are for debugging purposes only. There is a convenience function Config_getBool() for this.

QCString& ConfigImpl::getEnum ( const char *  fileName,
int  num,
const char *  name 
) const

Returns the value of the enum option with name fileName. The arguments num and name are for debugging purposes only. There is a convenience function Config_getEnum() for this.

int& ConfigImpl::getInt ( const char *  fileName,
int  num,
const char *  name 
) const

Returns the value of the integer option with name fileName. The arguments num and name are for debugging purposes only. There is a convenience function Config_getInt() for this.

QStrList& ConfigImpl::getList ( const char *  fileName,
int  num,
const char *  name 
) const

Returns the value of the list option with name fileName. The arguments num and name are for debugging purposes only. There is a convenience function Config_getList() for this.

QCString& ConfigImpl::getString ( const char *  fileName,
int  num,
const char *  name 
) const

Returns the value of the string option with name fileName. The arguments num and name are for debugging purposes only. There is a convenience function Config_getString() for this.

void ConfigImpl::init ( )

Initialize config variables to their default value

static ConfigImpl* ConfigImpl::instance ( )
inlinestatic

Returns the one and only instance of this class

Definition at line 300 of file configimpl.h.

References ConfigImpl(), and m_instance.

{
return m_instance;
}
QListIterator<ConfigOption> ConfigImpl::iterator ( )
inline

Returns an iterator that can by used to iterate over the configuration options.

Definition at line 315 of file configimpl.h.

{
return QListIterator<ConfigOption>(*m_options);
}
bool ConfigImpl::parse ( const char *  fn,
bool  upd = FALSE 
)

Parse a configuration file with name fn.

Returns
TRUE if successful, FALSE if the file could not be opened or read.
bool ConfigImpl::parseString ( const char *  fn,
const char *  str,
bool  upd = FALSE 
)

Parse a configuration data in string str.

Returns
TRUE if successful, or FALSE if the string could not be parsed.
void ConfigImpl::setHeader ( const char *  header)
inline

Definition at line 469 of file configimpl.h.

References m_header.

{ m_header = header; }
void ConfigImpl::substituteEnvironmentVars ( )

Replaces references to environment variable by the actual value of the environment variable.

QCString ConfigImpl::takeStartComment ( )
inline

Take the user start comment and reset it internally

Returns
user start comment

Definition at line 521 of file configimpl.h.

References m_startComment.

{
QCString result=m_startComment;
m_startComment.resize(0);
return result.replace(QRegExp("\r"),"");
}
QCString ConfigImpl::takeUserComment ( )
inline

Take the user comment and reset it internally

Returns
user comment

Definition at line 530 of file configimpl.h.

References m_userComment.

{
QCString result=m_userComment;
m_userComment.resize(0);
return result.replace(QRegExp("\r"),"");
}
void ConfigImpl::writeTemplate ( FTextStream t,
bool  shortIndex,
bool  updateOnly 
)

Writes a template configuration to stream t. If shortIndex is TRUE the description of each configuration option will be omitted.

Member Data Documentation

QDict<ConfigOption>* ConfigImpl::m_dict
private
QList<ConfigOption>* ConfigImpl::m_disabled
private

Definition at line 562 of file configimpl.h.

Referenced by addDisabled(), ConfigImpl(), and ~ConfigImpl().

QCString ConfigImpl::m_header
private

Definition at line 568 of file configimpl.h.

Referenced by setHeader().

bool ConfigImpl::m_initialized
private

Definition at line 567 of file configimpl.h.

Referenced by ConfigImpl().

ConfigImpl* ConfigImpl::m_instance
staticprivate

Definition at line 564 of file configimpl.h.

Referenced by deleteInstance(), and instance().

QList<ConfigOption>* ConfigImpl::m_obsolete
private

Definition at line 561 of file configimpl.h.

Referenced by addObsolete(), ConfigImpl(), and ~ConfigImpl().

QList<ConfigOption>* ConfigImpl::m_options
private

Definition at line 560 of file configimpl.h.

Referenced by addBool(), addEnum(), addInfo(), addInt(), addList(), addString(), ConfigImpl(), and ~ConfigImpl().

QCString ConfigImpl::m_startComment
private

Definition at line 565 of file configimpl.h.

Referenced by appendStartComment(), and takeStartComment().

QCString ConfigImpl::m_userComment
private

Definition at line 566 of file configimpl.h.

Referenced by appendUserComment(), and takeUserComment().


The documentation for this class was generated from the following file: