Use constexpr function instead of macros.

This commit is contained in:
Roman Telezhynskyi 2021-09-11 12:24:09 +03:00
parent 3a76f4a2d8
commit 18e52f4a70
13 changed files with 391 additions and 388 deletions

View File

@ -37,7 +37,10 @@
#include "vdomdocument.h" #include "vdomdocument.h"
#define FORMAT_VERSION(major, minor, patch) ((major<<16)|(minor<<8)|(patch)) constexpr inline auto FormatVersion(unsigned major, unsigned minor, unsigned patch) -> unsigned
{
return ((major<<16u)|(minor<<8u)|patch);
}
class VAbstractConverter :public VDomDocument class VAbstractConverter :public VDomDocument
{ {

View File

@ -80,7 +80,7 @@ QString VLabelTemplateConverter::XSDSchema(int ver) const
{ {
switch (ver) switch (ver)
{ {
case (0x010000): case (FormatVersion(1, 0, 0)):
return CurrentSchema; return CurrentSchema;
default: default:
InvalidVersion(ver); InvalidVersion(ver);
@ -94,7 +94,7 @@ void VLabelTemplateConverter::ApplyPatches()
{ {
switch (m_ver) switch (m_ver)
{ {
case (0x010000): case (FormatVersion(1, 0, 0)):
break; break;
default: default:
InvalidVersion(m_ver); InvalidVersion(m_ver);

View File

@ -39,8 +39,8 @@ public:
static const QString LabelTemplateMaxVerStr; static const QString LabelTemplateMaxVerStr;
static const QString CurrentSchema; static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int LabelTemplateMinVer = FORMAT_VERSION(1, 0, 0); static Q_DECL_CONSTEXPR const int LabelTemplateMinVer = FormatVersion(1, 0, 0);
static Q_DECL_CONSTEXPR const int LabelTemplateMaxVer = FORMAT_VERSION(1, 0, 0); static Q_DECL_CONSTEXPR const int LabelTemplateMaxVer = FormatVersion(1, 0, 0);
protected: protected:
virtual int MinVer() const override; virtual int MinVer() const override;

View File

@ -77,7 +77,7 @@ QString VLayoutConverter::XSDSchema(int ver) const
{ {
QHash <int, QString> schemas = QHash <int, QString> schemas =
{ {
std::make_pair(FORMAT_VERSION(0, 1, 0), CurrentSchema) std::make_pair(FormatVersion(0, 1, 0), CurrentSchema)
}; };
if (schemas.contains(ver)) if (schemas.contains(ver))
@ -93,7 +93,7 @@ void VLayoutConverter::ApplyPatches()
{ {
switch (m_ver) switch (m_ver)
{ {
case (FORMAT_VERSION(0, 1, 0)): case (FormatVersion(0, 1, 0)):
break; break;
default: default:
InvalidVersion(m_ver); InvalidVersion(m_ver);

View File

@ -44,8 +44,8 @@ public:
static const QString LayoutMaxVerStr; static const QString LayoutMaxVerStr;
static const QString CurrentSchema; static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int LayoutMinVer = FORMAT_VERSION(0, 1, 0); static Q_DECL_CONSTEXPR const int LayoutMinVer = FormatVersion(0, 1, 0);
static Q_DECL_CONSTEXPR const int LayoutMaxVer = FORMAT_VERSION(0, 1, 0); static Q_DECL_CONSTEXPR const int LayoutMaxVer = FormatVersion(0, 1, 0);
protected: protected:
virtual int MinVer() const override; virtual int MinVer() const override;

File diff suppressed because it is too large Load Diff

View File

@ -52,8 +52,8 @@ public:
static const QString PatternMaxVerStr; static const QString PatternMaxVerStr;
static const QString CurrentSchema; static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int PatternMinVer = FORMAT_VERSION(0, 1, 4); static Q_DECL_CONSTEXPR const int PatternMinVer = FormatVersion(0, 1, 4);
static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 12); static Q_DECL_CONSTEXPR const int PatternMaxVer = FormatVersion(0, 8, 12);
protected: protected:
virtual int MinVer() const override; virtual int MinVer() const override;

View File

@ -83,14 +83,14 @@ QString VVITConverter::XSDSchema(int ver) const
{ {
QHash <int, QString> schemas = QHash <int, QString> schemas =
{ {
std::make_pair(FORMAT_VERSION(0, 2, 0), QStringLiteral("://schema/individual_measurements/v0.2.0.xsd")), std::make_pair(FormatVersion(0, 2, 0), QStringLiteral("://schema/individual_measurements/v0.2.0.xsd")),
std::make_pair(FORMAT_VERSION(0, 3, 0), QStringLiteral("://schema/individual_measurements/v0.3.0.xsd")), std::make_pair(FormatVersion(0, 3, 0), QStringLiteral("://schema/individual_measurements/v0.3.0.xsd")),
std::make_pair(FORMAT_VERSION(0, 3, 1), QStringLiteral("://schema/individual_measurements/v0.3.1.xsd")), std::make_pair(FormatVersion(0, 3, 1), QStringLiteral("://schema/individual_measurements/v0.3.1.xsd")),
std::make_pair(FORMAT_VERSION(0, 3, 2), QStringLiteral("://schema/individual_measurements/v0.3.2.xsd")), std::make_pair(FormatVersion(0, 3, 2), QStringLiteral("://schema/individual_measurements/v0.3.2.xsd")),
std::make_pair(FORMAT_VERSION(0, 3, 3), QStringLiteral("://schema/individual_measurements/v0.3.3.xsd")), std::make_pair(FormatVersion(0, 3, 3), QStringLiteral("://schema/individual_measurements/v0.3.3.xsd")),
std::make_pair(FORMAT_VERSION(0, 4, 0), QStringLiteral("://schema/individual_measurements/v0.4.0.xsd")), std::make_pair(FormatVersion(0, 4, 0), QStringLiteral("://schema/individual_measurements/v0.4.0.xsd")),
std::make_pair(FORMAT_VERSION(0, 5, 0), QStringLiteral("://schema/individual_measurements/v0.5.0.xsd")), std::make_pair(FormatVersion(0, 5, 0), QStringLiteral("://schema/individual_measurements/v0.5.0.xsd")),
std::make_pair(FORMAT_VERSION(0, 5, 1), CurrentSchema), std::make_pair(FormatVersion(0, 5, 1), CurrentSchema),
}; };
if (schemas.contains(ver)) if (schemas.contains(ver))
@ -108,35 +108,35 @@ void VVITConverter::ApplyPatches()
{ {
switch (m_ver) switch (m_ver)
{ {
case (FORMAT_VERSION(0, 2, 0)): case (FormatVersion(0, 2, 0)):
ToV0_3_0(); ToV0_3_0();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 0))); ValidateXML(XSDSchema(FormatVersion(0, 3, 0)));
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 3, 0)): case (FormatVersion(0, 3, 0)):
ToV0_3_1(); ToV0_3_1();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 1))); ValidateXML(XSDSchema(FormatVersion(0, 3, 1)));
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 3, 1)): case (FormatVersion(0, 3, 1)):
ToV0_3_2(); ToV0_3_2();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 2))); ValidateXML(XSDSchema(FormatVersion(0, 3, 2)));
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 3, 2)): case (FormatVersion(0, 3, 2)):
ToV0_3_3(); ToV0_3_3();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 3, 3))); ValidateXML(XSDSchema(FormatVersion(0, 3, 3)));
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 3, 3)): case (FormatVersion(0, 3, 3)):
ToV0_4_0(); ToV0_4_0();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 0))); ValidateXML(XSDSchema(FormatVersion(0, 4, 0)));
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 4, 0)): case (FormatVersion(0, 4, 0)):
ToV0_5_0(); ToV0_5_0();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 5, 0))); ValidateXML(XSDSchema(FormatVersion(0, 5, 0)));
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 5, 0)): case (FormatVersion(0, 5, 0)):
ToV0_5_1(); ToV0_5_1();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 5, 1))); ValidateXML(XSDSchema(FormatVersion(0, 5, 1)));
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 5, 1)): case (FormatVersion(0, 5, 1)):
break; break;
default: default:
InvalidVersion(m_ver); InvalidVersion(m_ver);
@ -155,7 +155,7 @@ void VVITConverter::DowngradeToCurrentMaxVersion()
bool VVITConverter::IsReadOnly() const bool VVITConverter::IsReadOnly() const
{ {
// Check if attribute read-only was not changed in file format // Check if attribute read-only was not changed in file format
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMaxVer == FORMAT_VERSION(0, 5, 1), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMaxVer == FormatVersion(0, 5, 1),
"Check attribute read-only."); "Check attribute read-only.");
// Possibly in future attribute read-only will change position etc. // Possibly in future attribute read-only will change position etc.
@ -169,7 +169,7 @@ bool VVITConverter::IsReadOnly() const
void VVITConverter::AddNewTagsForV0_3_0() void VVITConverter::AddNewTagsForV0_3_0()
{ {
// TODO. Delete if minimal supported version is 0.3.0 // TODO. Delete if minimal supported version is 0.3.0
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FORMAT_VERSION(0, 3, 0), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 0),
"Time to refactor the code."); "Time to refactor the code.");
QDomElement rootElement = this->documentElement(); QDomElement rootElement = this->documentElement();
@ -185,7 +185,7 @@ void VVITConverter::AddNewTagsForV0_3_0()
QString VVITConverter::MUnitV0_2_0() QString VVITConverter::MUnitV0_2_0()
{ {
// TODO. Delete if minimal supported version is 0.3.0 // TODO. Delete if minimal supported version is 0.3.0
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FORMAT_VERSION(0, 3, 0), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 0),
"Time to refactor the code."); "Time to refactor the code.");
return UniqueTagText(QStringLiteral("unit"), QStringLiteral("cm")); return UniqueTagText(QStringLiteral("unit"), QStringLiteral("cm"));
@ -195,7 +195,7 @@ QString VVITConverter::MUnitV0_2_0()
void VVITConverter::ConvertMeasurementsToV0_3_0() void VVITConverter::ConvertMeasurementsToV0_3_0()
{ {
// TODO. Delete if minimal supported version is 0.3.0 // TODO. Delete if minimal supported version is 0.3.0
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FORMAT_VERSION(0, 3, 0), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 0),
"Time to refactor the code."); "Time to refactor the code.");
const QString tagBM = QStringLiteral("body-measurements"); const QString tagBM = QStringLiteral("body-measurements");
@ -238,7 +238,7 @@ void VVITConverter::ConvertMeasurementsToV0_3_0()
QDomElement VVITConverter::AddMV0_3_0(const QString &name, qreal value) QDomElement VVITConverter::AddMV0_3_0(const QString &name, qreal value)
{ {
// TODO. Delete if minimal supported version is 0.3.0 // TODO. Delete if minimal supported version is 0.3.0
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FORMAT_VERSION(0, 3, 0), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 0),
"Time to refactor the code."); "Time to refactor the code.");
QDomElement element = createElement(QStringLiteral("m")); QDomElement element = createElement(QStringLiteral("m"));
@ -255,7 +255,7 @@ QDomElement VVITConverter::AddMV0_3_0(const QString &name, qreal value)
void VVITConverter::GenderV0_3_1() void VVITConverter::GenderV0_3_1()
{ {
// TODO. Delete if minimal supported version is 0.3.1 // TODO. Delete if minimal supported version is 0.3.1
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FORMAT_VERSION(0, 3, 1), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 1),
"Time to refactor the code."); "Time to refactor the code.");
const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral("sex")); const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral("sex"));
@ -268,7 +268,7 @@ void VVITConverter::GenderV0_3_1()
void VVITConverter::PM_SystemV0_3_2() void VVITConverter::PM_SystemV0_3_2()
{ {
// TODO. Delete if minimal supported version is 0.3.2 // TODO. Delete if minimal supported version is 0.3.2
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FORMAT_VERSION(0, 3, 2), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 2),
"Time to refactor the code."); "Time to refactor the code.");
const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral("personal")); const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral("personal"));
@ -282,7 +282,7 @@ void VVITConverter::PM_SystemV0_3_2()
void VVITConverter::ConvertMeasurementsToV0_3_3() void VVITConverter::ConvertMeasurementsToV0_3_3()
{ {
// TODO. Delete if minimal supported version is 0.3.3 // TODO. Delete if minimal supported version is 0.3.3
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FORMAT_VERSION(0, 3, 3), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 3),
"Time to refactor the code."); "Time to refactor the code.");
const QMap<QString, QString> names = OldNamesToNewNames_InV0_3_3(); const QMap<QString, QString> names = OldNamesToNewNames_InV0_3_3();
@ -365,7 +365,7 @@ void VVITConverter::ConverCustomerNameToV0_4_0()
void VVITConverter::ToV0_3_0() void VVITConverter::ToV0_3_0()
{ {
// TODO. Delete if minimal supported version is 0.3.0 // TODO. Delete if minimal supported version is 0.3.0
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FORMAT_VERSION(0, 3, 0), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 0),
"Time to refactor the code."); "Time to refactor the code.");
AddRootComment(); AddRootComment();
@ -379,7 +379,7 @@ void VVITConverter::ToV0_3_0()
void VVITConverter::ToV0_3_1() void VVITConverter::ToV0_3_1()
{ {
// TODO. Delete if minimal supported version is 0.3.1 // TODO. Delete if minimal supported version is 0.3.1
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FORMAT_VERSION(0, 3, 1), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 1),
"Time to refactor the code."); "Time to refactor the code.");
SetVersion(QStringLiteral("0.3.1")); SetVersion(QStringLiteral("0.3.1"));
@ -391,7 +391,7 @@ void VVITConverter::ToV0_3_1()
void VVITConverter::ToV0_3_2() void VVITConverter::ToV0_3_2()
{ {
// TODO. Delete if minimal supported version is 0.3.2 // TODO. Delete if minimal supported version is 0.3.2
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FORMAT_VERSION(0, 3, 2), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 2),
"Time to refactor the code."); "Time to refactor the code.");
SetVersion(QStringLiteral("0.3.2")); SetVersion(QStringLiteral("0.3.2"));
@ -403,7 +403,7 @@ void VVITConverter::ToV0_3_2()
void VVITConverter::ToV0_3_3() void VVITConverter::ToV0_3_3()
{ {
// TODO. Delete if minimal supported version is 0.3.3 // TODO. Delete if minimal supported version is 0.3.3
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FORMAT_VERSION(0, 3, 3), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 3, 3),
"Time to refactor the code."); "Time to refactor the code.");
SetVersion(QStringLiteral("0.3.3")); SetVersion(QStringLiteral("0.3.3"));
@ -415,7 +415,7 @@ void VVITConverter::ToV0_3_3()
void VVITConverter::ToV0_4_0() void VVITConverter::ToV0_4_0()
{ {
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FORMAT_VERSION(0, 4, 0), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 4, 0),
"Time to refactor the code."); "Time to refactor the code.");
SetVersion(QStringLiteral("0.4.0")); SetVersion(QStringLiteral("0.4.0"));
@ -427,7 +427,7 @@ void VVITConverter::ToV0_4_0()
void VVITConverter::ToV0_5_0() void VVITConverter::ToV0_5_0()
{ {
// TODO. Delete if minimal supported version is 0.5.0 // TODO. Delete if minimal supported version is 0.5.0
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FORMAT_VERSION(0, 5, 0), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 5, 0),
"Time to refactor the code."); "Time to refactor the code.");
SetVersion(QStringLiteral("0.5.0")); SetVersion(QStringLiteral("0.5.0"));
@ -438,7 +438,7 @@ void VVITConverter::ToV0_5_0()
void VVITConverter::ToV0_5_1() void VVITConverter::ToV0_5_1()
{ {
// TODO. Delete if minimal supported version is 0.5.1 // TODO. Delete if minimal supported version is 0.5.1
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FORMAT_VERSION(0, 5, 1), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 5, 1),
"Time to refactor the code."); "Time to refactor the code.");
SetVersion(QStringLiteral("0.5.1")); SetVersion(QStringLiteral("0.5.1"));

