2014-12-10 18:18:22 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vabstractconverter.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 10 12, 2014
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2014-12-10 18:18:22 +01:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2014-12-10 18:18:22 +01:00
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef VABSTRACTCONVERTER_H
|
|
|
|
#define VABSTRACTCONVERTER_H
|
|
|
|
|
2016-08-08 16:57:05 +02:00
|
|
|
#include <qcompilerdetection.h>
|
|
|
|
|
|
|
|
#if !defined(Q_OS_OSX) && !defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <sys/sysmacros.h>
|
2016-08-08 14:14:21 +02:00
|
|
|
#endif
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QString>
|
2017-02-04 12:28:47 +01:00
|
|
|
#include <QTemporaryFile>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QtGlobal>
|
|
|
|
|
2014-12-11 16:12:16 +01:00
|
|
|
#include "vdomdocument.h"
|
2014-12-10 18:18:22 +01:00
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
template <class Key, class T> class QMap;
|
|
|
|
|
2018-07-26 20:21:08 +02:00
|
|
|
#define FORMAT_VERSION(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
|
2016-07-07 17:04:26 +02:00
|
|
|
|
2014-12-11 16:12:16 +01:00
|
|
|
class VAbstractConverter :public VDomDocument
|
2014-12-10 18:18:22 +01:00
|
|
|
{
|
2014-12-31 13:28:08 +01:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(VAbstractConverter)
|
2014-12-10 18:18:22 +01:00
|
|
|
public:
|
2015-10-12 13:52:48 +02:00
|
|
|
explicit VAbstractConverter(const QString &fileName);
|
2017-04-01 16:27:55 +02:00
|
|
|
virtual ~VAbstractConverter() Q_DECL_EQ_DEFAULT;
|
2014-12-11 20:44:48 +01:00
|
|
|
|
2017-02-07 12:44:33 +01:00
|
|
|
QString Convert();
|
2014-12-11 21:54:33 +01:00
|
|
|
|
2018-04-13 07:43:44 +02:00
|
|
|
int GetCurrentFormatVersion() const;
|
2017-04-12 08:49:05 +02:00
|
|
|
QString GetVersionStr() const;
|
|
|
|
|
2016-07-15 11:00:00 +02:00
|
|
|
static int GetVersion(const QString &version);
|
|
|
|
|
2014-12-11 20:44:48 +01:00
|
|
|
protected:
|
2017-02-04 12:28:47 +01:00
|
|
|
int m_ver;
|
|
|
|
QString m_convertedFileName;
|
|
|
|
|
2016-01-19 16:25:46 +01:00
|
|
|
void ValidateInputFile(const QString ¤tSchema) const;
|
|
|
|
Q_NORETURN void InvalidVersion(int ver) const;
|
2017-02-07 12:44:33 +01:00
|
|
|
void Save();
|
2014-12-16 08:42:24 +01:00
|
|
|
void SetVersion(const QString &version);
|
2014-12-11 20:44:48 +01:00
|
|
|
|
|
|
|
virtual int MinVer() const =0;
|
|
|
|
virtual int MaxVer() const =0;
|
|
|
|
|
|
|
|
virtual QString MinVerStr() const =0;
|
|
|
|
virtual QString MaxVerStr() const =0;
|
2014-12-11 16:12:16 +01:00
|
|
|
|
2014-12-11 21:16:03 +01:00
|
|
|
virtual QString XSDSchema(int ver) const =0;
|
2014-12-16 08:42:24 +01:00
|
|
|
virtual void ApplyPatches() =0;
|
2016-01-19 16:25:46 +01:00
|
|
|
virtual void DowngradeToCurrentMaxVersion() =0;
|
2014-12-11 21:16:03 +01:00
|
|
|
|
2017-02-04 12:28:47 +01:00
|
|
|
virtual bool IsReadOnly() const =0;
|
|
|
|
|
2015-08-27 10:25:11 +02:00
|
|
|
void Replace(QString &formula, const QString &newName, int position, const QString &token, int &bias) const;
|
|
|
|
void CorrectionsPositions(int position, int bias, QMap<int, QString> &tokens) const;
|
|
|
|
static void BiasTokens(int position, int bias, QMap<int, QString> &tokens);
|
|
|
|
|
2014-12-11 16:12:16 +01:00
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(VAbstractConverter)
|
2014-12-11 16:51:24 +01:00
|
|
|
|
2017-02-04 12:28:47 +01:00
|
|
|
QTemporaryFile m_tmpFile;
|
|
|
|
|
2016-07-15 11:00:00 +02:00
|
|
|
static void ValidateVersion(const QString &version);
|
2015-08-27 10:45:31 +02:00
|
|
|
|
|
|
|
void ReserveFile() const;
|
2014-12-10 18:18:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VABSTRACTCONVERTER_H
|