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
47class FileInfoText : public TextsBase
48{
49public:
58 explicit FileInfoText(const DocumentWeakPtr& document, Cmper partId, ShareMode shareMode, Cmper textNumber)
59 : TextsBase(document, partId, shareMode, textNumber)
60 {
61 if (textNumber <= 0 || textNumber > Cmper(TextType::Subtitle)) {
62 throw std::invalid_argument("invalid text type value provided to FileInfoText constructor");
63 }
64 }
65
72 explicit FileInfoText(const DocumentWeakPtr& document, Cmper textNumber)
73 : TextsBase(document, 0, ShareMode::All, textNumber)
74 {
75 if (textNumber <= 0 || textNumber > Cmper(TextType::Subtitle)) {
76 throw std::invalid_argument("invalid text type value provided to FileInfoText constructor");
77 }
78 }
79
86 enum class TextType : Cmper
87 {
88 Title = 1,
89 Composer = 2,
90 Copyright = 3,
91 Description = 4,
92 Lyricist = 5,
93 Arranger = 6,
94 Subtitle = 7
95 };
96
101 {
102 const Cmper textNumber = getTextNumber();
103 MUSX_ASSERT_IF(textNumber <= 0 || textNumber > Cmper(TextType::Subtitle)) {
104 throw std::logic_error("File Info text found with invalid text number " + std::to_string(textNumber));
105 }
106 return TextType(textNumber);
107 }
108
112 constexpr static std::string_view XmlNodeName = "fileInfo";
113};
114
120{
121public:
123
124 std::vector<std::shared_ptr<LyricsSyllableInfo>> syllables;
125
127 void createSyllableInfo();
128};
129
135{
136public:
137 using LyricsTextBase::LyricsTextBase;
138
142 constexpr static std::string_view XmlNodeName = "verse";
143};
144
150{
151public:
152 using LyricsTextBase::LyricsTextBase;
153
157 constexpr static std::string_view XmlNodeName = "chorus";
158};
159
165{
166public:
167 using LyricsTextBase::LyricsTextBase;
168
172 constexpr static std::string_view XmlNodeName = "section";
173};
174
179class BlockText : public TextsBase
180{
181public:
183
187 constexpr static std::string_view XmlNodeName = "blockText";
188};
189
195{
196public:
198
202 constexpr static std::string_view XmlNodeName = "smartShapeText";
203};
204
210{
211public:
213
217 constexpr static std::string_view XmlNodeName = "expression";
218};
219
225{
226public:
228
232 constexpr static std::string_view XmlNodeName = "bookmarkText";
233};
234
235} // namespace texts
236} // namespace dom
237} // namespace musx
ShareMode
Describes how this instance is shared between part and score.
Definition BaseClasses.h:71
Base class for all text blocks.
Definition BaseClasses.h:422
Cmper getTextNumber() const
Returns the raw text number.
Definition BaseClasses.h:440
TextsBase(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper textNumber)
Constructs a TextsBase object.
Definition BaseClasses.h:432
Contains block text (Finale Text Tool, both page- and measure-attached)
Definition Texts.h:180
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:187
Contains bookmark description text.
Definition Texts.h:225
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:232
Contains text blocks associated with text expressions.
Definition Texts.h:210
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:217
Contains File Info text (from Finale's Score Manager)
Definition Texts.h:48
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:112
TextType
Represents various text types for the file header.
Definition Texts.h:87
@ Copyright
Copyright information for the piece.
@ Description
Description of the piece.
FileInfoText(const DocumentWeakPtr &document, Cmper textNumber)
Constructs a FileInfoText object.
Definition Texts.h:72
TextType getTextType() const
Returns the TextType of the current instance.
Definition Texts.h:100
FileInfoText(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper textNumber)
Constructs a FileInfoText object.
Definition Texts.h:58
Contains chorus text for lyrics.
Definition Texts.h:150
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:157
Contains section text for lyrics.
Definition Texts.h:165
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:172
Base class for lyrics text.
Definition Texts.h:120
void createSyllableInfo()
Creates the syllables array. Used by the factory but available at any time.
Definition Implementations.cpp:1996
std::vector< std::shared_ptr< LyricsSyllableInfo > > syllables
the syllable info for the lyric text, constructed by the factory
Definition Texts.h:124
Contains verse text for lyrics.
Definition Texts.h:135
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:142
Contains text blocks associated with custom line smart shapes.
Definition Texts.h:195
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:202
uint16_t Cmper
Enigma "comperator" key type.
Definition Fundamentals.h:55
std::weak_ptr< Document > DocumentWeakPtr
Shared weak Document pointer.
Definition BaseClasses.h:56
object model for musx file (enigmaxml)
Definition BaseClasses.h:35