View File

@ -48,8 +48,8 @@ public:
static const QString MeasurementMaxVerStr; static const QString MeasurementMaxVerStr;
static const QString CurrentSchema; static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int MeasurementMinVer = FORMAT_VERSION(0, 2, 0); static Q_DECL_CONSTEXPR const int MeasurementMinVer = FormatVersion(0, 2, 0);
static Q_DECL_CONSTEXPR const int MeasurementMaxVer = FORMAT_VERSION(0, 5, 1); static Q_DECL_CONSTEXPR const int MeasurementMaxVer = FormatVersion(0, 5, 1);
protected: protected:
virtual int MinVer() const override; virtual int MinVer() const override;

View File

@ -77,14 +77,14 @@ QString VVSTConverter::XSDSchema(int ver) const
{ {
QHash <int, QString> schemas = QHash <int, QString> schemas =
{ {
std::make_pair(FORMAT_VERSION(0, 3, 0), QStringLiteral("://schema/multisize_measurements/v0.3.0.xsd")), std::make_pair(FormatVersion(0, 3, 0), QStringLiteral("://schema/multisize_measurements/v0.3.0.xsd")),
std::make_pair(FORMAT_VERSION(0, 4, 0), QStringLiteral("://schema/multisize_measurements/v0.4.0.xsd")), std::make_pair(FormatVersion(0, 4, 0), QStringLiteral("://schema/multisize_measurements/v0.4.0.xsd")),
std::make_pair(FORMAT_VERSION(0, 4, 1), QStringLiteral("://schema/multisize_measurements/v0.4.1.xsd")), std::make_pair(FormatVersion(0, 4, 1), QStringLiteral("://schema/multisize_measurements/v0.4.1.xsd")),
std::make_pair(FORMAT_VERSION(0, 4, 2), QStringLiteral("://schema/multisize_measurements/v0.4.2.xsd")), std::make_pair(FormatVersion(0, 4, 2), QStringLiteral("://schema/multisize_measurements/v0.4.2.xsd")),
std::make_pair(FORMAT_VERSION(0, 4, 3), QStringLiteral("://schema/multisize_measurements/v0.4.3.xsd")), std::make_pair(FormatVersion(0, 4, 3), QStringLiteral("://schema/multisize_measurements/v0.4.3.xsd")),
std::make_pair(FORMAT_VERSION(0, 4, 4), QStringLiteral("://schema/multisize_measurements/v0.4.4.xsd")), std::make_pair(FormatVersion(0, 4, 4), QStringLiteral("://schema/multisize_measurements/v0.4.4.xsd")),
std::make_pair(FORMAT_VERSION(0, 5, 0), QStringLiteral("://schema/multisize_measurements/v0.5.0.xsd")), std::make_pair(FormatVersion(0, 5, 0), QStringLiteral("://schema/multisize_measurements/v0.5.0.xsd")),
std::make_pair(FORMAT_VERSION(0, 5, 1), CurrentSchema), std::make_pair(FormatVersion(0, 5, 1), CurrentSchema),
}; };
if (schemas.contains(ver)) if (schemas.contains(ver))
@ -102,35 +102,35 @@ void VVSTConverter::ApplyPatches()
{ {
switch (m_ver) switch (m_ver)
{ {
case (FORMAT_VERSION(0, 3, 0)): case (FormatVersion(0, 3, 0)):
ToV0_4_0(); ToV0_4_0();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 0))); ValidateXML(XSDSchema(FormatVersion(0, 4, 0)));
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 4, 0)): case (FormatVersion(0, 4, 0)):
ToV0_4_1(); ToV0_4_1();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 1))); ValidateXML(XSDSchema(FormatVersion(0, 4, 1)));
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 4, 1)): case (FormatVersion(0, 4, 1)):
ToV0_4_2(); ToV0_4_2();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 2))); ValidateXML(XSDSchema(FormatVersion(0, 4, 2)));
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 4, 2)): case (FormatVersion(0, 4, 2)):
ToV0_4_3(); ToV0_4_3();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 3))); ValidateXML(XSDSchema(FormatVersion(0, 4, 3)));
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 4, 3)): case (FormatVersion(0, 4, 3)):
ToV0_4_4(); ToV0_4_4();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 4))); ValidateXML(XSDSchema(FormatVersion(0, 4, 4)));
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 4, 4)): case (FormatVersion(0, 4, 4)):
ToV0_5_0(); ToV0_5_0();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 5, 0))); ValidateXML(XSDSchema(FormatVersion(0, 5, 0)));
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 5, 0)): case (FormatVersion(0, 5, 0)):
ToV0_5_1(); ToV0_5_1();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 5, 1))); ValidateXML(XSDSchema(FormatVersion(0, 5, 1)));
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 5, 1)): case (FormatVersion(0, 5, 1)):
break; break;
default: default:
InvalidVersion(m_ver); InvalidVersion(m_ver);
@ -149,7 +149,7 @@ void VVSTConverter::DowngradeToCurrentMaxVersion()
bool VVSTConverter::IsReadOnly() const bool VVSTConverter::IsReadOnly() const
{ {
// Check if attribute read-only was not changed in file format // Check if attribute read-only was not changed in file format
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMaxVer == FORMAT_VERSION(0, 5, 1), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMaxVer == FormatVersion(0, 5, 1),
"Check attribute read-only."); "Check attribute read-only.");
// Possibly in future attribute read-only will change position etc. // Possibly in future attribute read-only will change position etc.
@ -163,7 +163,7 @@ bool VVSTConverter::IsReadOnly() const
void VVSTConverter::AddNewTagsForV0_4_0() void VVSTConverter::AddNewTagsForV0_4_0()
{ {
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FORMAT_VERSION(0, 4, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 0),
"Time to refactor the code."); "Time to refactor the code.");
QDomElement rootElement = this->documentElement(); QDomElement rootElement = this->documentElement();
@ -179,7 +179,7 @@ void VVSTConverter::AddNewTagsForV0_4_0()
void VVSTConverter::RemoveTagsForV0_4_0() void VVSTConverter::RemoveTagsForV0_4_0()
{ {
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FORMAT_VERSION(0, 4, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 0),
"Time to refactor the code."); "Time to refactor the code.");
QDomElement rootElement = this->documentElement(); QDomElement rootElement = this->documentElement();
@ -205,7 +205,7 @@ void VVSTConverter::RemoveTagsForV0_4_0()
void VVSTConverter::ConvertMeasurementsToV0_4_0() void VVSTConverter::ConvertMeasurementsToV0_4_0()
{ {
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FORMAT_VERSION(0, 4, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 0),
"Time to refactor the code."); "Time to refactor the code.");
const QString tagBM = QStringLiteral("body-measurements"); const QString tagBM = QStringLiteral("body-measurements");
@ -255,7 +255,7 @@ void VVSTConverter::ConvertMeasurementsToV0_4_0()
QDomElement VVSTConverter::AddMV0_4_0(const QString &name, qreal value, qreal sizeIncrease, qreal heightIncrease) QDomElement VVSTConverter::AddMV0_4_0(const QString &name, qreal value, qreal sizeIncrease, qreal heightIncrease)
{ {
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FORMAT_VERSION(0, 4, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 0),
"Time to refactor the code."); "Time to refactor the code.");
QDomElement element = createElement(QStringLiteral("m")); QDomElement element = createElement(QStringLiteral("m"));
@ -274,7 +274,7 @@ QDomElement VVSTConverter::AddMV0_4_0(const QString &name, qreal value, qreal si
void VVSTConverter::PM_SystemV0_4_1() void VVSTConverter::PM_SystemV0_4_1()
{ {
// TODO. Delete if minimal supported version is 0.4.1 // TODO. Delete if minimal supported version is 0.4.1
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FORMAT_VERSION(0, 4, 1), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 1),
"Time to refactor the code."); "Time to refactor the code.");
const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral("size")); const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral("size"));
@ -288,7 +288,7 @@ void VVSTConverter::PM_SystemV0_4_1()
void VVSTConverter::ConvertMeasurementsToV0_4_2() void VVSTConverter::ConvertMeasurementsToV0_4_2()
{ {
// TODO. Delete if minimal supported version is 0.4.2 // TODO. Delete if minimal supported version is 0.4.2
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FORMAT_VERSION(0, 4, 2), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 2),
"Time to refactor the code."); "Time to refactor the code.");
const QMap<QString, QString> names = OldNamesToNewNames_InV0_3_3(); const QMap<QString, QString> names = OldNamesToNewNames_InV0_3_3();
@ -321,7 +321,7 @@ void VVSTConverter::ConvertMeasurementsToV0_4_2()
void VVSTConverter::AddNewTagsForV0_5_0() void VVSTConverter::AddNewTagsForV0_5_0()
{ {
// TODO. Delete if minimal supported version is 0.5.0 // TODO. Delete if minimal supported version is 0.5.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FORMAT_VERSION(0, 5, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 0),
"Time to refactor the code."); "Time to refactor the code.");
QDomElement root = documentElement(); QDomElement root = documentElement();
@ -385,7 +385,7 @@ void VVSTConverter::AddNewTagsForV0_5_0()
void VVSTConverter::RemoveTagsForV0_5_0() void VVSTConverter::RemoveTagsForV0_5_0()
{ {
// TODO. Delete if minimal supported version is 0.5.0 // TODO. Delete if minimal supported version is 0.5.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FORMAT_VERSION(0, 5, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 0),
"Time to refactor the code."); "Time to refactor the code.");
QDomElement root = documentElement(); QDomElement root = documentElement();
@ -407,7 +407,7 @@ void VVSTConverter::RemoveTagsForV0_5_0()
void VVSTConverter::ConvertMeasurementsToV0_5_0() void VVSTConverter::ConvertMeasurementsToV0_5_0()
{ {
// TODO. Delete if minimal supported version is 0.5.0 // TODO. Delete if minimal supported version is 0.5.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FORMAT_VERSION(0, 5, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 0),
"Time to refactor the code."); "Time to refactor the code.");
const QDomNodeList measurements = elementsByTagName(QStringLiteral("m")); const QDomNodeList measurements = elementsByTagName(QStringLiteral("m"));
@ -427,7 +427,7 @@ void VVSTConverter::ConvertMeasurementsToV0_5_0()
void VVSTConverter::ToV0_4_0() void VVSTConverter::ToV0_4_0()
{ {
// TODO. Delete if minimal supported version is 0.4.0 // TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FORMAT_VERSION(0, 4, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 0),
"Time to refactor the code."); "Time to refactor the code.");
AddRootComment(); AddRootComment();
@ -442,7 +442,7 @@ void VVSTConverter::ToV0_4_0()
void VVSTConverter::ToV0_4_1() void VVSTConverter::ToV0_4_1()
{ {
// TODO. Delete if minimal supported version is 0.4.1 // TODO. Delete if minimal supported version is 0.4.1
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FORMAT_VERSION(0, 4, 1), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 1),
"Time to refactor the code."); "Time to refactor the code.");
SetVersion(QStringLiteral("0.4.1")); SetVersion(QStringLiteral("0.4.1"));
@ -454,7 +454,7 @@ void VVSTConverter::ToV0_4_1()
void VVSTConverter::ToV0_4_2() void VVSTConverter::ToV0_4_2()
{ {
// TODO. Delete if minimal supported version is 0.4.2 // TODO. Delete if minimal supported version is 0.4.2
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FORMAT_VERSION(0, 4, 2), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 2),
"Time to refactor the code."); "Time to refactor the code.");
SetVersion(QStringLiteral("0.4.2")); SetVersion(QStringLiteral("0.4.2"));
@ -466,7 +466,7 @@ void VVSTConverter::ToV0_4_2()
void VVSTConverter::ToV0_4_3() void VVSTConverter::ToV0_4_3()
{ {
// TODO. Delete if minimal supported version is 0.4.3 // TODO. Delete if minimal supported version is 0.4.3
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FORMAT_VERSION(0, 4, 3), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 3),
"Time to refactor the code."); "Time to refactor the code.");
SetVersion(QStringLiteral("0.4.3")); SetVersion(QStringLiteral("0.4.3"));
@ -477,7 +477,7 @@ void VVSTConverter::ToV0_4_3()
void VVSTConverter::ToV0_4_4() void VVSTConverter::ToV0_4_4()
{ {
// TODO. Delete if minimal supported version is 0.4.4 // TODO. Delete if minimal supported version is 0.4.4
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FORMAT_VERSION(0, 4, 4), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 4, 4),
"Time to refactor the code."); "Time to refactor the code.");
SetVersion(QStringLiteral("0.4.4")); SetVersion(QStringLiteral("0.4.4"));
@ -488,7 +488,7 @@ void VVSTConverter::ToV0_4_4()
void VVSTConverter::ToV0_5_0() void VVSTConverter::ToV0_5_0()
{ {
// TODO. Delete if minimal supported version is 0.5.0 // TODO. Delete if minimal supported version is 0.5.0
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FORMAT_VERSION(0, 5, 0), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 0),
"Time to refactor the code."); "Time to refactor the code.");
SetVersion(QStringLiteral("0.5.0")); SetVersion(QStringLiteral("0.5.0"));
@ -502,7 +502,7 @@ void VVSTConverter::ToV0_5_0()
void VVSTConverter::ToV0_5_1() void VVSTConverter::ToV0_5_1()
{ {
// TODO. Delete if minimal supported version is 0.5.1 // TODO. Delete if minimal supported version is 0.5.1
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FORMAT_VERSION(0, 5, 1), Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 1),
"Time to refactor the code."); "Time to refactor the code.");
SetVersion(QStringLiteral("0.5.1")); SetVersion(QStringLiteral("0.5.1"));

