1 /******************************************************************************
2  *
3  * Copyright (C) 1997-2015 by Dimitri van Heesch.
4  *
5  * Permission to use, copy, modify, and distribute this software and its
6  * documentation under the terms of the GNU General Public License is hereby
7  * granted. No representations are made about the suitability of this software
8  * for any purpose. It is provided "as is" without express or implied warranty.
9  * See the GNU General Public License for more details.
10  *
11  * Documents produced by Doxygen are derivative works derived from the
12  * input used in their production; they are not affected by this license.
13  *
14  */
15 
16 #ifndef CONFIG_H
17 #define CONFIG_H
18 
19 // note: this header file is generated from config.xml
20 #include "configvalues.h"
21 
22 //! @{
23 //! some convenience macros for accessing the config options
24 //! mainly done like this for backward compatibility
25 //#if DYNAMIC_LOOKUP // for debug purposes
26 //#define Config_getString(val) (ConfigValues::instance().*((ConfigValues::InfoString*)ConfigValues::instance().get(#val))->item)
27 //#define Config_getBool(val)   (ConfigValues::instance().*((ConfigValues::InfoBool*)ConfigValues::instance().get(#val))->item)
28 //#define Config_getInt(val)    (ConfigValues::instance().*((ConfigValues::InfoInt*)ConfigValues::instance().get(#val))->item)
29 //#define Config_getEnum(val)   (ConfigValues::instance().*((ConfigValues::InfoString*)ConfigValues::instance().get(#val))->item)
30 //#define Config_getList(val)   (ConfigValues::instance().*((ConfigValues::InfoList*)ConfigValues::instance().get(#val))->item)
31 //#else // direct access
32 #define Config_getString(name) (ConfigValues::instance().name())
33 #define Config_getBool(name)   (ConfigValues::instance().name())
34 #define Config_getInt(name)    (ConfigValues::instance().name())
35 #define Config_getEnum(name)   (ConfigValues::instance().name())
36 #define Config_getEnumAsString(name)   (ConfigValues::instance().name##_str())
37 #define Config_getList(name)   (ConfigValues::instance().name())
38 #define Config_updateString(name,value) (ConfigValues::instance().update_##name(value));
39 #define Config_updateBool(name,value)   (ConfigValues::instance().update_##name(value));
40 #define Config_updateInt(name,value)    (ConfigValues::instance().update_##name(value));
41 #define Config_updateEnum(name,value)   (ConfigValues::instance().update_##name(value));
42 #define Config_updateList(name,...)   (ConfigValues::instance().update_##name(__VA_ARGS__));
43 //#endif
44 //! @}
45 
46 class TextStream;
47 
48 /** \brief Public function to deal with the configuration file. */
49 namespace Config
50 {
51   /*! Initialize configuration variables to their default value */
52   void init();
53 
54   /*! Writes a template configuration to stream \a t. If \a shortList
55    *  is \c TRUE the description of each configuration option will
56    *  be omitted.
57    */
58   void writeTemplate(TextStream &t,bool shortList,bool updateOnly=FALSE);
59 
60   /*! Writes a the differences between the current configuration and the
61    *  template configuration to stream \a t.
62    */
63   void compareDoxyfile(TextStream &t);
64 
65   /*! Writes a the used settings of the current configuration as XML format
66    *  to stream \a t.
67    */
68   void writeXMLDoxyfile(TextStream &t);
69 
70   /*! Parses a configuration file with name \a fn.
71    *  \returns TRUE if successful, FALSE if the file could not be
72    *  opened or read.
73    */
74   bool parse(const QCString &fileName,bool update=FALSE);
75 
76   /*! Post processed the parsed data. Replaces raw string values by the actual values.
77    *  and replaces environment variables.
78    *  \param clearHeaderAndFooter set to TRUE when writing header and footer templates.
79    *  \param compare signals if we in Doxyfile compare (`-x`) mode are or not. Influences
80    *  setting of the default value.
81    */
82   void postProcess(bool clearHeaderAndFooter, bool compare = FALSE);
83 
84   /*! Check the validity of the parsed options and correct or warn the user where needed.
85    * \param quiet setting for the QUIET option (can have been overruled by means of a command line option)
86    * \param check check  HTML / LaTeX header file etc. on existence (and terminate when not present)
87    */
88   void checkAndCorrect(bool quiet, const bool check);
89 
90   /*! Adjust any configuration values based on the value of obsolete options. */
91   void updateObsolete();
92 
93   /*! Clean up any data */
94   void deinit();
95 }
96 
97 #endif
98