28#include "musx/dom/Fundamentals.h"
29#include "musx/xml/XmlInterface.h"
30#include "musx/util/Logger.h"
50 using std::runtime_error::runtime_error;
82 virtual ~Base() noexcept(false) = default;
91 auto document = m_document.lock();
94 throw std::logic_error(
"Document pointer is no longer valid.");
122 m_unlinkedNodes.insert(nodeName);
156 : m_document(document), m_partId(partId), m_shareMode(shareMode) {}
163 const Cmper m_partId;
210 :
Base(document, partId, shareMode) {}
232 :
Base(document, partId, shareMode), m_cmper(cmper), m_inci(inci) {}
247 std::optional<Inci>
getInci()
const {
return m_inci; }
251 std::optional<Inci> m_inci;
257template <
typename ElementType,
size_t REQUIRED_SIZE = 0>
261 virtual std::string_view xmlTag()
const = 0;
266 :
OthersBase(document, partId, shareMode, cmper)
277 if constexpr (REQUIRED_SIZE) {
278 const size_t originalSize =
values.size();
279 values.resize(REQUIRED_SIZE);
280 if (originalSize < REQUIRED_SIZE) {
281 MUSX_INTEGRITY_ERROR(
"Array with xml tag " + std::string(xmlTag()) +
" and cmper " + std::to_string(
getCmper())
282 +
" has fewer than " + std::to_string(REQUIRED_SIZE) +
" elements.");
308 :
Base(document, partId, shareMode), m_cmper1(cmper1), m_cmper2(cmper2), m_inci(inci) {}
324 std::optional<Inci>
getInci()
const {
return m_inci; }
329 std::optional<Inci> m_inci;
392 :
Base(document, partId, shareMode), m_textNumber(textNumber) {}
Base class to enforce polymorphism across all DOM classes.
Definition BaseClasses.h:64
Cmper getPartId() const
Gets the partId for this instance (or 0 for score)
Definition BaseClasses.h:102
DocumentPtr getDocument() const
Gets a reference to the Document.
Definition BaseClasses.h:89
virtual void integrityCheck()
Allows a class to determine if it has been properly contructed by the factory and fix issues that it ...
Definition BaseClasses.h:133
virtual bool requireAllFields() const
Specifies if the parser should alert (print or throw) when an unknown xml tag is found for this class...
Definition BaseClasses.h:145
Base & operator=(const Base &)
assignment constructor: m_unlinkedNodes is intentionally omitted
Definition BaseClasses.h:159
Base(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode)
Constructs the base class and enforces the static constexpr XmlNodeName.
Definition BaseClasses.h:155
ShareMode getShareMode() const
Gets the sharing mode for this instance.
Definition BaseClasses.h:110
std::set< std::string > SharedNodes
The container type for shared nodes.
Definition BaseClasses.h:67
const SharedNodes & getUnlinkedNodes() const
Gets the unlinked nodes for this instance. (Only populated for ShareMode::Partial)
Definition BaseClasses.h:115
void addUnlinkedNode(const std::string &nodeName)
Adds a shared node for this instance.
Definition BaseClasses.h:120
std::shared_ptr< others::PartDefinition > getPartDefinition() const
Gets the others::PartDefinition corresponding to getPartId.
Definition Implementations.cpp:49
ShareMode
Describes how this instance is shared between part and score.
Definition BaseClasses.h:72
virtual ~Base() noexcept(false)=default
Virtual destructor for polymorphic behavior.
Base class for classes that are commonly used among others, details, entries, and/or texts....
Definition BaseClasses.h:174
CommonClassBase(const DocumentWeakPtr &document)
Constructs a CommonClassBase object.
Definition BaseClasses.h:181
Base class for all "details" types.
Definition BaseClasses.h:295
DetailsBase(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper cmper1, Cmper cmper2, std::optional< Inci > inci=std::nullopt)
Constructs a DetailsBase object.
Definition BaseClasses.h:307
Cmper getCmper1() const
Gets the cmper1 key value.
Definition BaseClasses.h:314
Cmper getCmper2() const
Gets the cmper2 key value.
Definition BaseClasses.h:319
std::optional< Inci > getInci() const
Gets the optional array index (inci).
Definition BaseClasses.h:324
Represents a document object that encapsulates the entire EnigmaXML structure.
Definition Document.h:51
Base class for all "details" types that use entnum rather than cmper and cmper.
Definition BaseClasses.h:336
EntryDetailsBase(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, EntryNumber entnum, std::optional< Inci > inci=std::nullopt)
Constructs a EntryDetailsBase object.
Definition BaseClasses.h:347
EntryNumber getEntryNumber() const
Gets the entnum key value.
Definition BaseClasses.h:354
Represents the default font settings for a particular element type.
Definition CommonClasses.h:83
Base class note details. Note details are entry details associated with a note ID.
Definition BaseClasses.h:365
virtual NoteNumber getNoteId() const =0
Required virtual function that returns the note id.
Base class for all "options" types.
Definition BaseClasses.h:200
OptionsBase(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode)
Constructs the OptionsBase and validates XmlNodeName in the derived class.
Definition BaseClasses.h:209
Template pattern for OthersBase items consisting of an array of a single item.
Definition BaseClasses.h:259
std::vector< ElementType > values
Definition BaseClasses.h:270
OthersArray(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper cmper)
Constructor function.
Definition BaseClasses.h:265
void integrityCheck() override
Override of Base::integrityCheck.
Definition BaseClasses.h:274
Base class for all "others" types.
Definition BaseClasses.h:220
std::optional< Inci > getInci() const
Gets the optional array index (inci).
Definition BaseClasses.h:247
OthersBase(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper cmper, std::optional< Inci > inci=std::nullopt)
Constructs an OthersBase object.
Definition BaseClasses.h:231
Cmper getCmper() const
Gets the cmper key value.
Definition BaseClasses.h:240
Base class for all text blocks.
Definition BaseClasses.h:381
Cmper getTextNumber() const
Returns the raw text number.
Definition BaseClasses.h:399
std::string text
Raw Enigma string (with Enigma string tags), encoded UTF-8.
Definition BaseClasses.h:394
std::shared_ptr< FontInfo > parseFirstFontInfo() const
Returns a shared pointer to a FontInfo instance that reflects the first font information in the text.
Definition Implementations.cpp:2385
TextsBase(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper textNumber)
Constructs a TextsBase object.
Definition BaseClasses.h:391
void setTextNumber(Cmper textNumber)
Sets the raw text number.
Definition BaseClasses.h:404
Exception for integrity errors. (Used when MUSX_THROW_ON_INTEGRITY_CHECK_FAIL is defined....
Definition BaseClasses.h:48
Represents the attributes of a Finale "partDef".
Definition Others.h:1346
constexpr Cmper SCORE_PARTID
The part id of the score.
Definition Fundamentals.h:75
uint16_t Cmper
Enigma "comperator" key type.
Definition Fundamentals.h:55
std::weak_ptr< Document > DocumentWeakPtr
Shared weak Document pointer.
Definition BaseClasses.h:57
int32_t EntryNumber
Entry identifier.
Definition Fundamentals.h:68
uint16_t NoteNumber
Note identifier.
Definition Fundamentals.h:69
std::shared_ptr< Document > DocumentPtr
Shared Document pointer.
Definition BaseClasses.h:55
object model for musx file (enigmaxml)
Definition BaseClasses.h:32