diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2020-06-02 09:13:43 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2020-06-04 20:06:08 (GMT) |
commit | 0df1623c9363d52a2b04457233dcf2c64319b03c (patch) | |
tree | 7716f420ced7c05cfa50d3e12d91d02624361cff /src/configimpl.h | |
parent | fd1111503cd3e403db3784d03530e6ec3ac37032 (diff) | |
download | Doxygen-0df1623c9363d52a2b04457233dcf2c64319b03c.zip Doxygen-0df1623c9363d52a2b04457233dcf2c64319b03c.tar.gz Doxygen-0df1623c9363d52a2b04457233dcf2c64319b03c.tar.bz2 |
Refactor: modernize configuration values
Diffstat (limited to 'src/configimpl.h')
-rw-r--r-- | src/configimpl.h | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/src/configimpl.h b/src/configimpl.h index 6134088..a267cc6 100644 --- a/src/configimpl.h +++ b/src/configimpl.h @@ -1,13 +1,13 @@ /****************************************************************************** * - * + * * * * Copyright (C) 1997-2015 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -24,6 +24,7 @@ #include <qlist.h> #include <qregexp.h> #include "ftextstream.h" +#include "containers.h" /** Abstract base class for any configuration option. @@ -35,8 +36,8 @@ class ConfigOption public: /*! The type of option */ - enum OptionType - { + enum OptionType + { O_Info, //!< A section header O_List, //!< A list of items O_Enum, //!< A fixed set of items @@ -46,14 +47,14 @@ class ConfigOption O_Obsolete, //!< An obsolete option O_Disabled //!< Disabled compile time option }; - enum - { - /*! Maximum length of an option in the config file. Used for + enum + { + /*! Maximum length of an option in the config file. Used for * alignment purposes. */ - MAX_OPTION_LENGTH = 23 + MAX_OPTION_LENGTH = 23 }; - ConfigOption(OptionType t) : m_kind(t) + ConfigOption(OptionType t) : m_kind(t) { m_spaces.fill(' ',40); } @@ -81,8 +82,8 @@ class ConfigOption void writeBoolValue(FTextStream &t,bool v); void writeIntValue(FTextStream &t,int i); - void writeStringValue(FTextStream &t,QCString &s); - void writeStringList(FTextStream &t,QStrList &l); + void writeStringValue(FTextStream &t,const QCString &s); + void writeStringList(FTextStream &t,const StringVector &l); QCString m_spaces; QCString m_name; @@ -98,7 +99,7 @@ class ConfigOption class ConfigInfo : public ConfigOption { public: - ConfigInfo(const char *name,const char *doc) + ConfigInfo(const char *name,const char *doc) : ConfigOption(O_Info) { m_name = name; @@ -115,25 +116,25 @@ class ConfigList : public ConfigOption { public: enum WidgetType { String, File, Dir, FileAndDir }; - ConfigList(const char *name,const char *doc) + ConfigList(const char *name,const char *doc) : ConfigOption(O_List) { m_name = name; m_doc = doc; m_widgetType = String; } - void addValue(const char *v) { m_defaultValue.append(v); } + void addValue(const char *v) { m_defaultValue.push_back(v); } void setWidgetType(WidgetType w) { m_widgetType = w; } WidgetType widgetType() const { return m_widgetType; } - QStrList *valueRef() { return &m_value; } - QStrList getDefault() { return m_defaultValue; } + StringVector *valueRef() { return &m_value; } + StringVector getDefault() { return m_defaultValue; } void writeTemplate(FTextStream &t,bool sl,bool); void compareDoxyfile(FTextStream &t); void substEnvVars(); void init() { m_value = m_defaultValue; } private: - QStrList m_value; - QStrList m_defaultValue; + StringVector m_value; + StringVector m_defaultValue; WidgetType m_widgetType; }; @@ -142,7 +143,7 @@ class ConfigList : public ConfigOption class ConfigEnum : public ConfigOption { public: - ConfigEnum(const char *name,const char *doc,const char *defVal) + ConfigEnum(const char *name,const char *doc,const char *defVal) : ConfigOption(O_Enum) { m_name = name; @@ -151,7 +152,7 @@ class ConfigEnum : public ConfigOption m_defValue = defVal; } void addValue(const char *v) { m_valueRange.append(v); } - QStrListIterator iterator() + QStrListIterator iterator() { return QStrListIterator(m_valueRange); } @@ -174,7 +175,7 @@ class ConfigString : public ConfigOption { public: enum WidgetType { String, File, Dir, Image }; - ConfigString(const char *name,const char *doc) + ConfigString(const char *name,const char *doc) : ConfigOption(O_String) { m_name = name; @@ -193,7 +194,7 @@ class ConfigString : public ConfigOption void substEnvVars(); void init() { m_value = m_defValue.copy(); } void emptyValueToDefault() { if(m_value.isEmpty()) m_value=m_defValue; }; - + private: QCString m_value; QCString m_defValue; @@ -205,7 +206,7 @@ class ConfigString : public ConfigOption class ConfigInt : public ConfigOption { public: - ConfigInt(const char *name,const char *doc,int minVal,int maxVal,int defVal) + ConfigInt(const char *name,const char *doc,int minVal,int maxVal,int defVal) : ConfigOption(O_Int) { m_name = name; @@ -237,7 +238,7 @@ class ConfigInt : public ConfigOption class ConfigBool : public ConfigOption { public: - ConfigBool(const char *name,const char *doc,bool defVal) + ConfigBool(const char *name,const char *doc,bool defVal) : ConfigOption(O_Bool) { m_name = name; @@ -264,7 +265,7 @@ class ConfigBool : public ConfigOption class ConfigObsolete : public ConfigOption { public: - ConfigObsolete(const char *name) : ConfigOption(O_Obsolete) + ConfigObsolete(const char *name) : ConfigOption(O_Obsolete) { m_name = name; } void writeTemplate(FTextStream &,bool,bool); void compareDoxyfile(FTextStream &) {} @@ -276,7 +277,7 @@ class ConfigObsolete : public ConfigOption class ConfigDisabled : public ConfigOption { public: - ConfigDisabled(const char *name) : ConfigOption(O_Disabled) + ConfigDisabled(const char *name) : ConfigOption(O_Disabled) { m_name = name; } void writeTemplate(FTextStream &,bool,bool); void compareDoxyfile(FTextStream &) {} @@ -297,7 +298,7 @@ class ConfigDisabled : public ConfigOption * 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() * @@ -321,8 +322,8 @@ class ConfigImpl delete m_instance; m_instance=0; } - - /*! Returns an iterator that can by used to iterate over the + + /*! Returns an iterator that can by used to iterate over the * configuration options. */ QListIterator<ConfigOption> iterator() @@ -330,36 +331,36 @@ class ConfigImpl return QListIterator<ConfigOption>(*m_options); } - /*! + /*! * @name Getting configuration values. * @{ */ - /*! Returns the value of the string option with name \a fileName. + /*! Returns the value of the string option with name \a fileName. * The arguments \a num and \a name are for debugging purposes only. * There is a convenience function Config_getString() for this. */ QCString &getString(const char *fileName,int num,const char *name) const; - /*! Returns the value of the list option with name \a fileName. + /*! Returns the value of the list option with name \a fileName. * The arguments \a num and \a name are for debugging purposes only. * There is a convenience function Config_getList() for this. */ - QStrList &getList(const char *fileName,int num,const char *name) const; + StringVector &getList(const char *fileName,int num,const char *name) const; - /*! Returns the value of the enum option with name \a fileName. + /*! Returns the value of the enum option with name \a fileName. * The arguments \a num and \a name are for debugging purposes only. * There is a convenience function Config_getEnum() for this. */ QCString &getEnum(const char *fileName,int num,const char *name) const; - /*! Returns the value of the integer option with name \a fileName. + /*! Returns the value of the integer option with name \a fileName. * The arguments \a num and \a name are for debugging purposes only. * There is a convenience function Config_getInt() for this. */ int &getInt(const char *fileName,int num,const char *name) const; - /*! Returns the value of the boolean option with name \a fileName. + /*! Returns the value of the boolean option with name \a fileName. * The arguments \a num and \a name are for debugging purposes only. * There is a convenience function Config_getBool() for this. */ @@ -370,12 +371,12 @@ class ConfigImpl */ ConfigOption *get(const char *name) const { - return m_dict->find(name); + return m_dict->find(name); } /* @} */ - /*! - * @name Adding configuration options. + /*! + * @name Adding configuration options. * @{ */ @@ -402,7 +403,7 @@ class ConfigImpl } /*! Adds a new enumeration option with \a name and documentation \a doc - * and initial value \a defVal. + * and initial value \a defVal. * \returns An object representing the option. */ ConfigEnum *addEnum(const char *name, @@ -510,18 +511,18 @@ class ConfigImpl /*! Parse a configuration data in string \a str. * \returns TRUE if successful, or FALSE if the string could not be * parsed. - */ + */ //bool parseString(const char *fn,const char *str); bool parseString(const char *fn,const char *str,bool upd = FALSE); /*! Parse a configuration file with name \a fn. - * \returns TRUE if successful, FALSE if the file could not be + * \returns TRUE if successful, FALSE if the file could not be * opened or read. - */ + */ bool parse(const char *fn,bool upd = FALSE); /*! Called from the constructor, will add doxygen's default options - * to the configuration object + * to the configuration object */ void create(); |