1 /*
2   MusicXML Library
3   Copyright (C) Grame 2006-2013
4 
5   This Source Code Form is subject to the terms of the Mozilla Public
6   License, v. 2.0. If a copy of the MPL was not distributed with this
7   file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9   Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
10   research@grame.fr
11 */
12 
13 #include <sstream>
14 #include <iomanip>      // setw, setprecision, ...
15 #include <string>
16 #include <regex>
17 
18 #include "utilities.h"
19 
20 #include "setTraceOahIfDesired.h"
21 #ifdef TRACE_OAH
22   #include "traceOah.h"
23 #endif
24 
25 #include "generalOah.h"
26 #include "lpsrOah.h"
27 
28 
29 using namespace std;
30 
31 namespace MusicXML2
32 {
33 
34 //______________________________________________________________________________
create(string shortName,string longName,string description,string valueSpecification,string variableName,lpsrScoreOutputKind & lpsrScoreOutputKindVariable)35 S_lpsrScoreOutputKindAtom lpsrScoreOutputKindAtom::create (
36   string               shortName,
37   string               longName,
38   string               description,
39   string               valueSpecification,
40   string               variableName,
41   lpsrScoreOutputKind& lpsrScoreOutputKindVariable)
42 {
43   lpsrScoreOutputKindAtom* o = new
44     lpsrScoreOutputKindAtom (
45       shortName,
46       longName,
47       description,
48       valueSpecification,
49       variableName,
50       lpsrScoreOutputKindVariable);
51   assert(o!=0);
52   return o;
53 }
54 
lpsrScoreOutputKindAtom(string shortName,string longName,string description,string valueSpecification,string variableName,lpsrScoreOutputKind & lpsrScoreOutputKindVariable)55 lpsrScoreOutputKindAtom::lpsrScoreOutputKindAtom (
56   string               shortName,
57   string               longName,
58   string               description,
59   string               valueSpecification,
60   string               variableName,
61   lpsrScoreOutputKind& lpsrScoreOutputKindVariable)
62   : oahValuedAtom (
63       shortName,
64       longName,
65       description,
66       valueSpecification,
67       variableName),
68     fLpsrScoreOutputKindVariable (
69       lpsrScoreOutputKindVariable)
70 {}
71 
~lpsrScoreOutputKindAtom()72 lpsrScoreOutputKindAtom::~lpsrScoreOutputKindAtom ()
73 {}
74 
handleOptionUnderName(string optionName,ostream & os)75 S_oahValuedAtom lpsrScoreOutputKindAtom::handleOptionUnderName (
76   string   optionName,
77   ostream& os)
78 {
79 #ifdef TRACE_OAH
80   if (gTraceOah->fTraceOah) {
81     gLogOstream <<
82       "==> option '" << optionName << "' is a lpsrScoreOutputKindAtom" <<
83       endl;
84   }
85 #endif
86 
87   // an option value is needed
88   return this;
89 }
90 
handleValue(string theString,ostream & os)91 void lpsrScoreOutputKindAtom::handleValue (
92   string   theString,
93   ostream& os)
94 {
95 #ifdef TRACE_OAH
96   if (gTraceOah->fTraceOah) {
97     os <<
98       "==> oahAtom is of type 'lpsrScoreOutputKindAtom'" <<
99       endl;
100   }
101 #endif
102 
103   // theString contains the score output kind:
104   // is it in the score output kinds map?
105 
106 #ifdef TRACE_OAH
107   if (gTraceOah->fTraceOah) {
108     os <<
109       "==> oahAtom is of type 'lpsrScoreOutputKindAtom'" <<
110       endl;
111   }
112 #endif
113 
114   map<string, lpsrScoreOutputKind>::const_iterator
115     it =
116       gLpsrScoreOutputKindsMap.find (
117         theString);
118 
119   if (it == gLpsrScoreOutputKindsMap.end ()) {
120     // no, score output kind is unknown in the map
121 
122     stringstream s;
123 
124     s <<
125       "LPSR score output kind '" << theString <<
126       "' is unknown" <<
127       endl <<
128       "The " <<
129       gLpsrScoreOutputKindsMap.size () <<
130       " known LPSR score output kinds are:" <<
131       endl;
132 
133     gIndenter++;
134 
135     s <<
136       existingLpsrScoreOutputKinds (K_NAMES_LIST_MAX_LENGTH);
137 
138     gIndenter--;
139 
140     oahError (s.str ());
141   }
142 
143   setLpsrScoreOutputKindVariable (
144     (*it).second);
145 }
146 
acceptIn(basevisitor * v)147 void lpsrScoreOutputKindAtom::acceptIn (basevisitor* v)
148 {
149 #ifdef TRACE_OAH
150   if (gOahOah->fTraceOahVisitors) {
151     gLogOstream <<
152       ".\\\" ==> lpsrScoreOutputKindAtom::acceptIn ()" <<
153       endl;
154   }
155 #endif
156 
157   if (visitor<S_lpsrScoreOutputKindAtom>*
158     p =
159       dynamic_cast<visitor<S_lpsrScoreOutputKindAtom>*> (v)) {
160         S_lpsrScoreOutputKindAtom elem = this;
161 
162 #ifdef TRACE_OAH
163         if (gOahOah->fTraceOahVisitors) {
164           gLogOstream <<
165             ".\\\" ==> Launching lpsrScoreOutputKindAtom::visitStart ()" <<
166             endl;
167         }
168 #endif
169         p->visitStart (elem);
170   }
171 }
172 
acceptOut(basevisitor * v)173 void lpsrScoreOutputKindAtom::acceptOut (basevisitor* v)
174 {
175 #ifdef TRACE_OAH
176   if (gOahOah->fTraceOahVisitors) {
177     gLogOstream <<
178       ".\\\" ==> lpsrScoreOutputKindAtom::acceptOut ()" <<
179       endl;
180   }
181 #endif
182 
183   if (visitor<S_lpsrScoreOutputKindAtom>*
184     p =
185       dynamic_cast<visitor<S_lpsrScoreOutputKindAtom>*> (v)) {
186         S_lpsrScoreOutputKindAtom elem = this;
187 
188 #ifdef TRACE_OAH
189         if (gOahOah->fTraceOahVisitors) {
190           gLogOstream <<
191             ".\\\" ==> Launching lpsrScoreOutputKindAtom::visitEnd ()" <<
192             endl;
193         }
194 #endif
195         p->visitEnd (elem);
196   }
197 }
198 
browseData(basevisitor * v)199 void lpsrScoreOutputKindAtom::browseData (basevisitor* v)
200 {
201 #ifdef TRACE_OAH
202   if (gOahOah->fTraceOahVisitors) {
203     gLogOstream <<
204       ".\\\" ==> lpsrScoreOutputKindAtom::browseData ()" <<
205       endl;
206   }
207 #endif
208 }
209 
asShortNamedOptionString() const210 string lpsrScoreOutputKindAtom::asShortNamedOptionString () const
211 {
212   stringstream s;
213 
214   s <<
215     "-" << fShortName << " " <<
216     lpsrScoreOutputKindAsString (fLpsrScoreOutputKindVariable);
217 
218   return s.str ();
219 }
220 
asActualLongNamedOptionString() const221 string lpsrScoreOutputKindAtom::asActualLongNamedOptionString () const
222 {
223   stringstream s;
224 
225   s <<
226     "-" << fLongName << " " <<
227     lpsrScoreOutputKindAsString (fLpsrScoreOutputKindVariable);
228 
229   return s.str ();
230 }
231 
print(ostream & os) const232 void lpsrScoreOutputKindAtom::print (ostream& os) const
233 {
234   const int fieldWidth = K_OAH_FIELD_WIDTH;
235 
236   os <<
237     "OptionsLpsrScoreOutputKindAtom:" <<
238     endl;
239 
240   gIndenter++;
241 
242   printValuedAtomEssentials (
243     os, fieldWidth);
244 
245   os << left <<
246     setw (fieldWidth) <<
247     "fVariableName" << " : " <<
248     fVariableName <<
249     endl <<
250     setw (fieldWidth) <<
251     "fOptionsLpsrScoreOutputKindVariable" << " : \"" <<
252     lpsrScoreOutputKindAsString (
253       fLpsrScoreOutputKindVariable) <<
254     "\"" <<
255     endl;
256 }
257 
printAtomOptionsValues(ostream & os,int valueFieldWidth) const258 void lpsrScoreOutputKindAtom::printAtomOptionsValues (
259   ostream& os,
260   int      valueFieldWidth) const
261 {
262   os << left <<
263     setw (valueFieldWidth) <<
264     fVariableName <<
265     " : \"" <<
266     lpsrScoreOutputKindAsString (
267       fLpsrScoreOutputKindVariable) <<
268     "\"" <<
269     endl;
270 }
271 
operator <<(ostream & os,const S_lpsrScoreOutputKindAtom & elt)272 ostream& operator<< (ostream& os, const S_lpsrScoreOutputKindAtom& elt)
273 {
274   elt->print (os);
275   return os;
276 }
277 
278 //______________________________________________________________________________
create(string shortName,string longName,string description,string valueSpecification,string variableName,msrQuarterTonesPitchesLanguageKind & lpsrPitchesLanguageKindVariable)279 S_lpsrPitchesLanguageAtom lpsrPitchesLanguageAtom::create (
280   string             shortName,
281   string             longName,
282   string             description,
283   string             valueSpecification,
284   string             variableName,
285   msrQuarterTonesPitchesLanguageKind&
286                      lpsrPitchesLanguageKindVariable)
287 {
288   lpsrPitchesLanguageAtom* o = new
289     lpsrPitchesLanguageAtom (
290       shortName,
291       longName,
292       description,
293       valueSpecification,
294       variableName,
295       lpsrPitchesLanguageKindVariable);
296   assert(o!=0);
297   return o;
298 }
299 
lpsrPitchesLanguageAtom(string shortName,string longName,string description,string valueSpecification,string variableName,msrQuarterTonesPitchesLanguageKind & lpsrPitchesLanguageKindVariable)300 lpsrPitchesLanguageAtom::lpsrPitchesLanguageAtom (
301   string             shortName,
302   string             longName,
303   string             description,
304   string             valueSpecification,
305   string             variableName,
306   msrQuarterTonesPitchesLanguageKind&
307                      lpsrPitchesLanguageKindVariable)
308   : oahValuedAtom (
309       shortName,
310       longName,
311       description,
312       valueSpecification,
313       variableName),
314     fMsrQuarterTonesPitchesLanguageKindVariable (
315       lpsrPitchesLanguageKindVariable)
316 {}
317 
~lpsrPitchesLanguageAtom()318 lpsrPitchesLanguageAtom::~lpsrPitchesLanguageAtom ()
319 {}
320 
handleOptionUnderName(string optionName,ostream & os)321 S_oahValuedAtom lpsrPitchesLanguageAtom::handleOptionUnderName (
322   string   optionName,
323   ostream& os)
324 {
325 #ifdef TRACE_OAH
326   if (gTraceOah->fTraceOah) {
327     gLogOstream <<
328       "==> option '" << optionName << "' is a lpsrPitchesLanguageAtom" <<
329       endl;
330   }
331 #endif
332 
333   // an option value is needed
334   return this;
335 }
336 
handleValue(string theString,ostream & os)337 void lpsrPitchesLanguageAtom::handleValue (
338   string   theString,
339   ostream& os)
340 {
341 #ifdef TRACE_OAH
342   if (gTraceOah->fTraceOah) {
343     os <<
344       "==> oahAtom is of type 'lpsrPitchesLanguageAtom'" <<
345       endl;
346   }
347 #endif
348 
349   // theString contains the language name:
350   // is it in the pitches languages map?
351 
352 #ifdef TRACE_OAH
353   if (gTraceOah->fTraceOah) {
354     os <<
355       "==> oahAtom is of type 'lpsrPitchesLanguageAtom'" <<
356       endl;
357   }
358 #endif
359 
360   map<string, msrQuarterTonesPitchesLanguageKind>::const_iterator
361     it =
362       gQuarterTonesPitchesLanguageKindsMap.find (
363         theString);
364 
365   if (it == gQuarterTonesPitchesLanguageKindsMap.end ()) {
366     // no, language is unknown in the map
367 
368     stringstream s;
369 
370     s <<
371       "LPSR pitches language '" << theString <<
372       "' is unknown" <<
373       endl <<
374       "The " <<
375       gQuarterTonesPitchesLanguageKindsMap.size () <<
376       " known LPSR pitches languages are:" <<
377       endl;
378 
379     gIndenter++;
380 
381     s <<
382       existingQuarterTonesPitchesLanguageKinds (K_NAMES_LIST_MAX_LENGTH);
383 
384     gIndenter--;
385 
386     oahError (s.str ());
387   }
388 
389   setMsrQuarterTonesPitchesLanguageKindVariable (
390     (*it).second);
391 }
392 
acceptIn(basevisitor * v)393 void lpsrPitchesLanguageAtom::acceptIn (basevisitor* v)
394 {
395 #ifdef TRACE_OAH
396   if (gOahOah->fTraceOahVisitors) {
397     gLogOstream <<
398       ".\\\" ==> lpsrPitchesLanguageAtom::acceptIn ()" <<
399       endl;
400   }
401 #endif
402 
403   if (visitor<S_lpsrPitchesLanguageAtom>*
404     p =
405       dynamic_cast<visitor<S_lpsrPitchesLanguageAtom>*> (v)) {
406         S_lpsrPitchesLanguageAtom elem = this;
407 
408 #ifdef TRACE_OAH
409         if (gOahOah->fTraceOahVisitors) {
410           gLogOstream <<
411             ".\\\" ==> Launching lpsrPitchesLanguageAtom::visitStart ()" <<
412             endl;
413         }
414 #endif
415         p->visitStart (elem);
416   }
417 }
418 
acceptOut(basevisitor * v)419 void lpsrPitchesLanguageAtom::acceptOut (basevisitor* v)
420 {
421 #ifdef TRACE_OAH
422   if (gOahOah->fTraceOahVisitors) {
423     gLogOstream <<
424       ".\\\" ==> lpsrPitchesLanguageAtom::acceptOut ()" <<
425       endl;
426   }
427 #endif
428 
429   if (visitor<S_lpsrPitchesLanguageAtom>*
430     p =
431       dynamic_cast<visitor<S_lpsrPitchesLanguageAtom>*> (v)) {
432         S_lpsrPitchesLanguageAtom elem = this;
433 
434 #ifdef TRACE_OAH
435         if (gOahOah->fTraceOahVisitors) {
436           gLogOstream <<
437             ".\\\" ==> Launching lpsrPitchesLanguageAtom::visitEnd ()" <<
438             endl;
439         }
440 #endif
441         p->visitEnd (elem);
442   }
443 }
444 
browseData(basevisitor * v)445 void lpsrPitchesLanguageAtom::browseData (basevisitor* v)
446 {
447 #ifdef TRACE_OAH
448   if (gOahOah->fTraceOahVisitors) {
449     gLogOstream <<
450       ".\\\" ==> lpsrPitchesLanguageAtom::browseData ()" <<
451       endl;
452   }
453 #endif
454 }
455 
asShortNamedOptionString() const456 string lpsrPitchesLanguageAtom::asShortNamedOptionString () const
457 {
458   stringstream s;
459 
460   s <<
461     "-" << fShortName << " " <<
462     msrQuarterTonesPitchesLanguageKindAsString (
463       fMsrQuarterTonesPitchesLanguageKindVariable);
464 
465   return s.str ();
466 }
467 
asActualLongNamedOptionString() const468 string lpsrPitchesLanguageAtom::asActualLongNamedOptionString () const
469 {
470   stringstream s;
471 
472   s <<
473     "-" << fLongName << " " <<
474     msrQuarterTonesPitchesLanguageKindAsString (
475       fMsrQuarterTonesPitchesLanguageKindVariable);
476 
477   return s.str ();
478 }
479 
print(ostream & os) const480 void lpsrPitchesLanguageAtom::print (ostream& os) const
481 {
482   const int fieldWidth = K_OAH_FIELD_WIDTH;
483 
484   os <<
485     "OptionsLpsrPitchesLanguageAtom:" <<
486     endl;
487 
488   gIndenter++;
489 
490   printValuedAtomEssentials (
491     os, fieldWidth);
492 
493   os << left <<
494     setw (fieldWidth) <<
495     "fVariableName" << " : " <<
496     fVariableName <<
497     endl <<
498     setw (fieldWidth) <<
499     "fOptionsLpsrPitchesLanguageVariable" << " : \"" <<
500     msrQuarterTonesPitchesLanguageKindAsString (
501       fMsrQuarterTonesPitchesLanguageKindVariable) <<
502     "\"" <<
503     endl;
504 }
505 
printAtomOptionsValues(ostream & os,int valueFieldWidth) const506 void lpsrPitchesLanguageAtom::printAtomOptionsValues (
507   ostream& os,
508   int      valueFieldWidth) const
509 {
510   os << left <<
511     setw (valueFieldWidth) <<
512     fVariableName <<
513     " : \"" <<
514     msrQuarterTonesPitchesLanguageKindAsString (
515       fMsrQuarterTonesPitchesLanguageKindVariable) <<
516     "\"" <<
517     endl;
518 }
519 
operator <<(ostream & os,const S_lpsrPitchesLanguageAtom & elt)520 ostream& operator<< (ostream& os, const S_lpsrPitchesLanguageAtom& elt)
521 {
522   elt->print (os);
523   return os;
524 }
525 
526 //______________________________________________________________________________
create(string shortName,string longName,string description,string valueSpecification,string variableName,lpsrChordsLanguageKind & lpsrChordsLanguageKindVariable)527 S_lpsrChordsLanguageAtom lpsrChordsLanguageAtom::create (
528   string             shortName,
529   string             longName,
530   string             description,
531   string             valueSpecification,
532   string             variableName,
533   lpsrChordsLanguageKind&
534                      lpsrChordsLanguageKindVariable)
535 {
536   lpsrChordsLanguageAtom* o = new
537     lpsrChordsLanguageAtom (
538       shortName,
539       longName,
540       description,
541       valueSpecification,
542       variableName,
543       lpsrChordsLanguageKindVariable);
544   assert(o!=0);
545   return o;
546 }
547 
lpsrChordsLanguageAtom(string shortName,string longName,string description,string valueSpecification,string variableName,lpsrChordsLanguageKind & lpsrChordsLanguageKindVariable)548 lpsrChordsLanguageAtom::lpsrChordsLanguageAtom (
549   string             shortName,
550   string             longName,
551   string             description,
552   string             valueSpecification,
553   string             variableName,
554   lpsrChordsLanguageKind&
555                      lpsrChordsLanguageKindVariable)
556   : oahValuedAtom (
557       shortName,
558       longName,
559       description,
560       valueSpecification,
561       variableName),
562     fLpsrChordsLanguageKindVariable (
563       lpsrChordsLanguageKindVariable)
564 {}
565 
~lpsrChordsLanguageAtom()566 lpsrChordsLanguageAtom::~lpsrChordsLanguageAtom ()
567 {}
568 
handleOptionUnderName(string optionName,ostream & os)569 S_oahValuedAtom lpsrChordsLanguageAtom::handleOptionUnderName (
570   string   optionName,
571   ostream& os)
572 {
573 #ifdef TRACE_OAH
574   if (gTraceOah->fTraceOah) {
575     gLogOstream <<
576       "==> option '" << optionName << "' is a lpsrChordsLanguageAtom" <<
577       endl;
578   }
579 #endif
580 
581   // an option value is needed
582   return this;
583 }
584 
handleValue(string theString,ostream & os)585 void lpsrChordsLanguageAtom::handleValue (
586   string   theString,
587   ostream& os)
588 {
589 #ifdef TRACE_OAH
590   if (gTraceOah->fTraceOah) {
591     os <<
592       "==> oahAtom is of type 'lpsrChordsLanguageAtom'" <<
593       endl;
594   }
595 #endif
596 
597   // theString contains the language name:
598   // is it in the chords languages map?
599 
600 #ifdef TRACE_OAH
601   if (gTraceOah->fTraceOah) {
602     os <<
603       "==> oahAtom is of type 'lpsrChordsLanguageAtom'" <<
604       endl;
605   }
606 #endif
607 
608   map<string, lpsrChordsLanguageKind>::const_iterator
609     it =
610       gLpsrChordsLanguageKindsMap.find (theString);
611 
612   if (it == gLpsrChordsLanguageKindsMap.end ()) {
613     // no, language is unknown in the map
614     stringstream s;
615 
616     s <<
617       "LPSR chords language '" << theString <<
618       "' is unknown" <<
619       endl <<
620       "The " <<
621       gLpsrChordsLanguageKindsMap.size () - 1 <<
622       " known LPSR chords languages apart from the default Ignatzek are:" <<
623       endl;
624 
625     gIndenter++;
626 
627     s <<
628       existingLpsrChordsLanguageKinds (K_NAMES_LIST_MAX_LENGTH);
629 
630     gIndenter--;
631 
632     oahError (s.str ());
633   }
634 
635   setLpsrChordsLanguageKindVariable (
636     (*it).second);
637 }
638 
acceptIn(basevisitor * v)639 void lpsrChordsLanguageAtom::acceptIn (basevisitor* v)
640 {
641 #ifdef TRACE_OAH
642   if (gOahOah->fTraceOahVisitors) {
643     gLogOstream <<
644       ".\\\" ==> lpsrChordsLanguageAtom::acceptIn ()" <<
645       endl;
646   }
647 #endif
648 
649   if (visitor<S_lpsrChordsLanguageAtom>*
650     p =
651       dynamic_cast<visitor<S_lpsrChordsLanguageAtom>*> (v)) {
652         S_lpsrChordsLanguageAtom elem = this;
653 
654 #ifdef TRACE_OAH
655         if (gOahOah->fTraceOahVisitors) {
656           gLogOstream <<
657             ".\\\" ==> Launching lpsrChordsLanguageAtom::visitStart ()" <<
658             endl;
659         }
660 #endif
661         p->visitStart (elem);
662   }
663 }
664 
acceptOut(basevisitor * v)665 void lpsrChordsLanguageAtom::acceptOut (basevisitor* v)
666 {
667 #ifdef TRACE_OAH
668   if (gOahOah->fTraceOahVisitors) {
669     gLogOstream <<
670       ".\\\" ==> lpsrChordsLanguageAtom::acceptOut ()" <<
671       endl;
672   }
673 #endif
674 
675   if (visitor<S_lpsrChordsLanguageAtom>*
676     p =
677       dynamic_cast<visitor<S_lpsrChordsLanguageAtom>*> (v)) {
678         S_lpsrChordsLanguageAtom elem = this;
679 
680 #ifdef TRACE_OAH
681         if (gOahOah->fTraceOahVisitors) {
682           gLogOstream <<
683             ".\\\" ==> Launching lpsrChordsLanguageAtom::visitEnd ()" <<
684             endl;
685         }
686 #endif
687         p->visitEnd (elem);
688   }
689 }
690 
browseData(basevisitor * v)691 void lpsrChordsLanguageAtom::browseData (basevisitor* v)
692 {
693 #ifdef TRACE_OAH
694   if (gOahOah->fTraceOahVisitors) {
695     gLogOstream <<
696       ".\\\" ==> lpsrChordsLanguageAtom::browseData ()" <<
697       endl;
698   }
699 #endif
700 }
701 
asShortNamedOptionString() const702 string lpsrChordsLanguageAtom::asShortNamedOptionString () const
703 {
704   stringstream s;
705 
706   s <<
707     "-" << fShortName << " " <<
708     lpsrChordsLanguageKindAsString (fLpsrChordsLanguageKindVariable);
709 
710   return s.str ();
711 }
712 
asActualLongNamedOptionString() const713 string lpsrChordsLanguageAtom::asActualLongNamedOptionString () const
714 {
715   stringstream s;
716 
717   s <<
718     "-" << fLongName << " " <<
719     lpsrChordsLanguageKindAsString (fLpsrChordsLanguageKindVariable);
720 
721   return s.str ();
722 }
723 
print(ostream & os) const724 void lpsrChordsLanguageAtom::print (ostream& os) const
725 {
726   const int fieldWidth = K_OAH_FIELD_WIDTH;
727 
728   os <<
729     "OptionsLpsrChordsLanguageAtom:" <<
730     endl;
731 
732   gIndenter++;
733 
734   printValuedAtomEssentials (
735     os, fieldWidth);
736 
737   os << left <<
738     setw (fieldWidth) <<
739     "fVariableName" << " : " <<
740     fVariableName <<
741     setw (fieldWidth) <<
742     "fLpsrChordsLanguageKindVariable" << " : \"" <<
743     lpsrChordsLanguageKindAsString (
744       fLpsrChordsLanguageKindVariable) <<
745     "\"" <<
746     endl;
747 }
748 
printAtomOptionsValues(ostream & os,int valueFieldWidth) const749 void lpsrChordsLanguageAtom::printAtomOptionsValues (
750   ostream& os,
751   int      valueFieldWidth) const
752 {
753   os << left <<
754     setw (valueFieldWidth) <<
755     fVariableName <<
756     " : \"" <<
757     lpsrChordsLanguageKindAsString (
758       fLpsrChordsLanguageKindVariable) <<
759     "\"" <<
760     endl;
761 }
762 
operator <<(ostream & os,const S_lpsrChordsLanguageAtom & elt)763 ostream& operator<< (ostream& os, const S_lpsrChordsLanguageAtom& elt)
764 {
765   elt->print (os);
766   return os;
767 }
768 
769 //______________________________________________________________________________
create(string shortName,string longName,string description,string valueSpecification,string variableName,S_msrSemiTonesPitchAndOctave & lpsrTransposeVariable)770 S_lpsrTransposeAtom lpsrTransposeAtom::create (
771   string  shortName,
772   string  longName,
773   string  description,
774   string  valueSpecification,
775   string  variableName,
776   S_msrSemiTonesPitchAndOctave&
777           lpsrTransposeVariable)
778 {
779   lpsrTransposeAtom* o = new
780     lpsrTransposeAtom (
781       shortName,
782       longName,
783       description,
784       valueSpecification,
785       variableName,
786       lpsrTransposeVariable);
787   assert(o!=0);
788   return o;
789 }
790 
lpsrTransposeAtom(string shortName,string longName,string description,string valueSpecification,string variableName,S_msrSemiTonesPitchAndOctave & lpsrTransposeVariable)791 lpsrTransposeAtom::lpsrTransposeAtom (
792   string  shortName,
793   string  longName,
794   string  description,
795   string  valueSpecification,
796   string  variableName,
797   S_msrSemiTonesPitchAndOctave&
798           lpsrTransposeVariable)
799   : oahValuedAtom (
800       shortName,
801       longName,
802       description,
803       valueSpecification,
804       variableName),
805     fMsrSemiTonesPitchAndOctaveVariable (
806       lpsrTransposeVariable)
807 {}
808 
~lpsrTransposeAtom()809 lpsrTransposeAtom::~lpsrTransposeAtom ()
810 {}
811 
handleOptionUnderName(string optionName,ostream & os)812 S_oahValuedAtom lpsrTransposeAtom::handleOptionUnderName (
813   string   optionName,
814   ostream& os)
815 {
816 #ifdef TRACE_OAH
817   if (gTraceOah->fTraceOah) {
818     gLogOstream <<
819       "==> option '" << optionName << "' is a lpsrTransposeAtom" <<
820       endl;
821   }
822 #endif
823 
824   // an option value is needed
825   return this;
826 }
827 
handleValue(string theString,ostream & os)828 void lpsrTransposeAtom::handleValue (
829   string   theString,
830   ostream& os)
831 {
832 #ifdef TRACE_OAH
833   if (gTraceOah->fTraceOah) {
834     os <<
835       "==> oahAtom is of type 'lpsrTransposeAtom'" <<
836       endl;
837   }
838 #endif
839 
840   // theString contains the language name:
841   // is it in the chords languages map?
842 
843 #ifdef TRACE_OAH
844   if (gTraceOah->fTraceOah) {
845     os <<
846       "==> oahAtom is of type 'lpsrTransposeAtom'" <<
847       endl;
848   }
849 #endif
850 
851   // create the semitones pitch and octave from theString
852   S_msrSemiTonesPitchAndOctave
853     semiTonesPitchAndOctave =
854       msrSemiTonesPitchAndOctave::createFromString (
855         K_NO_INPUT_LINE_NUMBER,
856         theString);
857 
858   // set the transpose atom variable value
859   setMsrSemiTonesPitchAndOctaveVariable (
860     semiTonesPitchAndOctave);
861 }
862 
acceptIn(basevisitor * v)863 void lpsrTransposeAtom::acceptIn (basevisitor* v)
864 {
865 #ifdef TRACE_OAH
866   if (gOahOah->fTraceOahVisitors) {
867     gLogOstream <<
868       ".\\\" ==> lpsrTransposeAtom::acceptIn ()" <<
869       endl;
870   }
871 #endif
872 
873   if (visitor<S_lpsrTransposeAtom>*
874     p =
875       dynamic_cast<visitor<S_lpsrTransposeAtom>*> (v)) {
876         S_lpsrTransposeAtom elem = this;
877 
878 #ifdef TRACE_OAH
879         if (gOahOah->fTraceOahVisitors) {
880           gLogOstream <<
881             ".\\\" ==> Launching lpsrTransposeAtom::visitStart ()" <<
882             endl;
883         }
884 #endif
885         p->visitStart (elem);
886   }
887 }
888 
acceptOut(basevisitor * v)889 void lpsrTransposeAtom::acceptOut (basevisitor* v)
890 {
891 #ifdef TRACE_OAH
892   if (gOahOah->fTraceOahVisitors) {
893     gLogOstream <<
894       ".\\\" ==> lpsrTransposeAtom::acceptOut ()" <<
895       endl;
896   }
897 #endif
898 
899   if (visitor<S_lpsrTransposeAtom>*
900     p =
901       dynamic_cast<visitor<S_lpsrTransposeAtom>*> (v)) {
902         S_lpsrTransposeAtom elem = this;
903 
904 #ifdef TRACE_OAH
905         if (gOahOah->fTraceOahVisitors) {
906           gLogOstream <<
907             ".\\\" ==> Launching lpsrTransposeAtom::visitEnd ()" <<
908             endl;
909         }
910 #endif
911         p->visitEnd (elem);
912   }
913 }
914 
browseData(basevisitor * v)915 void lpsrTransposeAtom::browseData (basevisitor* v)
916 {
917 #ifdef TRACE_OAH
918   if (gOahOah->fTraceOahVisitors) {
919     gLogOstream <<
920       ".\\\" ==> lpsrTransposeAtom::browseData ()" <<
921       endl;
922   }
923 #endif
924 }
925 
asShortNamedOptionString() const926 string lpsrTransposeAtom::asShortNamedOptionString () const
927 {
928   stringstream s;
929 
930   s <<
931     "-" << fShortName << " " <<
932     fMsrSemiTonesPitchAndOctaveVariable->asString ();
933 
934   return s.str ();
935 }
936 
asActualLongNamedOptionString() const937 string lpsrTransposeAtom::asActualLongNamedOptionString () const
938 {
939   stringstream s;
940 
941   s <<
942     "-" << fLongName << " " <<
943     fMsrSemiTonesPitchAndOctaveVariable->asString ();
944 
945   return s.str ();
946 }
947 
print(ostream & os) const948 void lpsrTransposeAtom::print (ostream& os) const
949 {
950   const int fieldWidth = K_OAH_FIELD_WIDTH;
951 
952   os <<
953     "lpsrTransposeAtom:" <<
954     endl;
955 
956   gIndenter++;
957 
958   oahElement::printOptionEssentials (
959     os, fieldWidth);
960 
961   gIndenter++;
962   os <<
963     gIndenter.indentMultiLineString (
964       fDescription) <<
965     endl;
966   gIndenter--;
967 
968   gIndenter--;
969 }
970 
printAtomOptionsValues(ostream & os,int valueFieldWidth) const971 void lpsrTransposeAtom::printAtomOptionsValues (
972   ostream& os,
973   int      valueFieldWidth) const
974 {
975   os << left <<
976     setw (valueFieldWidth) <<
977     fVariableName <<
978     " : ";
979   if (fMsrSemiTonesPitchAndOctaveVariable) {
980     os << endl;
981     gIndenter++;
982     os <<
983       fMsrSemiTonesPitchAndOctaveVariable;
984     gIndenter--;
985   }
986   else {
987     os <<
988       "none" <<
989       endl;
990   }
991 }
992 
operator <<(ostream & os,const S_lpsrTransposeAtom & elt)993 ostream& operator<< (ostream& os, const S_lpsrTransposeAtom& elt)
994 {
995   elt->print (os);
996   return os;
997 }
998 
999 //_______________________________________________________________________________
1000 S_lpsrOah gLpsrOah;
1001 S_lpsrOah gLpsrOahUserChoices;
1002 S_lpsrOah gLpsrOahWithDetailedTrace;
1003 
create(S_oahHandler handlerUpLink)1004 S_lpsrOah lpsrOah::create (
1005   S_oahHandler handlerUpLink)
1006 {
1007   lpsrOah* o = new lpsrOah (
1008     handlerUpLink);
1009   assert(o!=0);
1010   return o;
1011 }
1012 
lpsrOah(S_oahHandler handlerUpLink)1013 lpsrOah::lpsrOah (
1014   S_oahHandler handlerUpLink)
1015   : oahGroup (
1016     "LPSR",
1017     "hlpsr", "help-lpsr",
1018 R"(These options control the way LPSR data is handled.)",
1019     kElementVisibilityAlways,
1020     handlerUpLink)
1021 {
1022   // append this options group to the options handler
1023   // if relevant
1024   if (handlerUpLink) {
1025     handlerUpLink->
1026       appendGroupToHandler (this);
1027   }
1028 
1029   // initialize it
1030   initializeLpsrOah (false);
1031 }
1032 
~lpsrOah()1033 lpsrOah::~lpsrOah ()
1034 {}
1035 
1036 #ifdef TRACE_OAH
initializeLpsrTraceOah(bool boolOptionsInitialValue)1037 void lpsrOah::initializeLpsrTraceOah (
1038   bool boolOptionsInitialValue)
1039 {
1040   S_oahSubGroup
1041     subGroup =
1042       oahSubGroup::create (
1043         "Trace",
1044         "hlpsrtrace", "help-lpsr-trace",
1045 R"()",
1046       kElementVisibilityAlways,
1047       this);
1048 
1049   appendSubGroupToGroup (subGroup);
1050 
1051   // trace- lpsr
1052 
1053   fTraceLpsr            = boolOptionsInitialValue;
1054 
1055   subGroup->
1056     appendAtomToSubGroup (
1057       oahBooleanAtom::create (
1058         "tlpsr", "trace-lpsr",
1059 R"(Write a trace of the LPSR graphs visiting activity to standard error.)",
1060         "traceLpsr",
1061         fTraceLpsr));
1062 
1063   // trace lilypond version
1064 
1065   fTraceLilypondVersion = boolOptionsInitialValue;
1066 
1067   subGroup->
1068     appendAtomToSubGroup (
1069       oahBooleanAtom::create (
1070         "tlpv", "trace-lilypond-version",
1071 R"(Write a trace of the LilyPond version to standard error.)",
1072         "traceLilypondVersion",
1073         fTraceLilypondVersion));
1074 
1075   // trace lpsr visitors
1076 
1077   fTraceLpsrVisitors    = boolOptionsInitialValue;
1078 
1079   subGroup->
1080     appendAtomToSubGroup (
1081       oahBooleanAtom::create (
1082         "tlpsrv", "trace-lpsr-visitors",
1083 R"(Write a trace of the LPSR graphs visiting activity to standard error.)",
1084         "traceLpsrVisitors",
1085         fTraceLpsrVisitors));
1086 
1087   // trace lpsr blocks
1088 
1089   fTraceLpsrBlocks      = boolOptionsInitialValue;
1090 
1091   subGroup->
1092     appendAtomToSubGroup (
1093       oahBooleanAtom::create (
1094         "tlpsrb", "trace-lpsr-blocks",
1095 R"(Write a trace of the LPSR blocks to standard error.)",
1096         "traceLpsrBlocks",
1097         fTraceLpsrBlocks));
1098 
1099   // trace scheme functions
1100 
1101   fTraceSchemeFunctions = boolOptionsInitialValue;
1102 
1103   subGroup->
1104     appendAtomToSubGroup (
1105       oahBooleanAtom::create (
1106         "tsf", "trace-scheme-functions",
1107 R"(Write a trace of the activity regarding Scheme functions to standard error.)",
1108         "traceSchemeFunctions",
1109         fTraceSchemeFunctions));
1110 }
1111 #endif
1112 
initializeLpsrDisplayOptions(bool boolOptionsInitialValue)1113 void lpsrOah::initializeLpsrDisplayOptions (
1114   bool boolOptionsInitialValue)
1115 {
1116   S_oahSubGroup
1117     subGroup =
1118       oahSubGroup::create (
1119         "Display",
1120         "hlpsrd", "help-lpsr-display",
1121 R"()",
1122       kElementVisibilityAlways,
1123       this);
1124 
1125   appendSubGroupToGroup (subGroup);
1126 
1127   // display LPSR
1128 
1129   fDisplayLpsr = boolOptionsInitialValue;
1130 
1131   subGroup->
1132     appendAtomToSubGroup (
1133       oahBooleanAtom::create (
1134         "dlpsr", "display-lpsr",
1135 R"(Write the contents of the LPSR data to standard error.)",
1136         "displayLpsr",
1137         fDisplayLpsr));
1138 }
1139 
initializeLpsrScoreOutputOptions(bool boolOptionsInitialValue)1140 void lpsrOah::initializeLpsrScoreOutputOptions (
1141   bool boolOptionsInitialValue)
1142 {
1143   S_oahSubGroup
1144     subGroup =
1145       oahSubGroup::create (
1146         "LilyPond score output",
1147         "hlpso", "help-lilypond-score-output",
1148 R"()",
1149       kElementVisibilityAlways,
1150       this);
1151 
1152   appendSubGroupToGroup (subGroup);
1153 
1154   // LilyPond version
1155 
1156   string lilyPondVersionDefaultValue = "2.19.83";
1157 
1158   fLilyPondVersion = lilyPondVersionDefaultValue;
1159 
1160   subGroup->
1161     appendAtomToSubGroup (
1162       oahStringAtom::create (
1163         "lpv", "lilypond-version",
1164         replaceSubstringInString (
1165 R"(Set the LilyPond '\version' to STRING in the LilyPond code.
1166 The default is 'DEFAULT_VALUE'.)",
1167           "DEFAULT_VALUE",
1168           lilyPondVersionDefaultValue),
1169         "STRING",
1170         "lilyPondVersion",
1171         fLilyPondVersion));
1172 
1173   // LPSR score output kind
1174 
1175   const lpsrScoreOutputKind
1176     lpsrScoreOutputKindDefaultValue =
1177       kScoreOnly; // default value
1178 
1179   fScoreOutputKind = lpsrScoreOutputKindDefaultValue;
1180 
1181   subGroup->
1182     appendAtomToSubGroup (
1183       lpsrScoreOutputKindAtom::create (
1184         "lpsok", "lpsr-score-output-kind",
1185         replaceSubstringInString (
1186           replaceSubstringInString (
1187             replaceSubstringInString (
1188 R"(Use OUTPUT_KIND to create the LPSR blocks,
1189 as well as in the generated LilyPond code.
1190 The NUMBER LilyPond output kinds available are:
1191   OUTPUT_KINDS.
1192 '-one-file' means that LilyPond will produce a single file containing all the scores and/or parts.
1193 Otherwise, one file will be generated for each score and/or part.
1194 The default is 'DEFAULT_VALUE'.)",
1195               "NUMBER",
1196               to_string (gLpsrScoreOutputKindsMap.size ())),
1197             "OUTPUT_KINDS",
1198             existingLpsrScoreOutputKinds (K_NAMES_LIST_MAX_LENGTH)),
1199           "DEFAULT_VALUE",
1200           lpsrScoreOutputKindAsString (
1201             lpsrScoreOutputKindDefaultValue)),
1202         "OUTPUT_KIND",
1203         "scoreOutputKind",
1204         fScoreOutputKind));
1205 }
1206 
initializeLpsrGlobalStaffSizeOptions(bool boolOptionsInitialValue)1207 void lpsrOah::initializeLpsrGlobalStaffSizeOptions (
1208   bool boolOptionsInitialValue)
1209 {
1210   S_oahSubGroup
1211     subGroup =
1212       oahSubGroup::create (
1213         "Global staff size",
1214         "hlpsrgss", "help-lpsr-gss",
1215 R"()",
1216       kElementVisibilityAlways,
1217       this);
1218 
1219   appendSubGroupToGroup (subGroup);
1220 
1221   // global staff size
1222 
1223   fStaffGlobalSizeDefaultValue = 20; // LilyPond default
1224   fGlobalStaffSize = fStaffGlobalSizeDefaultValue;
1225 
1226   subGroup->
1227     appendAtomToSubGroup (
1228       oahFloatAtom::create (
1229         "gss", "global-staff-size",
1230         replaceSubstringInString (
1231 R"(Set the LilyPond '#(set-global-staff-size ...)' to FLOAT in the LilyPond code.
1232 FLOAT should be a floating point or integer number.
1233 The default is 'DEFAULT_VALUE'.)",
1234           "DEFAULT_VALUE",
1235           to_string (fStaffGlobalSizeDefaultValue)),
1236         "FLOAT",
1237         "globalStaffSize",
1238         fGlobalStaffSize));
1239 }
1240 
initializeLpsrPaperOptions(bool boolOptionsInitialValue)1241 void lpsrOah::initializeLpsrPaperOptions (
1242   bool boolOptionsInitialValue)
1243 {
1244   S_oahSubGroup
1245     subGroup =
1246       oahSubGroup::create (
1247         "Paper",
1248         "hlpsrpaper", "help-lpsr-paper",
1249 R"()",
1250       kElementVisibilityAlways,
1251       this);
1252 
1253   appendSubGroupToGroup (subGroup);
1254 
1255   // length unit kind
1256 
1257   fLengthUnitKindDefaultValue = kMillimeterUnit; // default value;
1258   fLengthUnitKind = fLengthUnitKindDefaultValue;
1259 
1260   subGroup->
1261     appendAtomToSubGroup (
1262       oahLengthUnitKindAtom::create (
1263         "length-unit", "",
1264         replaceSubstringInString (
1265           replaceSubstringInString (
1266             replaceSubstringInString (
1267 R"(Set the LilyPond length variables unit to UNIT in the forthcoming options.
1268 The NUMBER LilyPond length variables units available are:
1269 LENTGTH_UNITS.
1270 This option should precede options that set paper size and indents
1271 if they don't specify a unit.
1272 The default is 'DEFAULT_VALUE'.)",
1273               "NUMBER",
1274               to_string (gMsrLengthUnitKindsMap.size ())),
1275             "LENTGTH_UNITS",
1276             gIndenter.indentMultiLineString (
1277               existingMsrLengthUnitKinds (K_NAMES_LIST_MAX_LENGTH))),
1278           "DEFAULT_VALUE",
1279           msrLengthUnitKindAsString (
1280             fLengthUnitKindDefaultValue)),
1281         "UNIT",
1282         "lengthUnitKind",
1283         fLengthUnitKind));
1284 
1285   // paper height
1286 
1287   fPaperHeight.setLengthUnitKind (kMillimeterUnit);
1288   fPaperHeight.setLengthValue (297);
1289 
1290   subGroup->
1291     appendAtomToSubGroup (
1292       oahLengthAtom::create (
1293         "paper-height", "",
1294 R"(Set the LilyPond 'paper-height' paper variable to HEIGHT in the LilyPond code.
1295 HEIGHT should be a positive floating point or integer number,
1296 immediately followed by a unit name, i.e. 'in', 'mm' or 'cm'.
1297 The default value is 210 mm (A4 format).)",
1298         "HEIGHT",
1299         "paperHeight",
1300         fPaperHeight));
1301 
1302   // paper width
1303 
1304   fPaperWidth.setLengthUnitKind (kMillimeterUnit);
1305   fPaperWidth.setLengthValue (210);
1306 
1307   subGroup->
1308     appendAtomToSubGroup (
1309       oahLengthAtom::create (
1310         "paper-width", "",
1311 R"(Set the LilyPond 'paper-width' paper variable to WIDTH in the LilyPond code.
1312 WIDTH should be a positive floating point or integer number,
1313 immediately followed by a unit name, i.e. 'in', 'mm' or 'cm'.
1314 The default value is 297 mm (A4 format).)",
1315         "WIDTH",
1316         "paperWidth",
1317         fPaperWidth));
1318 
1319   // fPaperHorizontalShift is 0.0 mm by default
1320 
1321   subGroup->
1322     appendAtomToSubGroup (
1323       oahLengthAtom::create (
1324         "hshift", "horizontal-shift",
1325 R"(Set the LilyPond 'horizontal-shift' paper variable to SHIFT in the LilyPond code.
1326 SHIFT should be a floating point or integer number,
1327 immediately followed by a unit name, i.e. 'in', 'mm' or 'cm'.
1328 The default value is 0.0 mm.)",
1329         "SHIFT",
1330         "paperHorizontalShift",
1331         fPaperHorizontalShift));
1332 
1333   // fPaperIndent is 0.0 mm by default
1334 
1335   subGroup->
1336     appendAtomToSubGroup (
1337       oahLengthAtom::create (
1338         "indent", "",
1339 R"(Set the LilyPond 'indent' paper variable to INDENT in the LilyPond code.
1340 INDENT should be a floating point or integer number,
1341 immediately followed by a unit name, i.e. 'in', 'mm' or 'cm'.
1342 The default value is 0.0 mm.)",
1343         "INDENT",
1344         "paperIndent",
1345         fPaperIndent));
1346 
1347   // short indent
1348 
1349   // fPaperShortIndent is 0.0 mm by default
1350 
1351   subGroup->
1352     appendAtomToSubGroup (
1353       oahLengthAtom::create (
1354         "short-indent", "",
1355 R"(Set the LilyPond 'short-indent' paper variable to SHORT_INDENT in the LilyPond code.
1356 SHORT_INDENT should be a floating point or integer number,
1357 immediately followed by a unit name, i.e. 'in', 'mm' or 'cm'.
1358 The default value is 0.0 mm.)",
1359         "SHORT_INDENT",
1360         "paperShortIndent",
1361         fPaperShortIndent));
1362 
1363   // fMarkupSystemSpacingPadding is 0.0 mm by default
1364 
1365   subGroup->
1366     appendAtomToSubGroup (
1367       oahLengthAtom::create (
1368         "mssp", "markup-system-spacing.padding",
1369 R"(Set the LilyPond 'markup-system-spacing.padding' paper variable to PADDING in the LilyPond code.
1370 PADDING should be a floating point or integer number,
1371 immediately followed by a unit name, i.e. 'in', 'mm' or 'cm'.
1372 LilyPond's default value is 0.0 mm.)",
1373         "INDENT",
1374         "markupSystemSpacingPadding",
1375         fMarkupSystemSpacingPadding));
1376 
1377   // ragged bottom
1378 
1379   fRaggedBottom = boolOptionsInitialValue;
1380 
1381   subGroup->
1382     appendAtomToSubGroup (
1383       oahBooleanAtom::create (
1384         "ragged-bottom", "",
1385 R"(Set the LilyPond 'ragged-bottom' paper variable to '##f' in the LilyPond code.
1386 LilyPond's default value is '##t'.)",
1387         "raggedBottom",
1388         fRaggedBottom));
1389 
1390   // ragged last bottom
1391 
1392   fRaggedLastBottom = boolOptionsInitialValue;
1393 
1394   subGroup->
1395     appendAtomToSubGroup (
1396       oahBooleanAtom::create (
1397         "ragged-last-bottom", "",
1398 R"(Set the LilyPond 'ragged-last-bottom' paper variable to '##f' in the LilyPond code.
1399 LilyPond's default value is '##t'.)",
1400         "raggedLastBottom",
1401         fRaggedLastBottom));
1402 
1403 /* LPSR or LilyPond option?"
1404   // tagline
1405 
1406   fTagline = boolOptionsInitialValue;
1407 
1408   subGroup->
1409     appendAtomToSubGroup (
1410       oahBooleanAtom::create (
1411         "tagline", "",
1412 R"(Set the LilyPond 'tagline' paper variable to '##f' in the LilyPond code.
1413 LilyPond's default value is '##t'.)",
1414         "tagline",
1415         fTagline));
1416 */
1417 
1418   // page count
1419 
1420   fPageCount = -1;
1421 
1422   subGroup->
1423     appendAtomToSubGroup (
1424       oahIntegerAtom::create (
1425         "page-count", "",
1426 R"(Set the LilyPond 'page-count' paper variable to PAGE_COUNT in the LilyPond code.
1427 PAGE_COUNT should be a positive integer.
1428 By default, this is left to LilyPond'.)",
1429         "PAGE_COUNT",
1430         "pageCount",
1431         fPageCount));
1432 
1433   // system count
1434 
1435   fSystemCount = -1;
1436 
1437   subGroup->
1438     appendAtomToSubGroup (
1439       oahIntegerAtom::create (
1440         "system-count", "",
1441 R"(Set the LilyPond 'system-count' paper variable to SYSTEM_COUNT in the LilyPond code.
1442 SYSTEM_COUNT should be a positive integer.
1443 By default, this is left to LilyPond'.)",
1444         "SYSTEM_COUNT",
1445         "systemCount",
1446         fSystemCount));
1447 }
1448 
initializeLpsrMeasuresOptions(bool boolOptionsInitialValue)1449 void lpsrOah::initializeLpsrMeasuresOptions (
1450   bool boolOptionsInitialValue)
1451 {
1452   S_oahSubGroup
1453     subGroup =
1454       oahSubGroup::create (
1455         "Measures",
1456         "hlpsrmeasures", "help-lpsr-measures",
1457 R"()",
1458       kElementVisibilityAlways,
1459       this);
1460 
1461   appendSubGroupToGroup (subGroup);
1462 
1463   // replicate empty measure
1464 
1465   fReplicateEmptyMeasureNumber = "";
1466   fReplicateEmptyMeasureReplicas = 0;
1467 
1468   subGroup->
1469     appendAtomToSubGroup (
1470       oahStringAndIntegerAtom::create (
1471         "rem", "replicate-empty-measure",
1472 R"###(Replicate an empty mesure, adding empty others according to SPECIFICATION.
1473 SPECIFICATION should be of the form 'MEASURE_NUMBER REPLICATES',
1474 where MEASURE_NUMBER is a string, and REPLICATES is the number
1475 of empty measures to add after measure MEASURE_NUMBER.
1476 MEASURE_NUMBER should be the number of an existing, empty measure,
1477 and REPLICATES should be at least 1, , such as '17 3'.
1478 This comes in handly when MusicXML data obtained by scanning contains
1479 a single empty measure when there were several in the original score.
1480 This option can be used any number of times.)###",
1481         "SPECIFICATION",
1482         "replicateEmptyMeasureNumber",
1483         fReplicateEmptyMeasureNumber,
1484         "replicateEmptyMeasureReplicas",
1485         fReplicateEmptyMeasureReplicas));
1486 }
1487 
initializeLpsrWordsOptions(bool boolOptionsInitialValue)1488 void lpsrOah::initializeLpsrWordsOptions (
1489   bool boolOptionsInitialValue)
1490 {
1491   S_oahSubGroup
1492     subGroup =
1493       oahSubGroup::create (
1494         "Words",
1495         "hlpsrwords", "help-lpsr-words",
1496 R"()",
1497       kElementVisibilityAlways,
1498       this);
1499 
1500   appendSubGroupToGroup (subGroup);
1501 
1502   // convert words to tempo
1503 
1504   fConvertWordsToTempo = boolOptionsInitialValue;
1505 
1506   subGroup->
1507     appendAtomToSubGroup (
1508       oahBooleanAtom::create (
1509         "cwtt", "convert-words-to-tempo",
1510 R"(Convert words to tempo.
1511 This may come in handy when MusicXML data has been obtained from scanned instrumental music images.)",
1512         "convertWordsToTempo",
1513         fConvertWordsToTempo));
1514 
1515   // add words from the lyrics
1516 
1517   fAddWordsFromTheLyrics = boolOptionsInitialValue;
1518 
1519   subGroup->
1520     appendAtomToSubGroup (
1521       oahBooleanAtom::create (
1522         "awftl", "add-words-from-the-lyrics",
1523 R"(Add words with the lyrics contents, keeping the latter untouched.
1524 This may come in handy when MusicXML data has been obtained from scanned images.)",
1525         "addWordsFromTheLyrics",
1526         fAddWordsFromTheLyrics));
1527 
1528   // convert tempos to rehearsal marks
1529 
1530   fConvertTemposToRehearsalMarks = boolOptionsInitialValue;
1531 
1532   subGroup->
1533     appendAtomToSubGroup (
1534       oahBooleanAtom::create (
1535         "cttrm", "convert-tempos-to-rehearsal-marks",
1536 R"(Convert tempos to rehearsal marks.
1537 This may come in handy when MusicXML data has been obtained from scanned instrumental music images.)",
1538         "convertTemposToRehearsalMarks",
1539         fConvertTemposToRehearsalMarks));
1540 
1541   // convert words to rehearsal marks
1542 
1543   fConvertWordsToRehearsalMarks = boolOptionsInitialValue;
1544 
1545   subGroup->
1546     appendAtomToSubGroup (
1547       oahBooleanAtom::create (
1548         "cwtrm", "convert-words-to-rehearsal-marks",
1549 R"(Convert words to rehearsal marks.
1550 This may come in handy when MusicXML data has been obtained from scanned instrumental music images.)",
1551         "convertWordsToRehearsalMarks",
1552         fConvertWordsToRehearsalMarks));
1553 }
1554 
initializeLpsrLanguagesOptions(bool boolOptionsInitialValue)1555 void lpsrOah::initializeLpsrLanguagesOptions (
1556   bool boolOptionsInitialValue)
1557 {
1558   S_oahSubGroup
1559     subGroup =
1560       oahSubGroup::create (
1561         "Languages",
1562         "hlpsrl", "help-lpsr-languages",
1563 R"()",
1564       kElementVisibilityAlways,
1565       this);
1566 
1567   appendSubGroupToGroup (subGroup);
1568 
1569   // lpsr pitches language
1570 
1571   if (! setLpsrQuarterTonesPitchesLanguage ("nederlands")) {
1572     stringstream s;
1573 
1574     s <<
1575       "INTERNAL INITIALIZATION ERROR: "
1576       "LPSR pitches language 'nederlands' is unknown" <<
1577       endl <<
1578       "The " <<
1579       gQuarterTonesPitchesLanguageKindsMap.size () <<
1580       " known LPSR pitches languages are:" <<
1581       endl;
1582 
1583     gIndenter++;
1584 
1585     s <<
1586       existingQuarterTonesPitchesLanguageKinds (K_NAMES_LIST_MAX_LENGTH);
1587 
1588     gIndenter--;
1589 
1590     oahError (s.str ());
1591   }
1592 
1593   const msrQuarterTonesPitchesLanguageKind
1594     msrQuarterTonesPitchesLanguageKindDefaultValue =
1595       fLpsrQuarterTonesPitchesLanguageKind;
1596 
1597   fLpsrQuarterTonesPitchesLanguageKind =
1598     msrQuarterTonesPitchesLanguageKindDefaultValue;
1599 
1600   subGroup->
1601     appendAtomToSubGroup (
1602       lpsrPitchesLanguageAtom::create (
1603         "lppl", "lpsr-pitches-language",
1604         replaceSubstringInString (
1605           replaceSubstringInString (
1606             replaceSubstringInString (
1607 R"(Use LANGUAGE to display note pitches in the LPSR logs and views,
1608 as well as in the generated LilyPond code.
1609 The NUMBER LilyPond pitches languages available are:
1610 PITCHES_LANGUAGES.
1611 The default is 'DEFAULT_VALUE'.)",
1612               "NUMBER",
1613               to_string (gQuarterTonesPitchesLanguageKindsMap.size ())),
1614             "PITCHES_LANGUAGES",
1615             gIndenter.indentMultiLineString (
1616               existingQuarterTonesPitchesLanguageKinds (K_NAMES_LIST_MAX_LENGTH))),
1617           "DEFAULT_VALUE",
1618           msrQuarterTonesPitchesLanguageKindAsString (
1619             msrQuarterTonesPitchesLanguageKindDefaultValue)),
1620         "LANGUAGE",
1621         "lpsrPitchesLanguage",
1622         fLpsrQuarterTonesPitchesLanguageKind));
1623 
1624   // lpsr chords language
1625 
1626   const lpsrChordsLanguageKind
1627     lpsrChordsLanguageKindDefaultValue =
1628       k_IgnatzekChords; // LilyPond default
1629 
1630   fLpsrChordsLanguageKind =
1631     lpsrChordsLanguageKindDefaultValue;
1632 
1633   subGroup->
1634     appendAtomToSubGroup (
1635       lpsrChordsLanguageAtom::create (
1636         "lpcl", "lpsr-chords-language",
1637         replaceSubstringInString (
1638           replaceSubstringInString (
1639             replaceSubstringInString (
1640 R"(Use LANGUAGE to display chord names, their root and bass notes,
1641 in the LPSR logs and views and the generated LilyPond code.
1642 The NUMBER LilyPond pitches languages available are:
1643 CHORDS_LANGUAGES.
1644 'ignatzek' is Ignatzek's jazz-like, english naming used by LilyPond by default.
1645 The default is 'DEFAULT_VALUE'.)",
1646               "NUMBER",
1647               to_string (gLpsrChordsLanguageKindsMap.size ())),
1648             "CHORDS_LANGUAGES",
1649             gIndenter.indentMultiLineString (
1650               existingLpsrChordsLanguageKinds (K_NAMES_LIST_MAX_LENGTH))),
1651           "DEFAULT_VALUE",
1652           lpsrChordsLanguageKindAsString (
1653             lpsrChordsLanguageKindDefaultValue)),
1654         "LANGUAGE",
1655         "lpsr-chords-language",
1656         fLpsrChordsLanguageKind));
1657 }
1658 
initializeLpsrTransposeOptions(bool boolOptionsInitialValue)1659 void lpsrOah::initializeLpsrTransposeOptions (
1660   bool boolOptionsInitialValue)
1661 {
1662   S_oahSubGroup
1663     subGroup =
1664       oahSubGroup::create (
1665         "Transpose",
1666         "hlpsrt", "help-lpsr-transpose",
1667 R"()",
1668       kElementVisibilityAlways,
1669       this);
1670 
1671   appendSubGroupToGroup (subGroup);
1672 
1673   // lpsr transpose
1674 
1675   subGroup->
1676     appendAtomToSubGroup (
1677       lpsrTransposeAtom::create (
1678         "lpt", "lpsr-transpose",
1679 R"(Use TRANSPOSITION to tranpose in the LPSR data,
1680 thus as in the generated LilyPond code as well.
1681 TRANSPOSITION should contain a diatonic pitch, followed if needed
1682 by a sequence of ',' or '\'' octave indications.
1683 Such indications cannot be mixed.
1684 For example, 'a', 'f' and 'bes,' can be used respectively
1685 for instruments in 'a', 'f' and B flat respectively)",
1686         "TRANSPOSITION",
1687         "lpsrTranspose",
1688         fTransposeSemiTonesPitchAndOctave));
1689 }
1690 
initializeLpsrExitAfterSomePassesOptions(bool boolOptionsInitialValue)1691 void lpsrOah::initializeLpsrExitAfterSomePassesOptions (
1692   bool boolOptionsInitialValue)
1693 {
1694   S_oahSubGroup
1695     subGroup =
1696       oahSubGroup::create (
1697         "Exit after some passes",
1698         "hlexit", "help-lpsr-exit",
1699 R"()",
1700       kElementVisibilityAlways,
1701       this);
1702 
1703   appendSubGroupToGroup (subGroup);
1704 
1705   // exit after pass 3
1706 
1707   fExit3 = boolOptionsInitialValue;
1708 
1709   S_oahBooleanAtom
1710     exit3OahBooleanAtom =
1711       oahBooleanAtom::create (
1712         "e3", "exit-3",
1713 R"(Exit after pass 3, i.e. after conversion
1714 of the MSR to LPSR.)",
1715         "exit3",
1716         fExit3);
1717 
1718   subGroup->
1719     appendAtomToSubGroup (
1720       exit3OahBooleanAtom);
1721 }
1722 
initializeLpsrOah(bool boolOptionsInitialValue)1723 void lpsrOah::initializeLpsrOah (
1724   bool boolOptionsInitialValue)
1725 {
1726 #ifdef TRACE_OAH
1727   // trace and display
1728   // --------------------------------------
1729   initializeLpsrTraceOah (
1730     boolOptionsInitialValue);
1731 #endif
1732 
1733   // display
1734   // --------------------------------------
1735   initializeLpsrDisplayOptions (
1736     boolOptionsInitialValue);
1737 
1738   // LilyPond score output
1739   // --------------------------------------
1740   initializeLpsrScoreOutputOptions (
1741     boolOptionsInitialValue);
1742 
1743   // global staff size
1744   // --------------------------------------
1745   initializeLpsrGlobalStaffSizeOptions (
1746     boolOptionsInitialValue);
1747 
1748   // paper
1749   // --------------------------------------
1750   initializeLpsrPaperOptions (
1751     boolOptionsInitialValue);
1752 
1753   // measures
1754   // --------------------------------------
1755   initializeLpsrMeasuresOptions (
1756     boolOptionsInitialValue);
1757 
1758   // words
1759   // --------------------------------------
1760   initializeLpsrWordsOptions (
1761     boolOptionsInitialValue);
1762 
1763   // languages
1764   // --------------------------------------
1765   initializeLpsrLanguagesOptions (
1766     boolOptionsInitialValue);
1767 
1768   // transpose
1769   // --------------------------------------
1770   initializeLpsrTransposeOptions (
1771     boolOptionsInitialValue);
1772 
1773   // exit after some passes
1774   // --------------------------------------
1775   initializeLpsrExitAfterSomePassesOptions (
1776     boolOptionsInitialValue);
1777 }
1778 
createCloneWithDetailedTrace()1779 S_lpsrOah lpsrOah::createCloneWithDetailedTrace ()
1780 {
1781   S_lpsrOah
1782     clone =
1783       lpsrOah::create (0);
1784       // 0 not to have it inserted twice in the option handler
1785 
1786   // set the options handler upLink
1787   clone->fHandlerUpLink =
1788     fHandlerUpLink;
1789 
1790   // trace
1791   // --------------------------------------
1792 
1793 #ifdef TRACE_OAH
1794   clone->fTraceLpsr =
1795     true;
1796 
1797   clone->fTraceLilypondVersion =
1798     true;
1799 
1800   clone->fTraceLpsrVisitors =
1801     true;
1802 
1803   clone->fTraceLpsrBlocks =
1804     true;
1805 
1806   clone->fTraceSchemeFunctions =
1807     true;
1808 #endif
1809 
1810   // display
1811   // --------------------------------------
1812 
1813   clone->fDisplayLpsr =
1814     true;
1815 
1816   // LilyPond version
1817   // --------------------------------------
1818 
1819   clone->fLilyPondVersion =
1820     fLilyPondVersion;
1821 
1822   // LilyPond output kind
1823   // --------------------------------------
1824 
1825   clone->fScoreOutputKind =
1826     fScoreOutputKind;
1827 
1828   // global staff size
1829   // --------------------------------------
1830 
1831   clone->fGlobalStaffSize =
1832     fGlobalStaffSize;
1833 
1834   // paper
1835   // --------------------------------------
1836 
1837   clone->fLengthUnitKind =
1838     fLengthUnitKind;
1839   clone->fLengthUnitKindDefaultValue =
1840     fLengthUnitKindDefaultValue;
1841 
1842   clone->fPaperHeight =
1843     fPaperHeight;
1844   clone->fPaperWidth =
1845     fPaperWidth;
1846 
1847   clone->fPaperIndent =
1848     fPaperIndent;
1849   clone->fPaperShortIndent =
1850     fPaperShortIndent;
1851 
1852   clone->fMarkupSystemSpacingPadding =
1853     fMarkupSystemSpacingPadding;
1854 
1855   clone->fRaggedBottom =
1856     fRaggedBottom;
1857   clone->fRaggedLastBottom =
1858     fRaggedLastBottom;
1859 
1860   clone->fTagline =
1861     fTagline;
1862 
1863   clone->fPageCount =
1864     fPageCount;
1865   clone->fSystemCount =
1866     fSystemCount;
1867 
1868   // measures
1869   // --------------------------------------
1870 
1871   clone->fReplicateEmptyMeasureNumber =
1872     fReplicateEmptyMeasureNumber;
1873   clone->fReplicateEmptyMeasureReplicas =
1874     fReplicateEmptyMeasureReplicas;
1875 
1876   clone->fAddEmptyMeasuresStringToIntMap =
1877     fAddEmptyMeasuresStringToIntMap;
1878 
1879   // words
1880   // --------------------------------------
1881 
1882   clone->fConvertWordsToTempo =
1883     true;
1884   clone->fAddWordsFromTheLyrics =
1885     true;
1886 
1887   // rehearsal marks
1888   clone->fConvertTemposToRehearsalMarks =
1889     true;
1890   clone->fConvertWordsToRehearsalMarks =
1891     true;
1892 
1893   // languages
1894   // --------------------------------------
1895 
1896   clone->fLpsrQuarterTonesPitchesLanguageKind =
1897     fLpsrQuarterTonesPitchesLanguageKind;
1898 
1899   clone->fLpsrChordsLanguageKind =
1900     fLpsrChordsLanguageKind;
1901 
1902   // transpose
1903   // --------------------------------------
1904 
1905   clone->fTransposeSemiTonesPitchAndOctave =
1906     fTransposeSemiTonesPitchAndOctave;
1907 
1908   return clone;
1909 }
1910 
1911 //______________________________________________________________________________
setLpsrQuarterTonesPitchesLanguage(string language)1912 bool lpsrOah::setLpsrQuarterTonesPitchesLanguage (string language)
1913 {
1914   // is language in the note names languages map?
1915   map<string, msrQuarterTonesPitchesLanguageKind>::const_iterator
1916     it =
1917       gQuarterTonesPitchesLanguageKindsMap.find (language);
1918 
1919   if (it == gQuarterTonesPitchesLanguageKindsMap.end ()) {
1920     // no, language is unknown in the map
1921     return false;
1922   }
1923 
1924   fLpsrQuarterTonesPitchesLanguageKind = (*it).second;
1925 
1926   return true;
1927 }
1928 
1929 //______________________________________________________________________________
setLpsrChordsLanguage(string language)1930 bool lpsrOah::setLpsrChordsLanguage (string language)
1931 {
1932   // is language in the chords languages map?
1933   map<string, lpsrChordsLanguageKind>::const_iterator
1934     it =
1935       gLpsrChordsLanguageKindsMap.find (language);
1936 
1937   if (it == gLpsrChordsLanguageKindsMap.end ()) {
1938     // no, language is unknown in the map
1939     return false;
1940   }
1941 
1942   fLpsrChordsLanguageKind = (*it).second;
1943 
1944   return true;
1945 }
1946 
1947 //______________________________________________________________________________
enforceQuietness()1948 void lpsrOah::enforceQuietness ()
1949 {
1950 #ifdef TRACE_OAH
1951   fTraceLpsr = false;
1952   fTraceLilypondVersion = false;
1953   fTraceLpsrVisitors = false;
1954   fTraceLpsrBlocks = false;
1955   fTraceSchemeFunctions = false;
1956 #endif
1957 
1958   fDisplayLpsr = false;
1959 }
1960 
1961 //______________________________________________________________________________
checkOptionsConsistency()1962 void lpsrOah::checkOptionsConsistency ()
1963 {
1964   // JMI
1965 }
1966 
1967 //______________________________________________________________________________
acceptIn(basevisitor * v)1968 void lpsrOah::acceptIn (basevisitor* v)
1969 {
1970 #ifdef TRACE_OAH
1971   if (gOahOah->fTraceOahVisitors) {
1972     gLogOstream <<
1973       ".\\\" ==> lpsrOah::acceptIn ()" <<
1974       endl;
1975   }
1976 #endif
1977 
1978   if (visitor<S_lpsrOah>*
1979     p =
1980       dynamic_cast<visitor<S_lpsrOah>*> (v)) {
1981         S_lpsrOah elem = this;
1982 
1983 #ifdef TRACE_OAH
1984         if (gOahOah->fTraceOahVisitors) {
1985           gLogOstream <<
1986             ".\\\" ==> Launching lpsrOah::visitStart ()" <<
1987             endl;
1988         }
1989 #endif
1990         p->visitStart (elem);
1991   }
1992 }
1993 
acceptOut(basevisitor * v)1994 void lpsrOah::acceptOut (basevisitor* v)
1995 {
1996 #ifdef TRACE_OAH
1997   if (gOahOah->fTraceOahVisitors) {
1998     gLogOstream <<
1999       ".\\\" ==> lpsrOah::acceptOut ()" <<
2000       endl;
2001   }
2002 #endif
2003 
2004   if (visitor<S_lpsrOah>*
2005     p =
2006       dynamic_cast<visitor<S_lpsrOah>*> (v)) {
2007         S_lpsrOah elem = this;
2008 
2009 #ifdef TRACE_OAH
2010         if (gOahOah->fTraceOahVisitors) {
2011           gLogOstream <<
2012             ".\\\" ==> Launching lpsrOah::visitEnd ()" <<
2013             endl;
2014         }
2015 #endif
2016         p->visitEnd (elem);
2017   }
2018 }
2019 
browseData(basevisitor * v)2020 void lpsrOah::browseData (basevisitor* v)
2021 {
2022 #ifdef TRACE_OAH
2023   if (gOahOah->fTraceOahVisitors) {
2024     gLogOstream <<
2025       ".\\\" ==> lpsrOah::browseData ()" <<
2026       endl;
2027   }
2028 #endif
2029 }
2030 
2031 //______________________________________________________________________________
printLpsrOahValues(int fieldWidth)2032 void lpsrOah::printLpsrOahValues (int fieldWidth)
2033 {
2034   gLogOstream <<
2035     "The LPSR options are:" <<
2036     endl;
2037 
2038   gIndenter++;
2039 
2040 #ifdef TRACE_OAH
2041   // trace
2042   // --------------------------------------
2043   gLogOstream <<
2044     "Trace:" <<
2045     endl;
2046 
2047   gIndenter++;
2048 
2049   gLogOstream << left <<
2050     setw (fieldWidth) << "traceLpsr" << " : " <<
2051     booleanAsString (fTraceLpsr) <<
2052     endl <<
2053 
2054     setw (fieldWidth) << "traceLilypondVersion" << " : " <<
2055     booleanAsString (fTraceLilypondVersion) <<
2056     endl <<
2057 
2058     setw (fieldWidth) << "traceLpsrVisitors" << " : " <<
2059     booleanAsString (fTraceLpsrVisitors) <<
2060     endl <<
2061 
2062     setw (fieldWidth) << "traceLpsrBlocks" << " : " <<
2063     booleanAsString (fTraceLpsrBlocks) <<
2064     endl <<
2065 
2066     setw (fieldWidth) << "traceSchemeFunctions" << " : " <<
2067     booleanAsString (fTraceSchemeFunctions) <<
2068     endl;
2069 
2070   gIndenter--;
2071 #endif
2072 
2073   // display
2074   // --------------------------------------
2075   gLogOstream <<
2076     "Display:" <<
2077     endl;
2078 
2079   gIndenter++;
2080 
2081   gLogOstream << left <<
2082     setw (fieldWidth) << "displayLpsr" << " : " <<
2083     booleanAsString (fDisplayLpsr) <<
2084     endl;
2085 
2086   gIndenter--;
2087 
2088   // LilyPond version
2089   // --------------------------------------
2090 
2091   gLogOstream <<
2092     "LilyPond version:" <<
2093     endl;
2094 
2095   gIndenter++;
2096 
2097   gLogOstream << left <<
2098     setw (fieldWidth) << "lilyPondVersion" << " : " <<
2099     fLilyPondVersion <<
2100     endl;
2101 
2102   gIndenter--;
2103 
2104   // LilyPond output kind
2105   // --------------------------------------
2106 
2107   gLogOstream <<
2108     "LilyPond output kind:" <<
2109     endl;
2110 
2111   gIndenter++;
2112 
2113   gLogOstream << left <<
2114     setw (fieldWidth) << "scoreOutputKind" << " : " <<
2115     lpsrScoreOutputKindAsString (fScoreOutputKind) <<
2116     endl;
2117 
2118   gIndenter--;
2119 
2120   // global staff size
2121   // --------------------------------------
2122 
2123   gLogOstream <<
2124     "Global staff size:" <<
2125     endl;
2126 
2127   gIndenter++;
2128 
2129   gLogOstream << left <<
2130     setw (fieldWidth) << "fGlobalStaffSize" << " : " <<
2131     fGlobalStaffSize <<
2132     endl;
2133 
2134   gIndenter--;
2135 
2136   // paper
2137   // --------------------------------------
2138 
2139   gLogOstream <<
2140     "Paper:" <<
2141     endl;
2142 
2143   gIndenter++;
2144 
2145   gLogOstream << left <<
2146     setw (fieldWidth) << "lengthUnitKind" << " : " <<
2147     msrLengthUnitKindAsString (fLengthUnitKind) <<
2148     endl <<
2149 
2150     setw (fieldWidth) << "paperHeight" << " : " <<
2151     fPaperHeight.asString () <<
2152     endl <<
2153     setw (fieldWidth) << "paperWidth" << " : " <<
2154     fPaperWidth.asString () <<
2155     endl <<
2156 
2157     setw (fieldWidth) << "paperIndent" << " : " <<
2158     fPaperIndent.asString () <<
2159     endl <<
2160     setw (fieldWidth) << "paperShortIndent" << " : " <<
2161     fPaperShortIndent.asString () <<
2162     endl <<
2163 
2164     setw (fieldWidth) << "markupSystemPpacingPadding" << " : " <<
2165     fMarkupSystemSpacingPadding.asString () <<
2166     endl <<
2167 
2168     setw (fieldWidth) << "raggedBottom" << " : " <<
2169     booleanAsString (fRaggedBottom) <<
2170     endl <<
2171     setw (fieldWidth) << "raggedLastBottom" << " : " <<
2172     booleanAsString (fRaggedLastBottom) <<
2173     endl <<
2174 
2175     setw (fieldWidth) << "tagline" << " : " <<
2176     booleanAsString (fTagline) <<
2177     endl <<
2178 
2179     setw (fieldWidth) << "pageCount" << " : " <<
2180     fPageCount <<
2181     endl <<
2182     setw (fieldWidth) << "systemCount" << " : " <<
2183     fSystemCount <<
2184     endl;
2185 
2186   gIndenter--;
2187 
2188   // measures
2189   // --------------------------------------
2190 
2191   gLogOstream <<
2192     "Measures:" <<
2193     endl;
2194 
2195   gIndenter++;
2196 
2197   gLogOstream << left <<
2198     setw (fieldWidth) << "resetMeasureElementMeasureNumberMap" << " : ";
2199   if (! fAddEmptyMeasuresStringToIntMap.size ()) {
2200     gLogOstream << "empty";
2201   }
2202   else {
2203     map<string, int>::const_iterator
2204       iBegin = fAddEmptyMeasuresStringToIntMap.begin (),
2205       iEnd   = fAddEmptyMeasuresStringToIntMap.end (),
2206       i      = iBegin;
2207     for ( ; ; ) {
2208       gLogOstream << (*i).first << "=" << (*i).second;
2209       if (++i == iEnd) break;
2210       gLogOstream << ",";
2211     } // for
2212   }
2213   gLogOstream << endl;
2214 
2215   gIndenter--;
2216 
2217   // words
2218   // --------------------------------------
2219 
2220   gLogOstream <<
2221     "Words:" <<
2222     endl;
2223 
2224   gIndenter++;
2225 
2226   gLogOstream << left <<
2227     setw (fieldWidth) << "convertWordsToTempo" << " : " <<
2228     booleanAsString (fConvertWordsToTempo) <<
2229     endl <<
2230     setw (fieldWidth) << "addWordsFromTheLyrics" << " : " <<
2231     booleanAsString (fAddWordsFromTheLyrics) <<
2232     endl;
2233 
2234   gIndenter--;
2235 
2236   // rehearsal marks
2237   // --------------------------------------
2238 
2239   gLogOstream <<
2240     "Rehearsal marks:" <<
2241     endl;
2242 
2243   gIndenter++;
2244 
2245   gLogOstream << left <<
2246     setw (fieldWidth) << "convertTemposToRehearsalMarks" << " : " <<
2247     booleanAsString (fConvertTemposToRehearsalMarks) <<
2248     endl <<
2249     setw (fieldWidth) << "convertWordsToRehearsalMarks" << " : " <<
2250     booleanAsString (fConvertWordsToRehearsalMarks) <<
2251     endl;
2252 
2253   gIndenter--;
2254 
2255   // languages
2256   // --------------------------------------
2257 
2258   gLogOstream <<
2259     "Languages:" <<
2260     endl;
2261 
2262   gIndenter++;
2263 
2264   gLogOstream << left <<
2265     setw (fieldWidth) << "lpsrQuarterTonesPitchesLanguage" << " : \"" <<
2266     msrQuarterTonesPitchesLanguageKindAsString (
2267       fLpsrQuarterTonesPitchesLanguageKind) <<
2268     "\"" <<
2269     endl <<
2270 
2271     setw (fieldWidth) << "lpsrChordsLanguage" << " : \"" <<
2272     lpsrChordsLanguageKindAsString (
2273       fLpsrChordsLanguageKind) <<
2274     "\"" <<
2275     endl;
2276 
2277   gIndenter--;
2278 
2279   // transpose
2280   // --------------------------------------
2281 
2282   gLogOstream <<
2283     "Transpose:" <<
2284     endl;
2285 
2286   gIndenter++;
2287 
2288   gLogOstream << left <<
2289     setw (fieldWidth) << "transposeSemiTonesPitchAndOctave" << " : ";
2290 
2291     if (fTransposeSemiTonesPitchAndOctave) {
2292       gLogOstream <<
2293         fTransposeSemiTonesPitchAndOctave->asString ();
2294     }
2295     else {
2296       gLogOstream <<
2297         "none";
2298     }
2299   gLogOstream << endl;
2300 
2301   gIndenter--;
2302 
2303 
2304   gIndenter--;
2305 }
2306 
crackLilypondVersionNumber(string theString,int & generationNumber,int & majorNumber,int & minorNumber)2307 void lpsrOah::crackLilypondVersionNumber (
2308   string theString,
2309   int&   generationNumber,
2310   int&   majorNumber,
2311   int&   minorNumber)
2312 {
2313   // obtains the three numbers in "2.19.83" or "2.20" for example
2314 
2315   // decipher theString with a three-number regular expression
2316   string regularExpression (
2317     "([[:digit:]]+)"
2318     "."
2319     "([[:digit:]]+)"
2320     "."
2321     "([[:digit:]]+)");
2322 
2323   regex  e (regularExpression);
2324   smatch sm;
2325 
2326   regex_match (theString, sm, e);
2327 
2328   unsigned smSize = sm.size ();
2329 
2330 #ifdef TRACE_OAH
2331   if (gLpsrOah->fTraceLilypondVersion) {
2332     gLogOstream <<
2333       "There are " << smSize << " matches" <<
2334       " for version string '" << theString <<
2335       "' with regex '" << regularExpression <<
2336       "'" <<
2337       endl <<
2338       smSize << " elements: ";
2339 
2340       for (unsigned i = 0; i < smSize; ++i) {
2341         gLogOstream <<
2342           "[" << sm [i] << "] ";
2343       } // for
2344 
2345       gLogOstream << endl;
2346     }
2347 #endif
2348 
2349   if (smSize == 4) {
2350     // found an n.x.y specification
2351     string
2352       generationNumberValue = sm [1],
2353       majorNumberValue      = sm [2],
2354       minorNumberValue      = sm [3];
2355 
2356 #ifdef TRACE_OAH
2357     if (gLpsrOah->fTraceLilypondVersion) {
2358       gLogOstream <<
2359         "--> generationNumberValue = \"" << generationNumberValue << "\", " <<
2360         "--> majorNumberValue = \"" << majorNumberValue << "\", " <<
2361         "--> minorNumberValue = \"" << minorNumberValue << "\"" <<
2362         endl;
2363     }
2364 #endif
2365 
2366     generationNumber = stoi (generationNumberValue);
2367     majorNumber      = stoi (majorNumberValue);
2368     minorNumber      = stoi (minorNumberValue);
2369   }
2370 
2371   else {
2372     // decipher theString with a two-number regular expression
2373     string regularExpression (
2374       "([[:digit:]]+)"
2375       "."
2376       "([[:digit:]]+)");
2377 
2378     regex  e (regularExpression);
2379     smatch sm;
2380 
2381     regex_match (theString, sm, e);
2382 
2383     unsigned smSize = sm.size ();
2384 
2385 #ifdef TRACE_OAH
2386     if (gLpsrOah->fTraceLilypondVersion) {
2387       gLogOstream <<
2388         "There are " << smSize << " matches" <<
2389         " for chord details string '" << theString <<
2390         "' with regex '" << regularExpression <<
2391         "'" <<
2392         endl <<
2393         smSize << " elements: ";
2394 
2395         for (unsigned i = 0; i < smSize; ++i) {
2396           gLogOstream <<
2397             "[" << sm [i] << "] ";
2398         } // for
2399 
2400         gLogOstream << endl;
2401       }
2402 #endif
2403 
2404     if (smSize == 3) {
2405       // found an n.x specification
2406       // assume implicit 0 minor number
2407       string
2408         generationNumberValue = sm [1],
2409         majorNumberValue      = sm [2];
2410 
2411 #ifdef TRACE_OAH
2412       if (gLpsrOah->fTraceLilypondVersion) {
2413         gLogOstream <<
2414           "--> generationNumberValue = \"" << generationNumberValue << "\", " <<
2415           "--> majorNumberValue = \"" << majorNumberValue << "\", " <<
2416           endl;
2417       }
2418 #endif
2419 
2420       generationNumber = stoi (generationNumberValue);
2421       majorNumber      = stoi (majorNumberValue);
2422       minorNumber      = 0;
2423     }
2424 
2425     else {
2426       stringstream s;
2427 
2428       s <<
2429         "version number argument '" << theString <<
2430         "' is ill-formed";
2431 
2432       oahError (s.str ());
2433     }
2434   }
2435 }
2436 
versionNumberGreaterThanOrEqualTo(string otherVersionNumber)2437 bool lpsrOah::versionNumberGreaterThanOrEqualTo (
2438   string otherVersionNumber)
2439 {
2440   bool result = false;
2441 
2442   int
2443     lilyPondVersionGenerationNumber,
2444     lilyPondVersionMajorNumber,
2445     lilyPondVersionMinorNumber;
2446 
2447   crackLilypondVersionNumber (
2448     fLilyPondVersion,
2449     lilyPondVersionGenerationNumber,
2450     lilyPondVersionMajorNumber,
2451     lilyPondVersionMinorNumber);
2452 
2453   int
2454     otherVersionNumbeGenerationNumber,
2455     otherVersionNumbeMajorNumber,
2456     otherVersionNumbeMinorNumber;
2457 
2458   crackLilypondVersionNumber (
2459     otherVersionNumber,
2460     otherVersionNumbeGenerationNumber,
2461     otherVersionNumbeMajorNumber,
2462     otherVersionNumbeMinorNumber);
2463 
2464   if (otherVersionNumbeGenerationNumber != 2) {
2465     gLogOstream <<
2466       "Using verstion \"" <<
2467       otherVersionNumbeGenerationNumber << ".x.y\" " <<
2468       "is probably not such a good idea" <<
2469       endl;
2470   }
2471 
2472   if (otherVersionNumbeMajorNumber < 19) {
2473     gLogOstream <<
2474       "Using a verstion older than \"" <<
2475       otherVersionNumbeGenerationNumber << ".19.y\" " <<
2476       "is not a good idea: the generated LilyPond code uses features introduced in the latter" <<
2477       endl;
2478   }
2479 
2480   if (lilyPondVersionGenerationNumber < otherVersionNumbeGenerationNumber) {
2481     result = false;
2482   }
2483   else if (lilyPondVersionGenerationNumber > otherVersionNumbeGenerationNumber) {
2484     result = true;
2485   }
2486   else {
2487     // same generation number
2488     if (lilyPondVersionMajorNumber < otherVersionNumbeMajorNumber) {
2489       result = false;
2490     }
2491     else if (lilyPondVersionMajorNumber > otherVersionNumbeMajorNumber) {
2492       result = true;
2493     }
2494     else {
2495       // same major number
2496       result =
2497         lilyPondVersionMinorNumber >= otherVersionNumbeMinorNumber;
2498     }
2499   }
2500 
2501   return result;
2502 }
2503 
operator <<(ostream & os,const S_lpsrOah & elt)2504 ostream& operator<< (ostream& os, const S_lpsrOah& elt)
2505 {
2506   elt->print (os);
2507   return os;
2508 }
2509 
2510 //______________________________________________________________________________
initializeLpsrOahHandling(S_oahHandler handler)2511 void initializeLpsrOahHandling (
2512   S_oahHandler handler)
2513 {
2514 #ifdef TRACE_OAH
2515   if (gTraceOah->fTraceOah && ! gGeneralOah->fQuiet) {
2516     gLogOstream <<
2517       "Initializing LPSR options handling" <<
2518       endl;
2519   }
2520 #endif
2521 
2522   // create the options variables
2523   // ------------------------------------------------------
2524 
2525   gLpsrOahUserChoices = lpsrOah::create (
2526     handler);
2527   assert(gLpsrOahUserChoices != 0);
2528 
2529   gLpsrOah =
2530     gLpsrOahUserChoices;
2531 
2532   // prepare for measure detailed trace
2533   // ------------------------------------------------------
2534 
2535 /* JMI
2536   gLpsrOahWithDetailedTrace =
2537     gLpsrOah->
2538       createCloneWithDetailedTrace ();
2539       */
2540 }
2541 
2542 
2543 }
2544