View File

@ -50,11 +50,11 @@ public:
static const QString CurrentSchema; static const QString CurrentSchema;
// GCC 4.6 doesn't allow constexpr and const together // GCC 4.6 doesn't allow constexpr and const together
#if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) <= 406 #if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) <= 406
static Q_DECL_CONSTEXPR int MeasurementMinVer = FORMAT_VERSION(0, 3, 0); static Q_DECL_CONSTEXPR int MeasurementMinVer = FormatVersion(0, 3, 0);
static Q_DECL_CONSTEXPR int MeasurementMaxVer = FORMAT_VERSION(0, 5, 1); static Q_DECL_CONSTEXPR int MeasurementMaxVer = FormatVersion(0, 5, 1);
#else #else
static Q_DECL_CONSTEXPR const int MeasurementMinVer = FORMAT_VERSION(0, 3, 0); static Q_DECL_CONSTEXPR const int MeasurementMinVer = FormatVersion(0, 3, 0);
static Q_DECL_CONSTEXPR const int MeasurementMaxVer = FORMAT_VERSION(0, 5, 1); static Q_DECL_CONSTEXPR const int MeasurementMaxVer = FormatVersion(0, 5, 1);
#endif #endif
protected: protected:

View File

@ -38,8 +38,8 @@ public:
static const QString WatermarkMaxVerStr; static const QString WatermarkMaxVerStr;
static const QString CurrentSchema; static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int WatermarkMinVer = FORMAT_VERSION(1, 0, 0); static Q_DECL_CONSTEXPR const int WatermarkMinVer = FormatVersion(1, 0, 0);
static Q_DECL_CONSTEXPR const int WatermarkMaxVer = FORMAT_VERSION(1, 0, 0); static Q_DECL_CONSTEXPR const int WatermarkMaxVer = FormatVersion(1, 0, 0);
protected: protected:
virtual int MinVer() const override; virtual int MinVer() const override;