Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[musicxml] Replace Qt containers with std containers #292

Draft
wants to merge 6 commits into
base: 3.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
453 changes: 453 additions & 0 deletions global/containers.h

Large diffs are not rendered by default.

164 changes: 88 additions & 76 deletions importexport/musicxml/exportxml.cpp

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions importexport/musicxml/importmxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
#include "libmscore/staff.h"
#include "libmscore/style.h"

#include "mscore/preferences.h"

#include "importmxml.h"
#include "importmxmllogger.h"
#include "importmxmlpass1.h"
#include "importmxmlpass2.h"

#include "mscore/preferences.h"

namespace Ms {

Score::FileError removeInstrumentNames(Score* score, MxmlLogger* logger)
Expand Down
226 changes: 114 additions & 112 deletions importexport/musicxml/importmxmlpass1.cpp

Large diffs are not rendered by default.

36 changes: 19 additions & 17 deletions importexport/musicxml/importmxmlpass1.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#ifndef __IMPORTMXMLPASS1_H__
#define __IMPORTMXMLPASS1_H__

#include "global/containers.h"

#include "libmscore/score.h"
#include "importxmlfirstpass.h"
#include "musicxml.h" // for the creditwords and MusicXmlPartGroupList definitions
Expand All @@ -44,7 +46,7 @@ struct MxmlPageFormat {
bool twosided { false };
};

typedef QMap<QString, Part*> PartMap;
typedef std::map<QString, Part*> PartMap;
typedef std::map<int,MusicXmlPartGroup*> MusicXmlPartGroupMap;

//---------------------------------------------------------
Expand Down Expand Up @@ -142,7 +144,7 @@ class MusicXMLParserPass1 {
void transpose(const QString& partId, const Fraction& tick);
void divisions();
void direction(const QString& partId, const Fraction cTime);
void directionType(const Fraction cTime, QList<MxmlOctaveShiftDesc>& starts, QList<MxmlOctaveShiftDesc>& stops);
void directionType(const Fraction cTime, std::vector<MxmlOctaveShiftDesc>& starts, std::vector<MxmlOctaveShiftDesc>& stops);
void handleOctaveShift(const Fraction cTime, const QString& type, short size, MxmlOctaveShiftDesc& desc);
void notations(MxmlStartStop& tupletStartStop);
void note(const QString& partId, const Fraction cTime, Fraction& missingPrev, Fraction& dura, Fraction& missingCurr, VoiceOverlapDetector& vod, MxmlTupletStates& tupletStates);
Expand All @@ -157,32 +159,32 @@ class MusicXMLParserPass1 {
void pitch(int& step, float& alter, int& oct);
void rest();
void skipLogCurrElem();
bool determineMeasureLength(QVector<Fraction>& ml) const;
bool determineMeasureLength(std::vector<Fraction>& ml) const;
VoiceList getVoiceList(const QString id) const;
bool determineStaffMoveVoice(const QString& id, const int mxStaff, const int& mxVoice,
int& msMove, int& msTrack, int& msVoice) const;
int voiceToInt(const QString& voice);
int trackForPart(const QString& id) const;
bool hasPart(const QString& id) const;
Part* getPart(const QString& id) const { return _partMap.value(id); }
MusicXmlPart getMusicXmlPart(const QString& id) const { return _parts.value(id); }
MusicXMLInstruments getInstruments(const QString& id) const { return _instruments.value(id); }
Part* getPart(const QString& id) const { return mu::value(_partMap, id); }
MusicXmlPart getMusicXmlPart(const QString& id) const { return mu::value( _parts, id); }
MusicXMLInstruments getInstruments(const QString& id) const { return mu::value(_instruments, id); }
void setDrumsetDefault(const QString& id, const QString& instrId, const NoteHead::Group hg, const int line, const Direction sd);
MusicXmlInstrList getInstrList(const QString id) const;
MusicXmlIntervalList getIntervals(const QString id) const;
Fraction getMeasureStart(const int i) const;
Fraction getMeasureStart(const size_t i) const;
int octaveShift(const QString& id, const int staff, const Fraction f) const;
const CreditWordsList& credits() const { return _credits; }
bool hasBeamingInfo() const { return _hasBeamingInfo; }
bool isVocalStaff(const QString& id) const { return _parts[id].isVocalStaff(); }
bool isVocalStaff(const QString& id) const { return _parts.at(id).isVocalStaff(); }
static VBox* createAndAddVBoxForCreditWords(Score* const score);
int maxDiff() const { return _maxDiff; }
void insertAdjustedDuration(Fraction key, Fraction value) { _adjustedDurations.insert(key, value); }
QMap<Fraction, Fraction>& adjustedDurations() { return _adjustedDurations; }
void insertAdjustedDuration(Fraction key, Fraction value) { _adjustedDurations.insert({ key, value }); }
std::map<Fraction, Fraction>& adjustedDurations() { return _adjustedDurations; }
void insertSeenDenominator(int val) { _seenDenominators.emplace(val); }
void createDefaultHeader(Score* const score);
void createMeasuresAndVboxes(Score* const score,
const QVector<Fraction>& ml, const QVector<Fraction>& ms,
const std::vector<Fraction>& ml, const std::vector<Fraction>& ms,
const std::set<int>& systemStartMeasureNrs,
const std::set<int>& pageStartMeasureNrs,
const CreditWordsList& crWords,
Expand All @@ -201,14 +203,14 @@ class MusicXMLParserPass1 {
QXmlStreamReader _e;
QString _exporterString; ///< Name of the software which exported the file
int _divs; ///< Current MusicXML divisions value
QMap<QString, MusicXmlPart> _parts; ///< Parts data, mapped on part id
std::map<QString, MusicXmlPart> _parts; ///< Parts data, mapped on part id
std::set<int> _systemStartMeasureNrs; ///< Measure numbers of measures starting a page
std::set<int> _pageStartMeasureNrs; ///< Measure numbers of measures starting a page
QVector<Fraction> _measureLength; ///< Length of each measure
QVector<Fraction> _measureStart; ///< Start time of each measure
std::vector<Fraction> _measureLength; ///< Length of each measure
std::vector<Fraction> _measureStart; ///< Start time of each measure
CreditWordsList _credits; ///< All credits collected
PartMap _partMap; ///< TODO merge into MusicXmlPart ??
QMap<QString, MusicXMLInstruments> _instruments; ///< instruments for each part, mapped on part id
std::map<QString, MusicXMLInstruments> _instruments; ///< instruments for each part, mapped on part id
Score* _score; ///< MuseScore score
MxmlLogger* _logger; ///< Error logger
QString _errors; ///< Errors to present to the user
Expand All @@ -218,11 +220,11 @@ class MusicXMLParserPass1 {

// part specific data (TODO: move to part-specific class)
Fraction _timeSigDura; ///< Measure duration according to last timesig read
QMap<int, MxmlOctaveShiftDesc> _octaveShifts; ///< Pending octave-shifts
std::map<int, MxmlOctaveShiftDesc> _octaveShifts; ///< Pending octave-shifts
QSize _pageSize; ///< Page width read from defaults

const int _maxDiff = 5; ///< Duration rounding tick threshold;
QMap<Fraction, Fraction> _adjustedDurations; ///< Rounded durations
std::map<Fraction, Fraction> _adjustedDurations; ///< Rounded durations
std::set<int> _seenDenominators; ///< Denominators seen. Used for rounding errors.
};

Expand Down
Loading