MUSX Document Model
Loading...
Searching...
No Matches
EnigmaString.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 <vector>
26
27namespace musx {
28
29namespace dom {
30class FontInfo;
31} // namespace dom
32
33namespace util {
34
39{
40public:
47 enum class AccidentalStyle
48 {
58 Ascii,
59
69 Unicode,
70
80 Smufl
81 };
82
85 static bool startsWithFontCommand(const std::string& text);
86
107 static std::vector<std::string> parseComponents(const std::string& input);
108
117 static bool parseFontCommand(const std::string& fontTag, dom::FontInfo& fontInfo);
118
120 static std::string trimFontTags(const std::string& input);
121
123 static std::string trimTags(const std::string& input);
124
126 static std::string replaceAccidentalTags(const std::string& input, AccidentalStyle style = AccidentalStyle::Ascii);
127};
128
129} // namespace util
130} // namespace musx
Represents the default font settings for a particular element type.
Definition CommonClasses.h:83
Static class that provides utilties to extract information from enigma strings.
Definition EnigmaString.h:39
static std::string trimTags(const std::string &input)
Trims all enigma tags from an enigma string, leaving just the plain text.
Definition EnigmaString.cpp:144
static bool startsWithFontCommand(const std::string &text)
Returns true if the enigma string starts with a font command.
Definition EnigmaString.cpp:33
AccidentalStyle
Enumeration to specify the type of accidental replacement.
Definition EnigmaString.h:48
@ Smufl
Use SMuFL notation-specific accidentals.
@ Ascii
Use ASCII substitutions for accidentals.
@ Unicode
Use Unicode text accidentals.
static std::vector< std::string > parseComponents(const std::string &input)
Parses an enigma text insert into its constituent components.
Definition EnigmaString.cpp:43
static bool parseFontCommand(const std::string &fontTag, dom::FontInfo &fontInfo)
Incorporates an enigma font command into the supplied dom::FontInfo instance.
Definition EnigmaString.cpp:95
static std::string trimFontTags(const std::string &input)
Trims all font tags from an enigma string.
Definition EnigmaString.cpp:128
static std::string replaceAccidentalTags(const std::string &input, AccidentalStyle style=AccidentalStyle::Ascii)
Replaces ^flat() and ^sharp() inserts with 'b' and '#'.
Definition EnigmaString.cpp:179
object model for musx file (enigmaxml)
Definition BaseClasses.h:32