24#include "musx/dom/BaseClasses.h"
25#include "musx/dom/Others.h"
26#include "musx/dom/Details.h"
27#include "musx/xml/XmlInterface.h"
28#include "FactoryBase.h"
30#ifndef DOXYGEN_SHOULD_IGNORE_THIS
42inline Enclosure::Shape toEnum<Enclosure::Shape>(
const uint8_t& value)
44 if (value >=
static_cast<uint8_t
>(Enclosure::Shape::NoEnclosure) &&
45 value <=
static_cast<uint8_t
>(Enclosure::Shape::Octogon)) {
46 return static_cast<Enclosure::Shape
>(value);
48 MUSX_UNKNOWN_XML(
"Invalid <sides> value in XML for enclosure: " + std::to_string(value));
53struct FieldPopulator<DrumStaffStyle> :
private FieldPopulator<DrumStaff>
55 using FieldPopulator<DrumStaff>::populate;
59struct FieldPopulator<NamePositionAbbreviated> :
private FieldPopulator<NamePositioning>
61 using FieldPopulator<NamePositioning>::populate;
65struct FieldPopulator<NamePositionStyleAbbreviated> :
private FieldPopulator<NamePositioning>
67 using FieldPopulator<NamePositioning>::populate;
71struct FieldPopulator<NamePositionFull> :
private FieldPopulator<NamePositioning>
73 using FieldPopulator<NamePositioning>::populate;
77struct FieldPopulator<NamePositionStyleFull> :
private FieldPopulator<NamePositioning>
79 using FieldPopulator<NamePositioning>::populate;
83struct FieldPopulator<TextExpressionEnclosure> :
private FieldPopulator<Enclosure>
85 using FieldPopulator<Enclosure>::populate;
89struct FieldPopulator<TextRepeatEnclosure> :
private FieldPopulator<Enclosure>
91 using FieldPopulator<Enclosure>::populate;
94MUSX_RESOLVER_ENTRY(KeyMapArray, {
96 auto arrays = document->getOthers()->getArray<KeyMapArray>(
SCORE_PARTID);
97 for (
const auto& array : arrays) {
98 auto trimSteps = [&](
size_t newSize) {
99 while (array->steps.size() > newSize) {
100 const auto& elt = array->steps[array->steps.size() - 1];
101 if (elt->diatonic || elt->hlevel != 0) {
104 array->steps.pop_back();
107 if (
auto keyFormat = document->getOthers()->get<others::KeyFormat>(
SCORE_PARTID, array->getCmper())) {
108 trimSteps(keyFormat->semitones);
109 if (keyFormat->scaleTones != array->countDiatonicSteps() || keyFormat->semitones != array->steps.size()) {
110 MUSX_INTEGRITY_ERROR(
"KeyMapArray " + std::to_string(array->getCmper()) +
" does not match KeyFormat.");
114 if (array->countDiatonicSteps() != 7 || array->steps.size() != 12) {
115 MUSX_INTEGRITY_ERROR(
"KeyMapArray " + std::to_string(array->getCmper()) +
" has no KeyFormat but does not match default values.");
122MUSX_RESOLVER_ENTRY(LayerAttributes, {
124 auto layers = document->getOthers()->getArray<LayerAttributes>(
SCORE_PARTID);
125 if (layers.size() != 4) {
126 MUSX_INTEGRITY_ERROR(
"Expected exactly 4 <layerAtts> elements.");
128 for (
size_t i = 0; i < layers.size(); i++) {
129 if (layers[i]->getCmper() != i) {
130 MUSX_INTEGRITY_ERROR(
"Expected <layerAtts> elements to have cmper values 0, 1, 2, 3 in order.");
136MUSX_RESOLVER_ENTRY(MarkingCategory, {
138 auto cats = document->getOthers()->getArray<MarkingCategory>(
SCORE_PARTID);
139 for (
const auto& cat : cats) {
140 if (cat->categoryType == MarkingCategory::CategoryType::Invalid) {
141 MUSX_INTEGRITY_ERROR(
"Encountered <markingsCategory> node (cmper " + std::to_string(cat->getCmper()) +
") with no categoryType");
147MUSX_RESOLVER_ENTRY(MultiStaffGroupId, {
149 auto parts = document->getOthers()->getArray<PartDefinition>(
SCORE_PARTID);
150 for (
const auto& part : parts) {
151 auto instGroups = document->getOthers()->getArray<MultiStaffGroupId>(part->getCmper());
152 for (
const auto& instance : instGroups) {
153 if (
auto group = document->getDetails()->get<details::StaffGroup>(part->getCmper(),
BASE_SYSTEM_ID, instance->staffGroupId)) {
154 group->multiStaffGroupId = instance->getCmper();
156 MUSX_INTEGRITY_ERROR(
"Group " + std::to_string(instance->staffGroupId) +
" appears in MultiStaffGroupId "
157 + std::to_string(instance->getCmper()) +
" but does not exist.");
164MUSX_RESOLVER_ENTRY(MultiStaffInstrumentGroup, MultiStaffInstrumentGroup::calcAllMultiStaffGroupIds);
166MUSX_RESOLVER_ENTRY(Page, Page::calcSystemInfo);
168MUSX_RESOLVER_ENTRY(ShapeExpressionDef, {
170 auto exps = document->getOthers()->getArray<ShapeExpressionDef>(
SCORE_PARTID);
171 for (
const auto& instance : exps) {
172 if (instance->categoryId) {
173 auto markingCat = document->getOthers()->get<MarkingCategory>(instance->getPartId(), instance->categoryId);
175 MUSX_INTEGRITY_ERROR(
"Marking category for shape expression " + std::to_string(instance->getCmper()) +
" does not exist.");
177 markingCat->shapeExpressions.emplace(instance->getCmper(), instance);
183MUSX_RESOLVER_ENTRY(Staff, {
185 others::Staff::calcAllRuntimeValues<others::Staff>(document);
186 auto instGroups = document->getOthers()->getArray<MultiStaffInstrumentGroup>(
SCORE_PARTID);
188 if (instGroups.empty()) {
194MUSX_RESOLVER_ENTRY(StaffStyle, {
196 others::Staff::calcAllRuntimeValues<others::StaffStyle>(document);
200MUSX_RESOLVER_ENTRY(TextExpressionDef, {
202 auto exps = document->getOthers()->getArray<TextExpressionDef>(
SCORE_PARTID);
203 for (
const auto& instance : exps) {
204 if (instance->categoryId) {
205 auto markingCat = document->getOthers()->get<MarkingCategory>(instance->getPartId(), instance->categoryId);
207 MUSX_INTEGRITY_ERROR(
"Marking category for text expression " + std::to_string(instance->getCmper()) +
" does not exist.");
209 markingCat->textExpressions.emplace(instance->getCmper(), instance);
static void calcAllAutoNumberValues(const DocumentPtr &document)
Get the auto-numbering value for this staff, if applicable.
Definition Implementations.cpp:3055
Classes in the OthersPool.
Definition CommonClasses.h:43
constexpr Cmper SCORE_PARTID
The part id of the score.
Definition Fundamentals.h:79
std::shared_ptr< Document > DocumentPtr
Shared Document pointer.
Definition BaseClasses.h:54
constexpr Cmper BASE_SYSTEM_ID
The base system cmper that gives a list of all available staves and their score order (others::Instru...
Definition Fundamentals.h:80
Provides interfaces and optional implementations for traversing XML.
Definition PugiXmlImpl.h:33
object model for musx file (enigmaxml)
Definition BaseClasses.h:35