Path to file version sxd schema.

--HG--
branch : feature
This commit is contained in:
dismine 2014-12-11 22:16:03 +02:00
parent 1c4af06343
commit 941b43b5b5
5 changed files with 34 additions and 13 deletions

View File

@ -2351,7 +2351,7 @@ void MainWindow::LoadPattern(const QString &fileName)
qApp->setOpeningPattern();//Begin opening file
try
{
VDomDocument::ValidateXML(VPatternConverter::CurrentSchema(), fileName);
VDomDocument::ValidateXML(VPatternConverter::CurrentSchema, fileName);
doc->setXMLContent(fileName);
qApp->setPatternUnit(doc->MUnit());

View File

@ -31,12 +31,11 @@
//---------------------------------------------------------------------------------------------------------------------
VAbstractConverter::VAbstractConverter(const QString &fileName)
:VDomDocument(), fileName(fileName)
:VDomDocument(), ver(0x0), fileName(fileName)
{
this->setXMLContent(fileName);
const QString version = GetVersionStr();
int ver = GetVersion(version);
CheckVersion(ver);
ver = GetVersion(version);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -39,7 +39,10 @@ public:
virtual ~VAbstractConverter();
protected:
int ver;
int GetVersion(const QString &version) const;
void CheckVersion(int ver) const;
virtual int MinVer() const =0;
virtual int MaxVer() const =0;
@ -47,6 +50,8 @@ protected:
virtual QString MinVerStr() const =0;
virtual QString MaxVerStr() const =0;
virtual QString XSDSchema(int ver) const =0;
private:
Q_DISABLE_COPY(VAbstractConverter)
QString fileName;
@ -54,7 +59,6 @@ private:
QString GetVersionStr() const;
void ValidateVersion(const QString &version) const;
void CheckVersion(int ver) const;
};
#endif // VABSTRACTCONVERTER_H

View File

@ -27,26 +27,23 @@
*************************************************************************/
#include "vpatternconverter.h"
#include "exception/vexception.h"
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.1");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.1.1");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.1.1.xsd");
//---------------------------------------------------------------------------------------------------------------------
VPatternConverter::VPatternConverter(const QString &fileName)
:VAbstractConverter(fileName)
{
QString schema = XSDSchema(ver);
}
//---------------------------------------------------------------------------------------------------------------------
VPatternConverter::~VPatternConverter()
{}
//---------------------------------------------------------------------------------------------------------------------
QString VPatternConverter::CurrentSchema()
{
return QStringLiteral("://schema/pattern/v0.1.1.xsd");
}
//---------------------------------------------------------------------------------------------------------------------
int VPatternConverter::MinVer() const
{
@ -70,3 +67,21 @@ QString VPatternConverter::MaxVerStr() const
{
return PatternMaxVerStr;
}
//---------------------------------------------------------------------------------------------------------------------
QString VPatternConverter::XSDSchema(int ver) const
{
CheckVersion(ver);
switch(ver)
{
case (0x000101):
return CurrentSchema;
default:
{
const QString errorMsg(tr("Unexpected version \"%1\".").arg(ver, 0, 16));
throw VException(errorMsg);
break;
}
}
}

View File

@ -37,8 +37,8 @@ public:
VPatternConverter(const QString &fileName);
virtual ~VPatternConverter();
static QString CurrentSchema();
static const QString PatternMaxVerStr;
static const QString CurrentSchema;
protected:
virtual int MinVer() const;
@ -46,6 +46,9 @@ protected:
virtual QString MinVerStr() const;
virtual QString MaxVerStr() const;
QString XSDSchema(int ver) const;
private:
Q_DISABLE_COPY(VPatternConverter)
static const QString PatternMinVerStr;