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 assert(textNumber > 0 && textNumber <= Cmper(TextType::Subtitle));
104 return TextType(textNumber);
105 }
106
110 constexpr static std::string_view XmlNodeName = "fileInfo";
111};
112
118{
119public:
121
122 std::vector<std::shared_ptr<LyricsSyllableInfo>> syllables;
123
125 void createSyllableInfo();
126};
127
133{
134public:
135 using LyricsTextBase::LyricsTextBase;
136
140 constexpr static std::string_view XmlNodeName = "verse";
141};
142
148{
149public:
150 using LyricsTextBase::LyricsTextBase;
151
155 constexpr static std::string_view XmlNodeName = "chorus";
156};
157
163{
164public:
165 using LyricsTextBase::LyricsTextBase;
166
170 constexpr static std::string_view XmlNodeName = "section";
171};
172
177class BlockText : public TextsBase
178{
179public:
181
185 constexpr static std::string_view XmlNodeName = "blockText";
186};
187
193{
194public:
196
200 constexpr static std::string_view XmlNodeName = "smartShapeText";
201};
202
208{
209public:
211
215 constexpr static std::string_view XmlNodeName = "expression";
216};
217
223{
224public:
226
230 constexpr static std::string_view XmlNodeName = "bookmarkText";
231};
232
233} // namespace texts
234} // namespace dom
235} // namespace musx
ShareMode
Describes how this instance is shared between part and score.
Definition BaseClasses.h:72
Base class for all text blocks.
Definition BaseClasses.h:381
Cmper getTextNumber() const
Returns the raw text number.
Definition BaseClasses.h:399
TextsBase(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper textNumber)
Constructs a TextsBase object.
Definition BaseClasses.h:391
Contains block text (Finale Text Tool, both page- and measure-attached)
Definition Texts.h:178
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:185
Contains bookmark description text.
Definition Texts.h:223
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:230
Contains text blocks associated with text expressions.
Definition Texts.h:208
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:215
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:110
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:148
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:155
Contains section text for lyrics.
Definition Texts.h:163
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:170
Base class for lyrics text.
Definition Texts.h:118
void createSyllableInfo()
Creates the syllables array. Used by the factory but available at any time.
Definition Implementations.cpp:1292
std::vector< std::shared_ptr< LyricsSyllableInfo > > syllables
the syllable info for the lyric text, constructed by the factory
Definition Texts.h:122
Contains verse text for lyrics.
Definition Texts.h:133
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:140
Contains text blocks associated with custom line smart shapes.
Definition Texts.h:193
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Texts.h:200
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:32