-
Notifications
You must be signed in to change notification settings - Fork 187
/
Copy pathattalternates.h
418 lines (345 loc) · 11.6 KB
/
attalternates.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
/////////////////////////////////////////////////////////////////////////////
// Name: attalternates.h
// Author: Laurent Pugin
// Created: 2017
// Copyright (c) Authors and others. All rights reserved.
/////////////////////////////////////////////////////////////////////////////
#ifndef __VRV_ATT_ALTERNATES_H__
#define __VRV_ATT_ALTERNATES_H__
#include <string>
//----------------------------------------------------------------------------
#include "atttypes.h"
#include "vrvdef.h"
namespace vrv {
//----------------------------------------------------------------------------
// Alternate data types not generated by LibMEI
//----------------------------------------------------------------------------
/**
* MEI data.FONTSIZE
* Since it can contain different subtype we need a dedicated class for it.
*/
enum FontSizeType { FONTSIZE_NONE = 0, FONTSIZE_fontSizeNumeric, FONTSIZE_term, FONTSIZE_percent };
class data_FONTSIZE {
public:
data_FONTSIZE() { Reset(FONTSIZE_NONE); }
virtual ~data_FONTSIZE() {}
void Reset(FontSizeType type)
{
m_type = type;
m_fontSizeNumeric = VRV_UNSET;
m_term = FONTSIZETERM_NONE;
m_percent = 0;
}
FontSizeType GetType() const { return m_type; }
data_FONTSIZENUMERIC GetFontSizeNumeric() const { return m_fontSizeNumeric; }
void SetFontSizeNumeric(data_FONTSIZENUMERIC value)
{
Reset(FONTSIZE_fontSizeNumeric);
m_fontSizeNumeric = value;
}
data_FONTSIZETERM GetTerm() const { return m_term; }
void SetTerm(data_FONTSIZETERM value)
{
Reset(FONTSIZE_term);
m_term = value;
}
data_PERCENT GetPercent() const { return m_percent; }
void SetPercent(data_PERCENT value)
{
Reset(FONTSIZE_percent);
m_percent = value;
}
int GetPercentForTerm() const
{
switch (m_term) {
case (FONTSIZETERM_xx_large): return 200; break;
case (FONTSIZETERM_x_large): return 150; break;
case (FONTSIZETERM_large): return 110; break;
case (FONTSIZETERM_larger): return 110; break;
case (FONTSIZETERM_small): return 80; break;
case (FONTSIZETERM_smaller): return 80; break;
case (FONTSIZETERM_x_small): return 60; break;
case (FONTSIZETERM_xx_small): return 50; break;
default: return 100; break;
}
}
bool HasValue() const
{
if (m_fontSizeNumeric != VRV_UNSET) return true;
if (m_term != FONTSIZETERM_NONE) return true;
if (m_percent != 0) return true;
return false;
}
// comparison
bool operator==(const data_FONTSIZE &val) const
{
if (m_type != val.GetType()) return false;
if (m_fontSizeNumeric != val.GetFontSizeNumeric()) return false;
if (m_term != val.GetTerm()) return false;
if (m_percent != val.GetPercent()) return false;
return true;
}
bool operator!=(const data_FONTSIZE &val) const { return !(*this == val); }
protected:
FontSizeType m_type;
data_FONTSIZENUMERIC m_fontSizeNumeric;
data_FONTSIZETERM m_term;
data_PERCENT m_percent;
};
/**
* MEI data.MEASUREMENTSIGNED
* Since it can contain different subtype we need a dedicated class for it.
*/
enum MeasurementType { MEASUREMENTTYPE_NONE = 0, MEASUREMENTTYPE_vu, MEASUREMENTTYPE_px };
class data_MEASUREMENTSIGNED {
public:
data_MEASUREMENTSIGNED() { Reset(MEASUREMENTTYPE_NONE); }
virtual ~data_MEASUREMENTSIGNED() {}
void Reset(MeasurementType type)
{
m_type = type;
m_px = VRV_UNSET;
m_vu = VRV_UNSET;
}
MeasurementType GetType() const { return m_type; }
int GetPx() const { return m_px; }
void SetPx(int px)
{
Reset(MEASUREMENTTYPE_px);
m_px = px;
}
double GetVu() const { return m_vu; }
void SetVu(double vu)
{
Reset(MEASUREMENTTYPE_vu);
m_vu = vu;
}
bool HasValue() const
{
if (m_px != VRV_UNSET) return true;
if (m_vu != VRV_UNSET) return true;
return false;
}
// comparison
bool operator==(const data_MEASUREMENTSIGNED &val) const
{
if (m_type != val.GetType()) return false;
if (m_px != val.GetPx()) return false;
if (m_vu != val.GetVu()) return false;
return true;
}
bool operator!=(const data_MEASUREMENTSIGNED &val) const { return !(*this == val); }
protected:
MeasurementType m_type;
int m_px;
double m_vu;
};
typedef data_MEASUREMENTSIGNED data_MEASUREMENTUNSIGNED;
/**
* MEI data.LINEWIDTH
* Since it can contain different subtype we need a dedicated class for it.
*/
enum LinewidthType { LINEWIDTHTYPE_NONE = 0, LINEWIDTHTYPE_lineWidthTerm, LINEWIDTHTYPE_measurementunsigned };
class data_LINEWIDTH {
public:
data_LINEWIDTH() { Reset(LINEWIDTHTYPE_NONE); }
virtual ~data_LINEWIDTH() {}
void Reset(LinewidthType type)
{
m_type = type;
m_lineWidthTerm = LINEWIDTHTERM_NONE;
m_measurementunsigned = data_MEASUREMENTUNSIGNED();
}
LinewidthType GetType() const { return m_type; }
data_LINEWIDTHTERM GetLineWithTerm() const { return m_lineWidthTerm; }
void SetLineWidthTerm(data_LINEWIDTHTERM value)
{
Reset(LINEWIDTHTYPE_lineWidthTerm);
m_lineWidthTerm = value;
}
data_MEASUREMENTUNSIGNED GetMeasurementunsigned() const { return m_measurementunsigned; }
void SetMeasurementunsigned(data_MEASUREMENTUNSIGNED value)
{
Reset(LINEWIDTHTYPE_measurementunsigned);
m_measurementunsigned = value;
}
bool HasValue() const
{
if (m_lineWidthTerm != LINEWIDTHTERM_NONE) return true;
if (m_measurementunsigned != data_MEASUREMENTUNSIGNED()) return true;
return false;
}
// comparison
bool operator==(const data_LINEWIDTH &val) const
{
if (m_type != val.GetType()) return false;
if (m_lineWidthTerm != val.GetLineWithTerm()) return false;
if (m_measurementunsigned != val.GetMeasurementunsigned()) return false;
return true;
}
bool operator!=(const data_LINEWIDTH &val) const { return !(*this == val); }
protected:
LinewidthType m_type;
data_LINEWIDTHTERM m_lineWidthTerm;
data_MEASUREMENTUNSIGNED m_measurementunsigned;
};
/**
* MEI data.MIDIVALUE_NAME
* Since it can contain different subtype we need a dedicated class for it.
*/
enum MidivalueNameType { MIDIVALUENAMETYPE_NONE = 0, MIDIVALUENAMETYPE_midivalue, MIDIVALUENAMETYPE_mcname };
class data_MIDIVALUE_NAME {
public:
data_MIDIVALUE_NAME() { Reset(MIDIVALUENAMETYPE_NONE); }
virtual ~data_MIDIVALUE_NAME() {}
void Reset(MidivalueNameType type)
{
m_type = type;
m_midivalue = -1;
m_ncname = "";
}
MidivalueNameType GetType() const { return m_type; }
data_MIDIVALUE GetMidivalue() const { return m_midivalue; }
void SetMidivalue(data_MIDIVALUE value)
{
Reset(MIDIVALUENAMETYPE_midivalue);
m_midivalue = value;
}
data_NCNAME GetNcname() const { return m_ncname; }
void SetNcname(data_NCNAME value)
{
Reset(MIDIVALUENAMETYPE_mcname);
m_ncname = value;
}
bool HasValue() const
{
if (m_midivalue != -1) return true;
if (m_ncname != "") return true;
return false;
}
// comparison
bool operator==(const data_MIDIVALUE_NAME &val) const
{
if (m_type != val.GetType()) return false;
if (m_midivalue != val.GetMidivalue()) return false;
if (m_ncname != val.GetNcname()) return false;
return true;
}
bool operator!=(const data_MIDIVALUE_NAME &val) const { return !(*this == val); }
protected:
MidivalueNameType m_type;
data_MIDIVALUE m_midivalue;
data_NCNAME m_ncname;
};
/**
* MEI data.MIDIVALUE_PAN
* Since it can contain different subtype we need a dedicated class for it.
*/
enum MidivaluePanType { MIDIVALUEPANTYPE_NONE = 0, MIDIVALUEPANTYPE_midivalue, MIDIVALUEPANTYPE_percentLimitedSigned };
class data_MIDIVALUE_PAN {
public:
data_MIDIVALUE_PAN() { Reset(MIDIVALUEPANTYPE_NONE); }
virtual ~data_MIDIVALUE_PAN() {}
void Reset(MidivaluePanType type)
{
m_type = type;
m_midivalue = -1;
m_percentLimitedSigned = VRV_UNSET;
}
MidivaluePanType GetType() const { return m_type; }
data_MIDIVALUE GetMidivalue() const { return m_midivalue; }
void SetMidivalue(data_MIDIVALUE value)
{
Reset(MIDIVALUEPANTYPE_midivalue);
m_midivalue = value;
}
data_PERCENT_LIMITED_SIGNED GetPercentLimitedSigned() const { return m_percentLimitedSigned; }
void SetPercentLimitedSigned(data_PERCENT_LIMITED_SIGNED value)
{
Reset(MIDIVALUEPANTYPE_percentLimitedSigned);
m_percentLimitedSigned = value;
}
bool HasValue() const
{
if (m_midivalue != -1) return true;
if (m_percentLimitedSigned != VRV_UNSET) return true;
return false;
}
// comparison
bool operator==(const data_MIDIVALUE_PAN &val) const
{
if (m_type != val.GetType()) return false;
if (m_midivalue != val.GetMidivalue()) return false;
if (m_percentLimitedSigned != val.GetPercentLimitedSigned()) return false;
return true;
}
bool operator!=(const data_MIDIVALUE_PAN &val) const { return !(*this == val); }
protected:
MidivaluePanType m_type;
data_MIDIVALUE m_midivalue;
data_PERCENT_LIMITED_SIGNED m_percentLimitedSigned;
};
//----------------------------------------------------------------------------
// Alternate data types unsing other alternate data types (above)
//----------------------------------------------------------------------------
/**
* MEI data.PLACEMENT
* Since it can contain different subtype we need a dedicated class for it.
*/
enum PlacementType { PLACEMENT_NONE = 0, PLACEMENT_staffRel, PLACEMENT_nonStaffPlace, PLACEMENT_nmtoken };
class data_PLACEMENT {
public:
data_PLACEMENT() { Reset(PLACEMENT_NONE); }
virtual ~data_PLACEMENT() {}
void Reset(PlacementType type)
{
m_type = type;
m_staffRel = data_STAFFREL();
m_nonStaffPlace = NONSTAFFPLACE_NONE;
m_nmtoken = "";
}
PlacementType GetType() const { return m_type; }
data_STAFFREL GetStaffRel() const { return m_staffRel; }
void SetStaffRel(data_STAFFREL value)
{
Reset(PLACEMENT_staffRel);
m_staffRel = value;
}
data_STAFFREL *GetStaffRelAtlernate() { return &m_staffRel; }
data_NONSTAFFPLACE GetNonStaffPlace() const { return m_nonStaffPlace; }
void SetNonStaffPlace(data_NONSTAFFPLACE value)
{
Reset(PLACEMENT_nonStaffPlace);
m_nonStaffPlace = value;
}
std::string GetNMToken() const { return m_nmtoken; }
void SetNMToken(std::string value)
{
Reset(PLACEMENT_nmtoken);
m_nmtoken = value;
}
bool HasValue() const
{
if (m_staffRel != STAFFREL_NONE) return true;
if (m_nonStaffPlace != NONSTAFFPLACE_NONE) return true;
if (m_nmtoken != "") return true;
return false;
}
// comparison
bool operator==(const data_PLACEMENT &val) const
{
if (m_type != val.GetType()) return false;
if (m_staffRel != val.GetStaffRel()) return false;
if (m_nonStaffPlace != val.GetNonStaffPlace()) return false;
if (m_nmtoken != val.GetNMToken()) return false;
return true;
}
bool operator!=(const data_PLACEMENT &val) const { return !(*this == val); }
protected:
PlacementType m_type;
data_STAFFREL m_staffRel;
data_NONSTAFFPLACE m_nonStaffPlace;
std::string m_nmtoken;
};
} // namespace vrv
#endif