MUSX Document Model
Loading...
Searching...
No Matches
Texts.h
1/*
2 * Copyright (C) 2025, Robert Patterson
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22#pragma once
23
24#include <string>
25#include <unordered_map>
26#include <vector>
27#include <memory>
28#include <stdexcept>
29
30#include "BaseClasses.h"
31#include "CommonClasses.h"
32// do not add other dom class dependencies. Use Implementations.h for implementations that need total class access.
33
34namespace musx {
35namespace dom {
36
41namespace texts {
42
49class FileInfoText : public TextsBase
50{
51public:
60 explicit FileInfoText(const DocumentWeakPtr& document, Cmper partId, ShareMode shareMode, Cmper textNumber)
61 : TextsBase(document, partId, shareMode, textNumber)
62 {
63 if (textNumber <= 0 || textNumber > Cmper(TextType::Subtitle)) {
64 throw std::invalid_argument("invalid text type value provided to FileInfoText constructor");
65 }
66 }
67
74 explicit FileInfoText(const DocumentWeakPtr& document, Cmper textNumber)
75 : TextsBase(document, 0, ShareMode::All, textNumber)
76 {
77 if (textNumber <= 0 || textNumber > Cmper(TextType::Subtitle)) {
78 throw std::invalid_argument("invalid text type value provided to FileInfoText constructor");
79 }
80 }
81
88 enum class TextType : Cmper
89 {
90 Title = 1,
91 Composer = 2,
92 Copyright = 3,
93 Description = 4,
94 Lyricist = 5,
95 Arranger = 6,
96 Subtitle = 7
97 };
98
103 {
104 const Cmper textNumber = getTextNumber();
105 MUSX_ASSERT_IF(textNumber <= 0 || textNumber > Cmper(TextType::Subtitle)) {
106 throw std::logic_error("File Info text found with invalid text number " + std::to_string(textNumber));
107 }
108 return TextType(textNumber);
109 }
110
114 constexpr static std::string_view XmlNodeName = "fileInfo";
115};
116
122{
123public:
125
126 std::vector<std::shared_ptr<const LyricsSyllableInfo>> syllables;
127
129 void createSyllableInfo();
130};
131
137{
138public:
139 using LyricsTextBase::LyricsTextBase;
140
144 constexpr static std::string_view XmlNodeName = "verse";
145};
146
152{
153public:
154 using LyricsTextBase::LyricsTextBase;
155
159 constexpr static std::string_view XmlNodeName = "chorus";
160};
161
167{
168public:
169 using LyricsTextBase::LyricsTextBase;
170
174 constexpr static std::string_view XmlNodeName = "section";
175};
176
181class BlockText : public TextsBase
182{
183public:
185
189 constexpr static std::string_view XmlNodeName = "blockText";
190};
191
197{
198public:
200
204 constexpr static std::string_view XmlNodeName = "smartShapeText";
205};
206
212{
213public:
215
219 constexpr static std::string_view XmlNodeName = "expression";
220};
221
229{
230public:
232
236 constexpr static std::string_view XmlNodeName = "bookmarkText";
237};
238
239} // namespace texts
240} // namespace dom
241} // namespace musx
ShareMode
Describes how this instance is shared between part and score.
Definition BaseClasses.h:91
Base class for all text blocks.
Definition BaseClasses.h:557
Cmper getTextNumber() const
Returns the raw text number.
Definition BaseClasses.h:577
TextsBase(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper textNumber)
Constructs a TextsBase object.
Definition BaseClasses.h:569
Contains block text (Finale Text Tool, both page- and measure-attached)
Definition Texts.h:182
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:189
Contains bookmark description text.
Definition Texts.h:229
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:236
Contains text blocks associated with text expressions.
Definition Texts.h:212
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:219
Contains File Info text (from Finale's Score Manager)
Definition Texts.h:50
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:114
TextType
Represents various text types for the file header.
Definition Texts.h:89
@ Copyright
Copyright information for the piece.
@ Description
Description of the piece.
FileInfoText(const DocumentWeakPtr &document, Cmper textNumber)
Constructs a FileInfoText object.
Definition Texts.h:74
TextType getTextType() const
Returns the TextType of the current instance.
Definition Texts.h:102
FileInfoText(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper textNumber)
Constructs a FileInfoText object.
Definition Texts.h:60
Contains chorus text for lyrics.
Definition Texts.h:152
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:159
Contains section text for lyrics.
Definition Texts.h:167
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:174
Base class for lyrics text.
Definition Texts.h:122
void createSyllableInfo()
Creates the syllables array. Used by the factory but available at any time.
Definition Texts.cpp:48
std::vector< std::shared_ptr< const LyricsSyllableInfo > > syllables
the syllable info for the lyric text, constructed by the factory
Definition Texts.h:126
Contains verse text for lyrics.
Definition Texts.h:137
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:144
Contains text blocks associated with custom line smart shapes.
Definition Texts.h:197
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:204
uint16_t Cmper
Enigma "comperator" key type.
Definition Fundamentals.h:55
std::weak_ptr< Document > DocumentWeakPtr
Shared weak Document pointer.
Definition BaseClasses.h:57
object model for musx file (enigmaxml)
Definition BaseClasses.h:36