2014-12-10 18:18:22 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vabstractconverter.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 10 12, 2014
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** 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
|
|
|
|
|
2014-12-11 16:12:16 +01:00
|
|
|
#include "vdomdocument.h"
|
2014-12-10 18:18:22 +01:00
|
|
|
|
2016-07-07 17:04:26 +02:00
|
|
|
#define CONVERTER_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
|
|
|
|
|
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);
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual ~VAbstractConverter() Q_DECL_OVERRIDE;
|
2014-12-11 20:44:48 +01:00
|
|
|
|
2014-12-16 08:42:24 +01:00
|
|
|
void Convert();
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual bool SaveDocument(const QString &fileName, QString &error) const Q_DECL_OVERRIDE;
|
2014-12-11 21:54:33 +01:00
|
|
|
|
2016-07-15 11:00:00 +02:00
|
|
|
static int GetVersion(const QString &version);
|
|
|
|
|
2014-12-11 20:44:48 +01:00
|
|
|
protected:
|
2014-12-11 21:16:03 +01:00
|
|
|
int ver;
|
2014-12-11 21:54:33 +01:00
|
|
|
QString fileName;
|
2014-12-11 21:16:03 +01:00
|
|
|
|
2016-01-19 16:25:46 +01:00
|
|
|
void ValidateInputFile(const QString ¤tSchema) const;
|
|
|
|
Q_NORETURN void InvalidVersion(int ver) const;
|
2014-12-16 08:42:24 +01:00
|
|
|
void Save() const;
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
|
|
QString GetVersionStr() const;
|
2014-12-11 19:40:26 +01:00
|
|
|
|
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
|