8 #ifndef __VRV_OPTIONS_H__
9 #define __VRV_OPTIONS_H__
11 #ifdef CUSTOM_VEROVIO_OPTIONS
12 #include "custom_options.h"
21 #include "attalternates.h"
24 #include "toolkitdef.h"
41 #define DEFAULT_SCALE 100
43 #define MAX_SCALE 1000
50 #define TEMP_LYRIC_LINE_SPACE 5.0
52 #define TEMP_KEYSIG_STEP 0.4
54 #define TEMP_KEYSIG_NATURAL_STEP 0.6
60 enum option_BREAKS { BREAKS_none = 0, BREAKS_auto, BREAKS_line, BREAKS_smart, BREAKS_encoded };
62 enum option_CONDENSE { CONDENSE_none = 0, CONDENSE_auto, CONDENSE_all, CONDENSE_encoded };
64 enum option_DURATION_EQ { DURATION_EQ_brevis = 0, DURATION_EQ_semibrevis, DURATION_EQ_minima };
67 ELISION_regular = SMUFL_E551_lyricsElision,
68 ELISION_narrow = SMUFL_E550_lyricsElisionNarrow,
69 ELISION_wide = SMUFL_E552_lyricsElisionWide,
70 ELISION_unicode = UNICODE_UNDERTIE
73 enum option_FONT_FALLBACK { FONT_FALLBACK_Leipzig = 0, FONT_FALLBACK_Bravura };
75 enum option_FOOTER { FOOTER_none = 0, FOOTER_auto, FOOTER_encoded, FOOTER_always };
77 enum option_HEADER { HEADER_none = 0, HEADER_auto, HEADER_encoded };
79 enum option_LIGATURE_OBL { LIGATURE_OBL_auto = 0, LIGATURE_OBL_straight, LIGATURE_OBL_curved };
81 enum option_MULTIRESTSTYLE {
82 MULTIRESTSTYLE_auto = 0,
83 MULTIRESTSTYLE_default,
85 MULTIRESTSTYLE_symbols
88 enum option_SYSTEMDIVIDER { SYSTEMDIVIDER_none = 0, SYSTEMDIVIDER_auto, SYSTEMDIVIDER_left, SYSTEMDIVIDER_left_right };
90 enum option_SMUFLTEXTFONT { SMUFLTEXTFONT_embedded = 0, SMUFLTEXTFONT_linked, SMUFLTEXTFONT_none };
96 enum class OptionsCategory { None, Base, General, Json, Layout, Mensural, Margins, Midi, Selectors, Full };
110 virtual void CopyTo(
Option *option) = 0;
112 void SetKey(
const std::string &key) { m_key = key; }
113 std::string GetKey()
const {
return m_key; }
115 virtual bool SetValueBool(
bool value);
116 virtual bool SetValueDbl(
double value);
117 virtual bool SetValueArray(
const std::vector<std::string> &values);
118 virtual bool SetValue(
const std::string &value);
119 virtual std::string GetStrValue()
const = 0;
120 virtual std::string GetDefaultStrValue()
const = 0;
122 virtual void Reset() = 0;
123 virtual bool IsSet()
const = 0;
125 void SetInfo(
const std::string &title,
const std::string &description);
126 std::string GetTitle()
const {
return m_title; }
127 std::string GetDescription()
const {
return m_description; }
129 void SetShortOption(
char shortOption,
bool isCmdOnly);
130 char GetShortOption()
const {
return m_shortOption; }
131 bool IsCmdOnly()
const {
return m_isCmdOnly; }
132 virtual bool IsArgumentRequired()
const {
return true; }
148 static const std::map<int, std::string> s_condense;
149 static const std::map<int, std::string> s_durationEq;
150 static const std::map<int, std::string> s_elision;
151 static const std::map<int, std::string> s_fontFallback;
152 static const std::map<int, std::string> s_footer;
153 static const std::map<int, std::string> s_header;
154 static const std::map<int, std::string> s_ligatureOblique;
155 static const std::map<int, std::string> s_multiRestStyle;
156 static const std::map<int, std::string> s_pedalStyle;
157 static const std::map<int, std::string> s_systemDivider;
158 static const std::map<int, std::string> s_smuflTextFont;
162 std::string m_description;
184 void CopyTo(
Option *option)
override;
185 void Init(
bool defaultValue);
187 bool SetValueBool(
bool value)
override;
188 bool SetValueDbl(
double value)
override;
189 bool SetValue(
const std::string &value)
override;
190 std::string GetStrValue()
const override;
191 std::string GetDefaultStrValue()
const override;
193 void Reset()
override;
194 bool IsSet()
const override;
196 bool GetValue()
const {
return m_value; }
197 bool GetDefault()
const {
return m_defaultValue; }
198 bool SetValue(
bool value);
200 bool IsArgumentRequired()
const override {
return false; }
223 m_defaultValue = 0.0;
226 m_definitionFactor =
false;
229 void CopyTo(
Option *option)
override;
230 void Init(
double defaultValue,
double minValue,
double maxValue,
bool definitionFactor =
false);
232 bool SetValueDbl(
double value)
override;
233 bool SetValue(
const std::string &value)
override;
234 std::string GetStrValue()
const override;
235 std::string GetDefaultStrValue()
const override;
237 void Reset()
override;
238 bool IsSet()
const override;
240 double GetValue()
const;
241 double GetUnfactoredValue()
const;
242 double GetDefault()
const {
return m_defaultValue; }
243 double GetMin()
const {
return m_minValue; }
244 double GetMax()
const {
return m_maxValue; }
245 bool SetValue(
double value);
253 double m_defaultValue;
256 bool m_definitionFactor;
274 m_definitionFactor =
false;
277 void CopyTo(
Option *option)
override;
278 void Init(
int defaultValue,
int minValue,
int maxValue,
bool definitionFactor =
false);
280 bool SetValueDbl(
double value)
override;
281 bool SetValue(
const std::string &value)
override;
282 std::string GetStrValue()
const override;
283 std::string GetDefaultStrValue()
const override;
285 void Reset()
override;
286 bool IsSet()
const override;
288 int GetValue()
const;
289 int GetUnfactoredValue()
const;
290 int GetDefault()
const {
return m_defaultValue; }
291 int GetMin()
const {
return m_minValue; }
292 int GetMax()
const {
return m_maxValue; }
293 bool SetValue(
int value);
304 bool m_definitionFactor;
319 void CopyTo(
Option *option)
override;
320 void Init(
const std::string &defaultValue);
322 bool SetValue(
const std::string &value)
override;
323 std::string GetStrValue()
const override {
return m_value; }
324 std::string GetDefaultStrValue()
const override {
return m_defaultValue; }
326 std::string GetValue()
const {
return m_value; }
327 std::string GetDefault()
const {
return m_defaultValue; }
329 void Reset()
override;
330 bool IsSet()
const override;
338 std::string m_defaultValue;
353 void CopyTo(
Option *option)
override;
356 bool SetValueArray(
const std::vector<std::string> &values)
override;
357 bool SetValue(
const std::string &value)
override;
358 std::string GetStrValue()
const override;
359 std::string GetDefaultStrValue()
const override;
361 std::vector<std::string> GetValue()
const {
return m_values; }
362 std::vector<std::string> GetDefault()
const {
return m_defaultValues; }
363 bool SetValue(std::vector<std::string>
const &values);
365 void Reset()
override;
366 bool IsSet()
const override;
369 std::string GetStr(
const std::vector<std::string> &values)
const;
374 std::vector<std::string> m_values;
375 std::vector<std::string> m_defaultValues;
390 void CopyTo(
Option *option)
override;
391 void Init(
int defaultValue,
const std::map<int, std::string> *values);
393 bool SetValue(
const std::string &value)
override;
394 std::string GetStrValue()
const override;
395 std::string GetDefaultStrValue()
const override;
397 int GetValue()
const {
return m_value; }
398 int GetDefault()
const {
return m_defaultValue; }
399 bool SetValue(
int value);
401 std::vector<std::string> GetStrValues(
bool withoutDefault)
const;
402 std::string GetStrValuesAsStr(
bool withoutDefault)
const;
404 void Reset()
override;
405 bool IsSet()
const override;
412 const std::map<int, std::string> *m_values;
429 void CopyTo(
Option *option)
override;
431 void Init(data_STAFFREL defaultValue);
433 bool SetValue(
const std::string &value)
override;
434 std::string GetStrValue()
const override;
435 std::string GetDefaultStrValue()
const override;
437 void Reset()
override;
438 bool IsSet()
const override;
442 const data_STAFFREL *GetValueAlternate()
const {
return &m_value; }
443 const data_STAFFREL *GetDefaultAlernate()
const {
return &m_defaultValue; }
450 data_STAFFREL m_value;
451 data_STAFFREL m_defaultValue;
459 enum class JsonSource { String, FilePath };
466 using JsonPath = std::vector<std::reference_wrapper<jsonxx::Value>>;
475 void CopyTo(
Option *option)
override;
476 void Init(JsonSource source,
const std::string &defaultValue);
483 jsonxx::Object GetValue(
bool getDefault =
false)
const;
490 std::string GetStrValue()
const override;
491 std::string GetDefaultStrValue()
const override;
493 void Reset()
override;
494 bool IsSet()
const override;
501 bool HasValue(
const std::vector<std::string> &jsonNodePath)
const;
502 int GetIntValue(
const std::vector<std::string> &jsonNodePath,
bool getDefault =
false)
const;
503 double GetDblValue(
const std::vector<std::string> &jsonNodePath,
bool getDefault =
false)
const;
504 std::string GetStrValue(
const std::vector<std::string> &jsonNodePath,
bool getDefault =
false)
const;
505 bool UpdateNodeValue(
const std::vector<std::string> &jsonNodePath,
const std::string &value);
513 std::set<std::string> GetKeysByNode(
const std::string &nodeName, std::list<std::string> &jsonNodePath)
const;
517 JsonPath StringPath2NodePath(
const jsonxx::Object &obj,
const std::vector<std::string> &jsonNodePath)
const;
520 const jsonxx::Object *FindNodeByName(
521 const jsonxx::Object &obj,
const std::string &jsonNodeName, std::list<std::string> &jsonNodePath)
const;
524 bool ReadJson(jsonxx::Object &output,
const std::string &input)
const;
527 JsonSource m_source = JsonSource::String;
529 jsonxx::Object m_values;
530 jsonxx::Object m_defaultValues;
546 void SetLabel(
const std::string &label,
const std::string &
id)
551 std::string GetLabel()
const {
return m_label; }
552 std::string GetId()
const {
return m_id; }
554 void SetCategory(OptionsCategory category) { m_category = category; }
555 OptionsCategory GetCategory()
const {
return m_category; }
557 void AddOption(
Option *option) { m_options.push_back(option); }
559 const std::vector<Option *> *GetOptions()
const {
return &m_options; }
566 std::vector<Option *> m_options;
567 OptionsCategory m_category = OptionsCategory::None;
586 bool SetInputFrom(std::string
const &inputFrom);
587 bool SetOutputTo(std::string
const &outputTo);
588 FileFormat GetInputFrom()
const {
return m_inputFromFormat; }
589 FileFormat GetOutputTo()
const {
return m_outputToFormat; }
591 const MapOfStrOptions *GetItems()
const {
return &m_items; }
593 const std::vector<OptionGrp *> *GetGrps()
const {
return &m_grps; }
595 jsonxx::Object GetBaseOptGrp();
597 const std::vector<Option *> *GetBaseOptions()
const;
626 FileFormat m_inputFromFormat;
627 FileFormat m_outputToFormat;
886 MapOfStrOptions m_items;
888 std::vector<OptionGrp *> m_grps;
This class is for array (string) styling params.
Definition: options.h:348
This class is for boolean styling params.
Definition: options.h:179
This class is for integer styling params.
Definition: options.h:218
This class is a base class of each styling parameter.
Definition: options.h:540
This class is a base class of each styling parameter.
Definition: options.h:101
static const std::map< int, std::string > s_breaks
Static maps used my OptionIntMap objects.
Definition: options.h:147
jsonxx::Object ToJson() const
Return a JSON object for the option.
This class is for integer styling params.
Definition: options.h:266
This class is for map break options.
Definition: options.h:385
This class is for Json input params.
Definition: options.h:465
std::set< std::string > GetKeys() const
Accessing all keys.
bool ReadJson(jsonxx::Object &output, const std::string &input) const
Read json from string or file.
JsonSource GetSource() const
Member access.
bool HasValue(const std::vector< std::string > &jsonNodePath) const
Accessing values as json node path.
bool SetValue(const std::string &value) override
Interface methods: accessing values as string.
This class is for map styling params.
Definition: options.h:424
This class is for string styling params.
Definition: options.h:314
This class contains the document styling parameters.
Definition: options.h:577
OptionGrp m_generalLayout
General layout.
Definition: options.h:692
OptionGrp m_baseOptions
Comments in implementation file options.cpp.
Definition: options.h:609
OptionGrp m_general
General.
Definition: options.h:632
OptionGrp m_midi
Midi.
Definition: options.h:855
OptionGrp m_elementMargins
Element margins.
Definition: options.h:800
OptionGrp m_deprecated
Deprecated options.
Definition: options.h:882
OptionGrp m_mensural
Mensural.
Definition: options.h:863
OptionGrp m_jsonCmdLineOptions
Additional options for passing method JSON options to the command-line.
Definition: options.h:875
OptionGrp m_selectors
Selectors.
Definition: options.h:780