ECConfig.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright 2005 - 2016 Zarafa and its licensors
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Affero General Public License, version 3,
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Affero General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Affero General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. */
  17. #ifndef ECCONFIG_H
  18. #define ECCONFIG_H
  19. #include <kopano/zcdefs.h>
  20. #include <list>
  21. #include <string>
  22. namespace KC {
  23. struct configsetting_t {
  24. const char *szName;
  25. const char *szValue;
  26. unsigned short ulFlags;
  27. #define CONFIGSETTING_ALIAS 0x0001
  28. #define CONFIGSETTING_RELOADABLE 0x0002
  29. #define CONFIGSETTING_UNUSED 0x0004
  30. #define CONFIGSETTING_NONEMPTY 0x0008
  31. #define CONFIGSETTING_EXACT 0x0010
  32. #define CONFIGSETTING_SIZE 0x0020
  33. unsigned short ulGroup;
  34. #define CONFIGGROUP_PROPMAP 0x0001
  35. };
  36. #ifdef UNICODE
  37. #define GetConfigSetting(_config, _name) ((_config)->GetSettingW(_name))
  38. #else
  39. #define GetConfigSetting(_config, _name) ((_config)->GetSetting(_name))
  40. #endif
  41. static const char *const lpszDEFAULTDIRECTIVES[] = {"include", NULL};
  42. class _kc_export ECConfig {
  43. public:
  44. static ECConfig *Create(const configsetting_t *defaults, const char *const *directives = lpszDEFAULTDIRECTIVES);
  45. static ECConfig *Create(const std::nothrow_t &, const configsetting_t *defaults, const char *const *directives = lpszDEFAULTDIRECTIVES);
  46. static const char *GetDefaultPath(const char *basename);
  47. _kc_hidden virtual ~ECConfig(void) _kc_impdtor;
  48. _kc_hidden virtual bool LoadSettings(const char *file) = 0;
  49. _kc_hidden virtual bool LoadSettings(const wchar_t *file);
  50. _kc_hidden virtual int ParseParams(int argc, char **argv) = 0;
  51. _kc_hidden virtual const char *GetSettingsPath(void) = 0;
  52. _kc_hidden virtual bool ReloadSettings(void) = 0;
  53. _kc_hidden virtual bool AddSetting(const char *name, const char *value, unsigned int group = 0) = 0;
  54. _kc_hidden virtual const char *GetSetting(const char *name) = 0;
  55. _kc_hidden virtual const char *GetSetting(const char *name, const char *equal, const char *other) = 0;
  56. _kc_hidden virtual const wchar_t *GetSettingW(const char *name) = 0;
  57. _kc_hidden virtual const wchar_t *GetSettingW(const char *name, const wchar_t *equal, const wchar_t *other) = 0;
  58. _kc_hidden virtual std::list<configsetting_t> GetSettingGroup(unsigned int group) = 0;
  59. _kc_hidden virtual std::list<configsetting_t> GetAllSettings(void) = 0;
  60. _kc_hidden virtual bool HasWarnings(void) = 0;
  61. _kc_hidden virtual const std::list<std::string> *GetWarnings(void) = 0;
  62. _kc_hidden virtual bool HasErrors(void) = 0;
  63. _kc_hidden virtual const std::list<std::string> *GetErrors(void) = 0;
  64. };
  65. } /* namespace */
  66. #endif // ECCONFIG_H