oo_CAN_WRITE_AS_ENCODING.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* oo_CAN_WRITE_AS_ENCODING.h
  2. *
  3. * Copyright (C) 2007,2009,2011-2018 Paul Boersma
  4. *
  5. * This code is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This code is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. * See the GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "oo_undef.h"
  19. #define oo_SIMPLE(type, storage, x)
  20. #define oo_SET(type, storage, x, setType)
  21. #define oo_VECTOR(type, storage, x, min, max)
  22. #define oo_ANYVEC(type, storage, x, sizeExpression)
  23. #define oo_MATRIX(type, storage, x, row1, row2, col1, col2)
  24. #define oo_ANYMAT(type, storage, x, nrowExpression, ncolExpression)
  25. #define oo_ENUMx(kType, storage, x)
  26. //#define oo_ENUMx_SET(kType, storage, x, setType)
  27. //#define oo_ENUMx_VECTOR(kType, storage, x, min, max)
  28. #define oo_STRINGx(storage, x) \
  29. if (our x && ! Melder_isEncodable (our x.get(), encoding)) return false;
  30. #define oo_STRINGx_SET(storage, x, setType) \
  31. for (int _i = 0; _i <= setType::MAX; _i ++) \
  32. if (our x [_i] && ! Melder_isEncodable (our x [_i].get(), encoding)) return false;
  33. #define oo_STRINGx_VECTOR(storage, x, n) \
  34. { \
  35. integer _size = (n); \
  36. Melder_assert (_size == our x.size); \
  37. if (our x) { \
  38. for (integer _i = 1; _i <= _size; _i ++) { \
  39. if (our x [_i] && ! Melder_isEncodable (our x [_i].get(), encoding)) return false; \
  40. } \
  41. } \
  42. }
  43. #define oo_STRUCT(Type, x) \
  44. if (! our x. canWriteAsEncoding (encoding)) return false;
  45. #define oo_STRUCT_SET(Type, x, setType) \
  46. for (int _i = 0; _i <= (int) setType::MAX; _i ++) { \
  47. if (! our x [_i]. canWriteAsEncoding (encoding)) return false; \
  48. }
  49. #define oo_STRUCT_VECTOR_FROM(Type, x, min, max) \
  50. { \
  51. integer _min = (min), _max = (max); \
  52. if (our x) { \
  53. for (integer _i = _min; _i <= _max; _i ++) { \
  54. if (! our x [_i]. canWriteAsEncoding (encoding)) return false; \
  55. } \
  56. } \
  57. }
  58. #define oo_STRUCT_MATRIX_FROM(Type, x, row1, row2, col1, col2) \
  59. { \
  60. integer _row1 = (row1), _row2 = (row2), _col1 = (col1), _col2 = (col2); \
  61. if (our x) { \
  62. for (integer _irow = _row1; _irow <= _row2; _irow ++) { \
  63. for (integer _icol = _col1; _icol <= _col2; _icol ++) { \
  64. if (! our x [_irow] [_icol]. canWriteAsEncoding (encoding)) return false; \
  65. } \
  66. } \
  67. } \
  68. }
  69. #define oo_OBJECT(Class, version, x) \
  70. if (our x && ! Data_canWriteAsEncoding (our x.get(), encoding)) return false;
  71. #define oo_COLLECTION_OF(Class, x, ItemClass, version) \
  72. for (integer _i = 1; _i <= x.size; _i ++) { \
  73. if (our x.at [_i] && ! Data_canWriteAsEncoding (our x.at [_i], encoding)) return false; \
  74. }
  75. #define oo_COLLECTION(Class, x, ItemClass, version) \
  76. if (our x && ! Data_canWriteAsEncoding (our x.get(), encoding)) return false;
  77. #define oo_FILE(x) \
  78. if (! Melder_isEncodable (our x. path, encoding)) return false;
  79. #define oo_DIR(x) \
  80. if (! Melder_isEncodable (our x. path, encoding)) return false;
  81. #define oo_DEFINE_STRUCT(Type) \
  82. bool struct##Type :: canWriteAsEncoding (int encoding) { \
  83. (void) encoding;
  84. #define oo_END_STRUCT(Type) \
  85. return true; \
  86. }
  87. #define oo_DEFINE_CLASS(Class, Parent) \
  88. bool struct##Class :: v_canWriteAsEncoding (int encoding) { \
  89. if (! Class##_Parent :: v_canWriteAsEncoding (encoding)) return false;
  90. #define oo_END_CLASS(Class) \
  91. return true; \
  92. }
  93. #define oo_FROM(from)
  94. #define oo_ENDFROM
  95. #define oo_DECLARING 0
  96. #define oo_DESTROYING 0
  97. #define oo_COPYING 0
  98. #define oo_COMPARING 0
  99. #define oo_VALIDATING_ENCODING 1
  100. #define oo_READING 0
  101. #define oo_READING_TEXT 0
  102. #define oo_READING_BINARY 0
  103. #define oo_WRITING 0
  104. #define oo_WRITING_TEXT 0
  105. #define oo_WRITING_BINARY 0
  106. #define oo_DESCRIBING 0
  107. /* End of file oo_CAN_WRITE_AS_ENCODING.h */