Debian Codegraph @

sys/oo_EQUAL.h

raw
1 /* oo_EQUAL.h
2 *
3 * Copyright (C) 1994-2007,2009,2011-2020,2022,2024,2026 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 3 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
19 #include "oo_undef.h"
20
21 #define oo_SIMPLE(type, storage, x) \
22 if (our x != thy x) \
23 return false;
24
25 #define oo_SET(type, storage, x, setType) \
26 for (int _i = 0; _i <= (int) setType::MAX; _i ++) { \
27 if (our x [_i] != thy x [_i]) \
28 return false; \
29 }
30
31 #define oo_ANYVEC(type, storage, x, sizeExpression) \
32 { \
33 const integer _size = (sizeExpression); \
34 Melder_assert (our x.size == _size); \
35 if (_size > 0) { \
36 if (! NUMequal (our x.get(), thy x.get())) \
37 return false; \
38 } \
39 }
40
41 #define oo_ANYMAT(type, storage, x, nrowExpression, ncolExpression) \
42 { \
43 const integer _nrow = (nrowExpression), _ncol = (ncolExpression); \
44 if (_nrow > 0 && _ncol > 0) { \
45 /*Melder_assert (our x.nrow == _nrow && our x.ncol == _ncol); BUG routinely violated in SSCP for lowerCholesky */ \
46 if (! NUMequal (our x.get(), thy x.get())) \
47 return false; \
48 } \
49 }
50
51 #define oo_ANYTEN3(type, storage, x, ndim1Expression, ndim2Expression, ndim3Expression) \
52 { \
53 const integer _ndim1 = (ndim1Expression), _ndim2 = (ndim2Expression), _ndim3 = (ndim3Expression); \
54 if (_ndim1 > 0 && _ndim2 > 0 && _ndim3 > 0) { \
55 if (! NUMequal (our x.get(), thy x.get())) \
56 return false; \
57 } \
58 }
59
60 #define oo_ENUMx(kType, storage, x) \
61 if (our x != thy x) \
62 return false;
63
64 //#define oo_ENUMx_SET(kType, storage, x, setType) \
65 // for (int _i = 0; _i <= (int) setType::MAX; _i ++) \
66 // if (our x [_i] != thy x [_i]) \
67 // return false;
68
69 #define oo_STRINGx(storage, x) \
70 if (! Melder_equ (our x.get(), thy x.get())) \
71 return false;
72
73 #define oo_STRINGx_SET(storage, x, setType) \
74 for (int _i = 0; _i <= setType::MAX; _i ++) \
75 if (! Melder_equ (our x [_i].get(), thy x [_i].get())) \
76 return false;
77
78 #define oo_STRINGx_VECTOR(storage, x, sizeExpression) \
79 { \
80 const integer _size = (sizeExpression); \
81 Melder_assert (_size == our x.size); \
82 if (! our x != ! thy x) \
83 return false; \
84 if (our x) { \
85 for (integer _i = 1; _i <= _size; _i ++) { \
86 if (! Melder_equ (our x [_i].get(), thy x [_i].get())) \
87 return false; \
88 } \
89 } \
90 }
91
92 #define oo_STRUCT(Type, x) \
93 if (! our x. equal (& thy x)) \
94 return false;
95
96 #define oo_STRUCT_SET(Type, x, setType) \
97 for (int _i = 0; _i <= (int) setType::MAX; _i ++) { \
98 if (! our x [_i]. equal (& thy x [_i])) \
99 return false; \
100 }
101
102 #define oo_STRUCTVEC(Type, x, sizeExpression) \
103 { \
104 const integer _size = (sizeExpression); \
105 Melder_assert (_size == our x.size); \
106 if (thy x.size != _size) \
107 return false; \
108 for (integer _i = 1; _i <= _size; _i ++) { \
109 if (! our x [_i]. equal (& thy x [_i])) \
110 return false; \
111 } \
112 }
113
114 #define oo_STRUCTMAT(Type, x, nrowExpression, ncolExpression) \
115 { \
116 const integer _nrow = (nrowExpression), _ncol = (ncolExpression); \
117 Melder_assert (_nrow == our x.nrow && _ncol == our x.ncol); \
118 if (thy x.nrow != _nrow || thy x.ncol != _ncol) \
119 return false; \
120 for (integer _irow = 1; _irow <= _nrow; _irow ++) { \
121 for (integer _icol = 1; _icol <= _ncol; _icol ++) { \
122 if (! our x [_irow] [_icol]. equal (& thy x [_irow] [_icol])) \
123 return false; \
124 } \
125 } \
126 }
127
128 #define oo_OBJECT(Class, version, x) \
129 if (! our x != ! thy x || (our x && ! Data_equal (our x.get(), thy x.get()))) \
130 return false;
131
132 #define oo_COLLECTION_OF(Class, x, ItemClass, version) \
133 for (integer _i = 1; _i <= our x.size; _i ++) { \
134 if (! our x.at [_i] != ! thy x.at [_i] || (our x.at [_i] && ! Data_equal (our x.at [_i], thy x.at [_i]))) \
135 return false; \
136 }
137
138 #define oo_COLLECTION(Class, x, ItemClass, version) \
139 if (! our x != ! thy x || (our x && ! Data_equal (our x.get(), thy x.get()))) \
140 return false;
141
142 #define oo_TRANSIENT_FILE(x) \
143 if (! MelderFile_equal (& our x, & thy x)) \
144 return false;
145
146 #define oo_TRANSIENT_FOLDER(x) \
147 if (! MelderFolder_equal (& our x, & thy x)) \
148 return false;
149
150 #define oo_UNSAFE_BORROWED_TRANSIENT_CONST_OBJECT_REFERENCE(Class, x) \
151 if (our x != thy x) /* pointer comparison */ \
152 return false;
153
154 #define oo_UNSAFE_BORROWED_TRANSIENT_MUTABLE_OBJECT_REFERENCE(Class, x) \
155 if (our x != thy x) /* pointer comparison */ \
156 return false;
157
158 #define oo_DEFINE_STRUCT(Type) \
159 bool struct##Type :: equal (Type thee) {
160
161 #define oo_END_STRUCT(Type) \
162 return true; \
163 }
164
165 #define oo_DEFINE_CLASS(Class, Parent) \
166 bool struct##Class :: v1_equal (Daata _thee_Daata) { \
167 Class thee = static_cast <Class> (_thee_Daata); \
168 if (! Class##_Parent :: v1_equal (thee)) \
169 return false;
170
171 #define oo_END_CLASS(Class) \
172 return true; \
173 }
174
175 #define oo_FROM(from)
176
177 #define oo_ENDFROM
178
179 #define oo_DECLARING 0
180 #define oo_DESTROYING 0
181 #define oo_COPYING 0
182 #define oo_COMPARING 1
183 #define oo_VALIDATING_ENCODING 0
184 #define oo_READING 0
185 #define oo_READING_TEXT 0
186 #define oo_READING_BINARY 0
187 #define oo_WRITING 0
188 #define oo_WRITING_TEXT 0
189 #define oo_WRITING_BINARY 0
190 #define oo_DESCRIBING 0
191
192 /* End of file oo_EQUAL.h */