Blame src/config.h

Packit 1c1d7e
/******************************************************************************
Packit 1c1d7e
 *
Packit 1c1d7e
 * Copyright (C) 1997-2015 by Dimitri van Heesch.
Packit 1c1d7e
 *
Packit 1c1d7e
 * Permission to use, copy, modify, and distribute this software and its
Packit 1c1d7e
 * documentation under the terms of the GNU General Public License is hereby
Packit 1c1d7e
 * granted. No representations are made about the suitability of this software
Packit 1c1d7e
 * for any purpose. It is provided "as is" without express or implied warranty.
Packit 1c1d7e
 * See the GNU General Public License for more details.
Packit 1c1d7e
 *
Packit 1c1d7e
 * Documents produced by Doxygen are derivative works derived from the
Packit 1c1d7e
 * input used in their production; they are not affected by this license.
Packit 1c1d7e
 *
Packit 1c1d7e
 */
Packit 1c1d7e
Packit 1c1d7e
#ifndef CONFIG_H
Packit 1c1d7e
#define CONFIG_H
Packit 1c1d7e
Packit 1c1d7e
class FTextStream;
Packit 1c1d7e
Packit 1c1d7e
// note: this header file is generated from config.xml
Packit 1c1d7e
#include "configvalues.h"
Packit 1c1d7e
Packit 1c1d7e
//! @{
Packit 1c1d7e
//! some convenience macros for accessing the config options
Packit 1c1d7e
//! mainly done like this for backward compatibility
Packit 1c1d7e
#if DYNAMIC_LOOKUP // for debug purposes
Packit 1c1d7e
#define Config_getString(val) (ConfigValues::instance().*((ConfigValues::InfoString*)ConfigValues::instance().get(#val))->item)
Packit 1c1d7e
#define Config_getBool(val)   (ConfigValues::instance().*((ConfigValues::InfoBool*)ConfigValues::instance().get(#val))->item)
Packit 1c1d7e
#define Config_getInt(val)    (ConfigValues::instance().*((ConfigValues::InfoInt*)ConfigValues::instance().get(#val))->item)
Packit 1c1d7e
#define Config_getEnum(val)   (ConfigValues::instance().*((ConfigValues::InfoString*)ConfigValues::instance().get(#val))->item)
Packit 1c1d7e
#define Config_getList(val)   (ConfigValues::instance().*((ConfigValues::InfoList*)ConfigValues::instance().get(#val))->item)
Packit 1c1d7e
#else // direct access
Packit 1c1d7e
#define Config_getString(val) (ConfigValues::instance().val)
Packit 1c1d7e
#define Config_getBool(val)   (ConfigValues::instance().val)
Packit 1c1d7e
#define Config_getInt(val)    (ConfigValues::instance().val)
Packit 1c1d7e
#define Config_getEnum(val)   (ConfigValues::instance().val)
Packit 1c1d7e
#define Config_getList(val)   (ConfigValues::instance().val)
Packit 1c1d7e
#endif
Packit 1c1d7e
//! @}
Packit 1c1d7e
Packit 1c1d7e
/** \brief Public function to deal with the configuration file. */
Packit 1c1d7e
namespace Config
Packit 1c1d7e
{
Packit 1c1d7e
  /*! Initialize configuration variables to their default value */
Packit 1c1d7e
  void init();
Packit 1c1d7e
Packit 1c1d7e
  /*! Writes a template configuration to stream \a t. If \a shortList
Packit 1c1d7e
   *  is \c TRUE the description of each configuration option will
Packit 1c1d7e
   *  be omitted.
Packit 1c1d7e
   */
Packit 1c1d7e
  void writeTemplate(FTextStream &t,bool shortList,bool updateOnly=FALSE);
Packit 1c1d7e
Packit 1c1d7e
  /*! Parses a configuration file with name \a fn.
Packit 1c1d7e
   *  \returns TRUE if successful, FALSE if the file could not be
Packit 1c1d7e
   *  opened or read.
Packit 1c1d7e
   */
Packit 1c1d7e
  bool parse(const char *fileName,bool update=FALSE);
Packit 1c1d7e
Packit 1c1d7e
  /*! Post processed the parsed data. Replaces raw string values by the actual values.
Packit 1c1d7e
   *  and replaces environment variables.
Packit 1c1d7e
   *  \param clearHeaderAndFooter set to TRUE when writing header and footer templates.
Packit 1c1d7e
   */
Packit 1c1d7e
  void postProcess(bool clearHeaderAndFooter);
Packit 1c1d7e
Packit 1c1d7e
  /*! Check the validity of the parsed options and correct or warn the user where needed. */
Packit 1c1d7e
  void checkAndCorrect();
Packit 1c1d7e
Packit 1c1d7e
  /*! Clean up any data */
Packit 1c1d7e
  void deinit();
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
#endif