MUSX Document Model
Loading...
Searching...
No Matches
musx::util::EnigmaString Class Reference

Static class that provides utilties to extract information from enigma strings. More...

#include <EnigmaString.h>

Public Types

enum class  AccidentalStyle { Ascii , Unicode , Smufl }
 Enumeration to specify the type of accidental replacement. More...
 

Static Public Member Functions

static bool startsWithFontCommand (const std::string &text)
 Returns true if the enigma string starts with a font command.
 
static std::vector< std::string > parseComponents (const std::string &input)
 Parses an enigma text insert into its constituent components.
 
static bool parseFontCommand (const std::string &fontTag, dom::FontInfo &fontInfo)
 Incorporates an enigma font command into the supplied dom::FontInfo instance.
 
static std::string trimFontTags (const std::string &input)
 Trims all font tags from an enigma string.
 
static std::string trimTags (const std::string &input)
 Trims all enigma tags from an enigma string, leaving just the plain text.
 
static std::string replaceAccidentalTags (const std::string &input, AccidentalStyle style=AccidentalStyle::Ascii)
 Replaces ^flat() and ^sharp() inserts with 'b' and '#'.
 

Detailed Description

Static class that provides utilties to extract information from enigma strings.

Member Enumeration Documentation

◆ AccidentalStyle

Enumeration to specify the type of accidental replacement.

This enum class is used to choose between different representations of musical accidentals when processing text.

Enumerator
Ascii 

Use ASCII substitutions for accidentals.

  • Flat: 'b'
  • Sharp: '#'
  • Natural: (empty string)

Suitable for environments where Unicode or SMuFL support is unavailable.

Unicode 

Use Unicode text accidentals.

  • Flat: ♭ (U+266D)
  • Sharp: ♯ (U+266F)
  • Natural: ♮ (U+266E)

Suitable for inline text representations like "Clarinet in B♭."

Smufl 

Use SMuFL notation-specific accidentals.

  • Flat: (U+E260)
  • Sharp: (U+E262)
  • Natural: (U+E261)

Suitable for musical notation systems or specialized fonts that support SMuFL.

Member Function Documentation

◆ parseComponents()

std::vector< std::string > musx::util::EnigmaString::parseComponents ( const std::string &  input)
static

Parses an enigma text insert into its constituent components.

The function takes an enigma text insert starting with ^ and extracts the command and its parameters. If the string is invalid or unbalanced, it returns an empty vector.

Examples:

parseComponents("^fontTxt(Times,4096)"); // Returns {"fontTxt", "Times", "4096"}
parseComponents("^size(10)"); // Returns {"size", "10"}
parseComponents("^nfx(130,(xyz))"); // Returns {"nfx", "130", "(xyz)"}
parseComponents("^some"); // Returns {"some"}
parseComponents("^^"); // Returns {"^"}
parseComponents("^^invalid"); // Returns {}
parseComponents("^unbalanced(abc"); // Returns {}
static std::vector< std::string > parseComponents(const std::string &input)
Parses an enigma text insert into its constituent components.
Definition EnigmaString.cpp:43
Parameters
inputThe enigma text insert to parse.
Returns
A vector of strings representing the command and its parameters, or an empty vector if invalid.

◆ parseFontCommand()

bool musx::util::EnigmaString::parseFontCommand ( const std::string &  fontTag,
dom::FontInfo fontInfo 
)
static

Incorporates an enigma font command into the supplied dom::FontInfo instance.

Enigma font commands are