melder.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #ifndef _melder_h_
  2. #define _melder_h_
  3. /* melder.h
  4. *
  5. * Copyright (C) 1992-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 <stdio.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <stdarg.h>
  24. #include <stddef.h>
  25. #include <wchar.h>
  26. #include <wctype.h>
  27. #ifdef __MINGW32__
  28. #include <sys/types.h> // for off_t
  29. #endif
  30. #include <stdbool.h>
  31. #include <functional> // std::move, std::forward
  32. #include <memory> // unique_ptr
  33. #include <new> // placement new
  34. #include <algorithm> // std::min
  35. #include "melder_assert.h" // Melder_assert
  36. #include "melder_int.h" // <stdint.h>, int64, integer_to_uinteger (requires Melder_assert)
  37. #include "melder_pointer.h" // NULL
  38. #include "melder_real.h" // longdouble
  39. #include "complex.h" // dcomplex
  40. /*
  41. Law of Demeter for class functions defined outside class definition.
  42. */
  43. #define our this ->
  44. /* The single most useful macro in Praat: */
  45. #define my me ->
  46. #define thy thee ->
  47. #define your you ->
  48. #define his him ->
  49. #define her she ->
  50. #define iam(klas) klas me = (klas) void_me
  51. #include "melder_alloc.h" // Melder_malloc (requires int64), Melder_free, Melder_strdup
  52. #include "melder_string32.h" // char32, conststring32, autostring32 (requires Melder_malloc, our), Melder_dup
  53. #include "melder_kar.h" // Melder_hasInk (requires char32), Melder_toLowerCase
  54. #include "melder_str32.h" // str32len, str32cpy, str32cmp_caseInsensitive (requires Melder_toLowerCase)
  55. #include "enums.h"
  56. #include "melder_enums.h"
  57. /*
  58. * Operating system version control.
  59. */
  60. #define ALLOW_GDK_DRAWING (gtk && 1) /* change to (gtk && 0) if you want to try out GTK 3 */
  61. /* */
  62. typedef struct { double red, green, blue, transparency; } double_rgbt;
  63. #include "melder_ftoa.h" // Melder_double, Melder_pad (require dcomplex, conststring32)
  64. #include "melder_console.h" // MelderConsole (requires conststring32)
  65. #include "melder_textencoding.h" // str32len_utf8, Melder_32to8
  66. #include "melder_atof.h"
  67. #include "melder_files.h" // Melder_fopen, MelderFile, MelderDir
  68. #include "melder_tensor.h" // NUMvector, autoNUMmatrix, VEC, autoMAT, Melder_VEC
  69. #include "melder_strvec.h" // string32vector, autostring32vector (requires NUMvector)
  70. #include "melder_sort.h" // VECsort_inplace (requires VEC), NUMsort_str (requires string32vector)
  71. #include "MelderArg.h" // MelderArg (requires Melder_double, MelderFile, Melder_VEC)
  72. #include "melder_debug.h" // trace (requires MelderFile, MelderArg), Melder_debug
  73. #include "MelderFile.h" // MelderFile_open (requires MelderFile), MelderFile_write (requires MelderArg)
  74. #include "MelderString.h" // MelderString_append (requires MelderArg)
  75. #include "melder_cat.h" // Melder_cat (requires MelderArg)
  76. #include "melder_sprint.h" // Melder_sprint (requires MelderArg)
  77. #include "melder_search.h"
  78. #include "melder_casual.h"
  79. #include "melder_info.h"
  80. #include "melder_error.h" // Melder_throw (requires MelderArg)
  81. #include "melder_require.h"
  82. #include "melder_warning.h"
  83. #include "melder_fatal.h"
  84. #include "melder_progress.h"
  85. #include "melder_play.h" // Melder_record, Melder_play, Melder_beep
  86. #include "melder_help.h"
  87. #include "melder_ftoi.h"
  88. #include "melder_time.h" // stopwatch, sleep, clock
  89. #include "melder_audio.h"
  90. #include "melder_audiofiles.h"
  91. /* The following trick uses Melder_debug only because it is the only plain variable known to exist at the moment. */
  92. #define Melder_offsetof(klas,member) (int) ((char *) & ((klas) & Melder_debug) -> member - (char *) & Melder_debug)
  93. /********** SYSTEM VERSION **********/
  94. /*
  95. For MacOS, this is set in Melder_init.
  96. TODO: change to inline variable once C++17 is implemented completely on all platforms.
  97. */
  98. extern int32 Melder_systemVersion;
  99. /********** ENFORCE INTERACTIVE BEHAVIOUR **********/
  100. /* Procedures to enforce interactive behaviour of the Melder_XXXXXX routines. */
  101. /*
  102. Set in praat_init.
  103. True if run from the batch or from an interactive command-line interface.
  104. TODO: change to inline variable once C++17 is implemented completely on all platforms.
  105. */
  106. extern bool Melder_batch;
  107. /*
  108. True if running a script.
  109. TODO: change to inline variable once C++17 is implemented completely on all platforms.
  110. */
  111. extern bool Melder_backgrounding;
  112. void Melder_init (); // inits NUmrandom, alloc, message, Melder_systemVersion
  113. #include "melder_quantity.h"
  114. #include "MelderReadText.h"
  115. #include "melder_tensorio.h" // requires MelderReadText
  116. #include "melder_sysenv.h"
  117. #include "abcio_enums.h"
  118. #include "abcio.h" // requires MelderReadText
  119. #include "melder_templates.h" // Melder_ENABLE_IF_ISA, MelderCallback, MelderCompareHook
  120. #include "NUMmath.h" // <math.h>, NUMpi, undefined
  121. #include "NUMspecfunc.h"
  122. #include "NUMear.h"
  123. #include "NUMinterpol.h"
  124. #include "NUMmetrics.h"
  125. #include "NUMrandom.h"
  126. #include "NUMfilter.h"
  127. #include "NUMlinprog.h"
  128. #include "regularExp.h"
  129. #include "PAIRWISE_SUM.h"
  130. #include "NUM.h"
  131. #include "STR.h"
  132. #include "VEC.h"
  133. #include "MAT.h"
  134. #include "STRVEC.h"
  135. /* End of file melder.h */
  136. #endif