Skip to content

GuitarPrometheus::Parser

GuitarPrometheus::Parser

Classes

Name
structGuitarPrometheus::Parser::BannerEntry
One entry in the unknown-techniques banner: the diagnostic message and how many warnings shared that exact message text.
structGuitarPrometheus::Parser::Diagnostic
A parser warning or error tied to a specific location in the source.
classGuitarPrometheus::Parser::GpFileParser
Native Guitar Pro 7 / 8 (.gp) importer.
classGuitarPrometheus::Parser::GpifReader
Walks a Guitar Pro 7 / 8 score.gpif XML document and emits an [IntermediateScore]() ready for [ScoreBuilder::build]().
classGuitarPrometheus::Parser::GpxBitInput
Bit-level reader used by [GpxFileSystem]() to decode the BCFZ compressed stream and the BCFS sector-based filesystem inside it.
classGuitarPrometheus::Parser::GpxFileParser
Native Guitar Pro 6 (.gpx) importer.
classGuitarPrometheus::Parser::GpxFileSystem
Decodes a Guitar Pro 6 .gpx BitWise container into a virtual filesystem keyed by entry name.
structGuitarPrometheus::Parser::IntermediatePart
A parser-internal representation of a single Part, prior to the final immutable conversion handled by [ScoreBuilder::build]().
structGuitarPrometheus::Parser::IntermediateScore
Parser-internal representation of the whole score immediately before [ScoreBuilder::build]() finalises it.
classGuitarPrometheus::Parser::IScoreImporter
Abstract interface for importing a score from a file.
classGuitarPrometheus::Parser::MusicXmlParser
Parses Guitar Pro 8 MusicXML exports into the in-memory Score model.
structGuitarPrometheus::Parser::Result
Result of a score-import attempt.
classGuitarPrometheus::Parser::ScoreBuilder
Finalises a parser-built [IntermediateScore](/api-reference/classes/structguitarprometheus_1_1parser_1_1intermediatescore/) into an immutable [SongStructure::Score]().
classGuitarPrometheus::Parser::ScoreImporter
Dispatch entry point for all score importers.

Functions

Name
intreadIntChild(const pugi::xml_node & parent, const char * childName, int fallback =0)
Read the integer text content of a named child element.
boolxmlDepthWithin(const pugi::xml_document & doc, std::size_t cap =kMaxXmlNestingDepth)
Walk a pugixml document and confirm element nesting does not exceed cap levels.
std::vector< BannerEntry >summarizeWarnings(const std::vector< std::string > & warnings)
Group identical warning messages, preserving first-occurrence order.

Attributes

Name
constexpr unsigned intkSafeXmlParseFlags
pugixml parse flags used by every score importer in this project.
constexpr std::size_tkMaxXmlNestingDepth
Maximum nesting depth accepted by kMaxXmlNestingDepth (256 levels).
constexpr intkOutputPPQN

Functions Documentation

function readIntChild

int readIntChild(
const pugi::xml_node & parent,
const char * childName,
int fallback =0
)

Read the integer text content of a named child element.

Parameters:

  • parent The element to look under.
  • childName Tag name of the child to read.
  • fallback Value returned when the child is absent or empty.

Return: The parsed integer, or fallback.

Both MusicXML and Guitar Pro’s GPIF schema use the same one-element-per-int convention (<element>123</element>). This helper centralises the “child present → as_int; child absent → fallback” pattern that was previously duplicated in [MusicXmlParser](/api-reference/classes/classguitarprometheus_1_1parser_1_1musicxmlparser/) and [GpifReader](/api-reference/classes/classguitarprometheus_1_1parser_1_1gpifreader/).

function xmlDepthWithin

bool xmlDepthWithin(
const pugi::xml_document & doc,
std::size_t cap =kMaxXmlNestingDepth
)

Walk a pugixml document and confirm element nesting does not exceed cap levels.

Parameters:

  • doc Loaded pugixml document.
  • cap Maximum permitted depth, in elements.

Return: True iff the document is within the cap; false means the document carries a depth-bomb.

Iterative depth-first traversal; safe to run on adversarial input that would otherwise blow the recursive walker’s stack. Returns true when every element sits at depth ≤ cap. Used by every score importer right after xml_document::load_* to bound the cost of subsequent walks.

function summarizeWarnings

std::vector< BannerEntry > summarizeWarnings(
const std::vector< std::string > & warnings
)

Group identical warning messages, preserving first-occurrence order.

The returned vector has one entry per distinct message; count totals how many times that message appeared in the input. Empty messages are dropped.

Attributes Documentation

variable kSafeXmlParseFlags

constexpr unsigned int kSafeXmlParseFlags = pugi::parse_default | pugi::parse_pi;

pugixml parse flags used by every score importer in this project.

pugi::parse_default omits pugi::parse_doctype, so pugixml skips DTD parsing entirely. That means custom-entity declarations inside a DOCTYPE block are never read, never expanded, and cannot drive a “billion laughs” / quadratic-blowup memory attack — the parser simply does not see them. parse_pi is added so the <?GP …?> processing instructions Guitar Pro embeds in its MusicXML exports survive to the technique-extraction layer.

Use this constant for every xml_document::load_* call in the score-importer pipeline.

variable kMaxXmlNestingDepth

constexpr std::size_t kMaxXmlNestingDepth = 256;

Maximum nesting depth accepted by kMaxXmlNestingDepth (256 levels).

Real MusicXML / GPIF documents bottom out around 8 levels; anything deeper is malicious or corrupt.

variable kOutputPPQN

constexpr int kOutputPPQN = 480;

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