Skip to content

GuitarPrometheus::Parser::MusicXmlParser

GuitarPrometheus::Parser::MusicXmlParser

Parses Guitar Pro 8 MusicXML exports into the in-memory Score model. More…

#include <MusicXmlParser.h>

Inherits from GuitarPrometheus::Parser::IScoreImporter

Public Types

Name
using Parser::DiagnosticDiagnostic
Back-compat type aliases — canonical declarations live in [IScoreImporter.h].
using Parser::ResultResult

Public Functions

Name
virtual Resultimport(const std::filesystem::path & file) const override
Parse a score file from disk.
virtual ResultimportMemory(const std::uint8_t * bytes, std::size_t size) const override
Parse a score from raw bytes already in memory.
Resultparse(const std::filesystem::path & file)
Parse a MusicXML file from disk.
Resultparse(std::string_view xmlContent)
Parse MusicXML content already loaded into memory.

Additional inherited members

Public Functions inherited from GuitarPrometheus::Parser::IScoreImporter

Name
virtual~IScoreImporter() =default

Detailed Description

class GuitarPrometheus::Parser::MusicXmlParser;

Parses Guitar Pro 8 MusicXML exports into the in-memory Score model.

The parser is strict by design: it surfaces unrecognized elements as warnings rather than silently dropping them, so newly-encountered Guitar Pro extensions are noticed at parse time rather than going missing in the MIDI output.

One concrete implementation of [IScoreImporter](/api-reference/classes/classguitarprometheus_1_1parser_1_1iscoreimporter/). The legacy static helpers parse(path) and parse(string_view) are retained for test compatibility and for the in-memory parse path used by ProjectStore::materializeScore (when an embedded MusicXML payload is decompressed and parsed without touching disk).

Public Types Documentation

using Diagnostic

using GuitarPrometheus::Parser::MusicXmlParser::Diagnostic = Parser::Diagnostic;

Back-compat type aliases — canonical declarations live in [IScoreImporter.h].

Consumers that previously wrote [MusicXmlParser::Diagnostic](/api-reference/classes/classguitarprometheus_1_1parser_1_1musicxmlparser/#using-diagnostic) / MusicXmlParser::Result continue to compile unchanged.

using Result

using GuitarPrometheus::Parser::MusicXmlParser::Result = Parser::Result;

Public Functions Documentation

function import

virtual Result import(
const std::filesystem::path & file
) const override

Parse a score file from disk.

Parameters:

  • file Absolute path to the source file.

Return: A Result containing either a parsed Score or a list of errors. Warnings are collected separately and are not fatal.

Reimplements: GuitarPrometheus::Parser::IScoreImporter::import

function importMemory

virtual Result importMemory(
const std::uint8_t * bytes,
std::size_t size
) const override

Parse a score from raw bytes already in memory.

Parameters:

  • bytes Raw source bytes. Format is determined by the concrete importer.
  • size Number of bytes in bytes.

Return: A Result containing either a parsed Score or a list of errors.

Reimplements: GuitarPrometheus::Parser::IScoreImporter::importMemory

Default implementation writes the bytes to a temporary file and delegates to import(path) — importers that can read directly from memory should override this for performance. ProjectStore::materializeScore uses this to re-materialise a Score from a .gpproj’s embedded source payload without round-tripping through the user’s filesystem.

function parse

static Result parse(
const std::filesystem::path & file
)

Parse a MusicXML file from disk.

Parameters:

  • file Absolute path to a MusicXML (.xml or .musicxml) file.

Return: A Result containing either a parsed Score or a list of errors.

function parse

static Result parse(
std::string_view xmlContent
)

Parse MusicXML content already loaded into memory.

Parameters:

  • xmlContent UTF-8-encoded MusicXML, full document including the XML prolog. Must remain valid for the duration of this call (pugixml copies internally; no longer-term lifetime requirement).

Return: A Result containing either a parsed Score or a list of errors.

Used by ProjectStore::materializeScore when the XML is embedded inside a .gpproj file: the caller decompresses the gzip payload and hands the resulting buffer here directly, skipping the temp-file dance.


Updated on 2026-05-29 at 07:39:52 +0000