LMMS
Loading...
Searching...
No Matches
DataFile.h
Go to the documentation of this file.
1/*
2 * DataFile.h - class for reading and writing LMMS data files
3 *
4 * Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5 * Copyright (c) 2012-2013 Paul Giblock <p/at/pgiblock.net>
6 *
7 * This file is part of LMMS - https://lmms.io
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program (see COPYING); if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA.
23 *
24 */
25
26#ifndef LMMS_DATA_FILE_H
27#define LMMS_DATA_FILE_H
28
29#include <map>
30#include <QDomDocument>
31#include <vector>
32
33#include "lmms_export.h"
34
35class QTextStream;
36
37namespace lmms
38{
39
40class ProjectVersion;
41
42
43class LMMS_EXPORT DataFile : public QDomDocument
44{
45
47
48public:
49 enum class Type
50 {
51 Unknown,
52 SongProject,
53 SongProjectTemplate,
54 InstrumentTrackSettings,
55 DragNDropData,
56 ClipboardData,
57 JournalData,
58 EffectSettings,
60 } ;
61
62 DataFile( const QString& fileName );
63 DataFile( const QByteArray& data );
64 DataFile( Type type );
65
66 virtual ~DataFile() = default;
67
72 bool validate( QString extension );
73
74 QString nameWithExtension( const QString& fn ) const;
75
76 void write( QTextStream& strm );
77 bool writeFile(const QString& fn, bool withResources = false);
78 bool copyResources(const QString& resourcesDir);
79 bool hasLocalPlugins(QDomElement parent = QDomElement(), bool firstCall = true) const;
80
81 QDomElement& content()
82 {
83 return m_content;
84 }
85
86 QDomElement& head()
87 {
88 return m_head;
89 }
90
91 Type type() const
92 {
93 return m_type;
94 }
95
96 unsigned int legacyFileVersion();
97
98private:
99 static Type type( const QString& typeName );
100 static QString typeName( Type type );
101
102 void cleanMetaNodes( QDomElement de );
103
104 void mapSrcAttributeInElementsWithResources(const QMap<QString, QString>& map);
105
106 // helper upgrade routines
107 void upgrade_0_2_1_20070501();
108 void upgrade_0_2_1_20070508();
109 void upgrade_0_3_0_rc2();
110 void upgrade_0_3_0();
111 void upgrade_0_4_0_20080104();
112 void upgrade_0_4_0_20080118();
113 void upgrade_0_4_0_20080129();
114 void upgrade_0_4_0_20080409();
115 void upgrade_0_4_0_20080607();
116 void upgrade_0_4_0_20080622();
117 void upgrade_0_4_0_beta1();
118 void upgrade_0_4_0_rc2();
119 void upgrade_1_0_99();
120 void upgrade_1_1_0();
121 void upgrade_1_1_91();
122 void upgrade_1_2_0_rc3();
123 void upgrade_1_3_0();
124 void upgrade_noHiddenClipNames();
125 void upgrade_automationNodes();
126 void upgrade_extendedNoteRange();
127 void upgrade_defaultTripleOscillatorHQ();
128 void upgrade_mixerRename();
129 void upgrade_bbTcoRename();
130 void upgrade_sampleAndHold();
131 void upgrade_midiCCIndexing();
132 void upgrade_loopsRename();
133 void upgrade_noteTypes();
134 void upgrade_fixCMTDelays();
135 void upgrade_fixBassLoopsTypo();
136 void findProblematicLadspaPlugins();
137 void upgrade_noHiddenAutomationTracks();
138
139 // List of all upgrade methods
140 static const std::vector<UpgradeMethod> UPGRADE_METHODS;
141 // List of ProjectVersions for the legacyFileVersion method
142 static const std::vector<ProjectVersion> UPGRADE_VERSIONS;
143
144 // Map with DOM elements that access resources (for making bundles)
145 using ResourcesMap = std::map<QString, std::vector<QString>>;
147
148 void upgrade();
149
150 void loadData( const QByteArray & _data, const QString & _sourceFile );
151
152 QString m_fileName;
153 QDomElement m_content;
154 QDomElement m_head;
156 unsigned int m_fileVersion;
157} ;
158
159
160} // namespace lmms
161
162#endif // LMMS_DATA_FILE_H
CAdPlugDatabase::CRecord::RecordType type
Definition adplugdb.cpp:93
Definition DataFile.h:44
Type m_type
Definition DataFile.h:155
bool copyResources(const QString &resourcesDir)
Copies resources to the resourcesDir and changes the DataFile to use local paths to them.
Definition DataFile.cpp:446
QDomElement & head()
Definition DataFile.h:86
void upgrade()
Definition DataFile.cpp:2087
QString nameWithExtension(const QString &fn) const
Definition DataFile.cpp:262
QString m_fileName
The origin file name or "" if this DataFile didn't originate from a file.
Definition DataFile.h:152
void write(QTextStream &strm)
Definition DataFile.cpp:301
bool hasLocalPlugins(QDomElement parent=QDomElement(), bool firstCall=true) const
This recursive method will go through all XML nodes of the DataFile and check whether any of them hav...
Definition DataFile.cpp:544
void loadData(const QByteArray &_data, const QString &_sourceFile)
Definition DataFile.cpp:2128
Type type() const
Definition DataFile.h:91
static const std::vector< ProjectVersion > UPGRADE_VERSIONS
Definition DataFile.h:142
QDomElement m_head
Definition DataFile.h:154
QDomElement & content()
Definition DataFile.h:81
static const ResourcesMap ELEMENTS_WITH_RESOURCES
Definition DataFile.h:146
unsigned int m_fileVersion
Definition DataFile.h:156
DataFile(const QString &fileName)
Definition DataFile.cpp:156
std::map< QString, std::vector< QString > > ResourcesMap
Definition DataFile.h:145
static const std::vector< UpgradeMethod > UPGRADE_METHODS
Definition DataFile.h:140
QDomElement m_content
Definition DataFile.h:153
virtual ~DataFile()=default
Type
Definition DataFile.h:50
void(DataFile::*)() UpgradeMethod
Definition DataFile.h:46
bool validate(QString extension)
validate performs basic validation, compared to file extension.
Definition DataFile.cpp:200
bool writeFile(const QString &fn, bool withResources=false)
Definition DataFile.cpp:315
Definition MidiClip.h:46
Version number parsing and comparison.
Definition ProjectVersion.h:43
static uintptr_t parent
Definition pugl.h:1644
JSAMPIMAGE data
Definition jpeglib.h:945
Definition AudioAlsa.cpp:35
const char const char const char const char char * fn
Definition swell-functions.h:168
#define void
Definition unzip.h:396