Preferences.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef _Preferences_h_
  2. #define _Preferences_h_
  3. /* Preferences.h
  4. *
  5. * Copyright (C) 1996-2008,2011,2013,2015-2018 Paul Boersma
  6. *
  7. * This code is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * This code is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. * See the GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include "melder.h"
  21. /*
  22. * All strings added with Preferences_addString should have the following buffer size,
  23. * which conveniently equals the size of the path buffer in MelderFile so that
  24. * file paths can be used as preferences.
  25. */
  26. #define Preferences_STRING_BUFFER_SIZE 1+kMelder_MAXPATH
  27. #define pref_str32cpy(to, from) \
  28. str32ncpy (to, from, Preferences_STRING_BUFFER_SIZE); \
  29. to [Preferences_STRING_BUFFER_SIZE - 1] = U'\0';
  30. #define pref_str32cpy2(to2, to1, from) \
  31. str32ncpy (to1, from, Preferences_STRING_BUFFER_SIZE); \
  32. to1 [Preferences_STRING_BUFFER_SIZE - 1] = U'\0'; \
  33. str32cpy (to2, to1);
  34. void Preferences_addByte (conststring32 string /* cattable */, signed char *value, signed char defaultValue);
  35. void Preferences_addShort (conststring32 string /* cattable */, short *value, short defaultValue);
  36. void Preferences_addInt16 (conststring32 string /* cattable */, int *value, int defaultValue);
  37. void Preferences_addInt (conststring32 string /* cattable */, int *value, int defaultValue);
  38. void Preferences_addInteger (conststring32 string /* cattable */, integer *value, integer defaultValue);
  39. void Preferences_addUbyte (conststring32 string /* cattable */, unsigned char *value, unsigned char defaultValue);
  40. void Preferences_addUshort (conststring32 string /* cattable */, unsigned short *value, unsigned short defaultValue);
  41. void Preferences_addUint (conststring32 string /* cattable */, unsigned int *value, unsigned int defaultValue);
  42. void Preferences_addUinteger (conststring32 string /* cattable */, uinteger *value, uinteger defaultValue);
  43. void Preferences_addBool (conststring32 string /* cattable */, bool *value, bool defaultValue);
  44. void Preferences_addDouble (conststring32 string /* cattable */, double *value, double defaultValue);
  45. void Preferences_addString (conststring32 string /* cattable */, char32 *value, conststring32 defaultValue);
  46. void _Preferences_addEnum (conststring32 string /* cattable */, int *value, int min, int max,
  47. conststring32 (*getText) (int value), int (*getValue) (conststring32 text), int defaultValue);
  48. #define Preferences_addEnum(string, value, enumerated, defaultValue) \
  49. _Preferences_addEnum (string, (int *) value, (int) enumerated::MIN, (int) enumerated::MAX, \
  50. (conststring32 (*) (int)) enumerated##_getText, (enum_generic_getValue) enumerated##_getValue, (int) defaultValue)
  51. void Preferences_read (MelderFile file);
  52. void Preferences_write (MelderFile file);
  53. void Preferences_exit_optimizeByLeaking ();
  54. /* End of file Preferences.h */
  55. #endif