New format version. Basic implementation.
This commit is contained in:
parent
cea2671687
commit
daef1799ab
|
@ -65,6 +65,7 @@
|
|||
<file>schema/standard_measurements/v0.4.2.xsd</file>
|
||||
<file>schema/standard_measurements/v0.4.3.xsd</file>
|
||||
<file>schema/standard_measurements/v0.4.4.xsd</file>
|
||||
<file>schema/standard_measurements/v0.5.0.xsd</file>
|
||||
<file>schema/individual_measurements/v0.2.0.xsd</file>
|
||||
<file>schema/individual_measurements/v0.3.0.xsd</file>
|
||||
<file>schema/individual_measurements/v0.3.1.xsd</file>
|
||||
|
|
95
src/libs/ifc/schema/standard_measurements/v0.5.0.xsd
Normal file
95
src/libs/ifc/schema/standard_measurements/v0.5.0.xsd
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
|
||||
<xs:element name="vst">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="version" type="formatVersion"/>
|
||||
<xs:element name="read-only" type="xs:boolean"/>
|
||||
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
||||
<xs:element name="unit" type="units"/>
|
||||
<xs:element name="pm_system" type="psCode"/>
|
||||
<xs:element name="dimensions">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="dimension" minOccurs="0" maxOccurs="3">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="type" type="dimensionType" use="required"/>
|
||||
<xs:attribute name="base" type="dimesionValue" use="required"/>
|
||||
<xs:attribute name="min" type="dimesionValue" use="required"/>
|
||||
<xs:attribute name="max" type="dimesionValue" use="required"/>
|
||||
<xs:attribute name="step" type="dimensionStep" use="required"/>
|
||||
<xs:attribute name="circumference" type="xs:boolean"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="restrictions">
|
||||
</xs:element>
|
||||
<xs:element name="body-measurements">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="m" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="name" type="shortName" use="required"/>
|
||||
<xs:attribute name="base" type="xs:double" use="required"/>
|
||||
<xs:attribute name="height_increase" type="xs:double" use="required"/>
|
||||
<xs:attribute name="size_increase" type="xs:double" use="required"/>
|
||||
<xs:attribute name="full_name" type="xs:string"/>
|
||||
<xs:attribute name="description" type="xs:string"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:unique name="measurementName">
|
||||
<xs:selector xpath="body-measurements/m"/>
|
||||
<xs:field xpath="@name"/>
|
||||
</xs:unique>
|
||||
</xs:element>
|
||||
<xs:simpleType name="shortName">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="([^\p{Nd}\p{Zs}*/&|!<>^ \()\-−+.,٫, ٬.’=?:;'\"]){1,1}([^\p{Zs}*/&|!<>^ \()\-−+.,٫, ٬.’=?:;\"]){0,}"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="units">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="mm"/>
|
||||
<xs:enumeration value="cm"/>
|
||||
<xs:enumeration value="inch"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="formatVersion">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="psCode">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="(([0-9]|[1-4][0-9]|5[0-4])|998)"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="dimensionType">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="x"/>
|
||||
<xs:enumeration value="y"/>
|
||||
<xs:enumeration value="w"/>
|
||||
<xs:enumeration value="z"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="dimesionValue">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:minInclusive value="8"/>
|
||||
<xs:maxInclusive value="2720"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="dimensionStep">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:minInclusive value="0"/>
|
||||
<xs:maxInclusive value="8"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
|
@ -54,8 +54,8 @@
|
|||
*/
|
||||
|
||||
const QString VVSTConverter::MeasurementMinVerStr = QStringLiteral("0.3.0");
|
||||
const QString VVSTConverter::MeasurementMaxVerStr = QStringLiteral("0.4.4");
|
||||
const QString VVSTConverter::CurrentSchema = QStringLiteral("://schema/standard_measurements/v0.4.4.xsd");
|
||||
const QString VVSTConverter::MeasurementMaxVerStr = QStringLiteral("0.5.0");
|
||||
const QString VVSTConverter::CurrentSchema = QStringLiteral("://schema/standard_measurements/v0.5.0.xsd");
|
||||
|
||||
//VVSTConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
//VVSTConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
|
@ -75,25 +75,25 @@ VVSTConverter::VVSTConverter(const QString &fileName)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VVSTConverter::XSDSchema(int ver) const
|
||||
{
|
||||
switch (ver)
|
||||
QHash <int, QString> schemas =
|
||||
{
|
||||
case (0x000300):
|
||||
return QStringLiteral("://schema/standard_measurements/v0.3.0.xsd");
|
||||
case (0x000400):
|
||||
return QStringLiteral("://schema/standard_measurements/v0.4.0.xsd");
|
||||
case (0x000401):
|
||||
return QStringLiteral("://schema/standard_measurements/v0.4.1.xsd");
|
||||
case (0x000402):
|
||||
return QStringLiteral("://schema/standard_measurements/v0.4.2.xsd");
|
||||
case (0x000403):
|
||||
return QStringLiteral("://schema/standard_measurements/v0.4.3.xsd");
|
||||
case (0x000404):
|
||||
return CurrentSchema;
|
||||
default:
|
||||
InvalidVersion(ver);
|
||||
break;
|
||||
std::make_pair(FORMAT_VERSION(0, 3, 0), QStringLiteral("://schema/standard_measurements/v0.3.0.xsd")),
|
||||
std::make_pair(FORMAT_VERSION(0, 4, 0), QStringLiteral("://schema/standard_measurements/v0.4.0.xsd")),
|
||||
std::make_pair(FORMAT_VERSION(0, 4, 1), QStringLiteral("://schema/standard_measurements/v0.4.1.xsd")),
|
||||
std::make_pair(FORMAT_VERSION(0, 4, 2), QStringLiteral("://schema/standard_measurements/v0.4.2.xsd")),
|
||||
std::make_pair(FORMAT_VERSION(0, 4, 3), QStringLiteral("://schema/standard_measurements/v0.4.3.xsd")),
|
||||
std::make_pair(FORMAT_VERSION(0, 4, 4), QStringLiteral("://schema/standard_measurements/v0.4.4.xsd")),
|
||||
std::make_pair(FORMAT_VERSION(0, 5, 0), CurrentSchema),
|
||||
};
|
||||
|
||||
if (schemas.contains(ver))
|
||||
{
|
||||
return schemas.value(ver);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvalidVersion(ver);
|
||||
}
|
||||
return QString();//unreachable code
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -101,27 +101,31 @@ void VVSTConverter::ApplyPatches()
|
|||
{
|
||||
switch (m_ver)
|
||||
{
|
||||
case (0x000300):
|
||||
case (FORMAT_VERSION(0, 3, 0)):
|
||||
ToV0_4_0();
|
||||
ValidateXML(XSDSchema(0x000400));
|
||||
ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 0)));
|
||||
Q_FALLTHROUGH();
|
||||
case (0x000400):
|
||||
case (FORMAT_VERSION(0, 4, 0)):
|
||||
ToV0_4_1();
|
||||
ValidateXML(XSDSchema(0x000401));
|
||||
ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 1)));
|
||||
Q_FALLTHROUGH();
|
||||
case (0x000401):
|
||||
case (FORMAT_VERSION(0, 4, 1)):
|
||||
ToV0_4_2();
|
||||
ValidateXML(XSDSchema(0x000402));
|
||||
ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 2)));
|
||||
Q_FALLTHROUGH();
|
||||
case (0x000402):
|
||||
case (FORMAT_VERSION(0, 4, 2)):
|
||||
ToV0_4_3();
|
||||
ValidateXML(XSDSchema(0x000403));
|
||||
ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 3)));
|
||||
Q_FALLTHROUGH();
|
||||
case (0x000403):
|
||||
case (FORMAT_VERSION(0, 4, 3)):
|
||||
ToV0_4_4();
|
||||
ValidateXML(XSDSchema(0x000404));
|
||||
ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 4)));
|
||||
Q_FALLTHROUGH();
|
||||
case (0x000404):
|
||||
case (FORMAT_VERSION(0, 4, 4)):
|
||||
ToV0_5_0();
|
||||
ValidateXML(XSDSchema(FORMAT_VERSION(0, 5, 0)));
|
||||
Q_FALLTHROUGH();
|
||||
case (FORMAT_VERSION(0, 5, 0)):
|
||||
break;
|
||||
default:
|
||||
InvalidVersion(m_ver);
|
||||
|
@ -140,7 +144,7 @@ void VVSTConverter::DowngradeToCurrentMaxVersion()
|
|||
bool VVSTConverter::IsReadOnly() const
|
||||
{
|
||||
// Check if attribute read-only was not changed in file format
|
||||
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMaxVer == FORMAT_VERSION(0, 4, 4),
|
||||
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMaxVer == FORMAT_VERSION(0, 5, 0),
|
||||
"Check attribute read-only.");
|
||||
|
||||
// Possibly in future attribute read-only will change position etc.
|
||||
|
@ -368,3 +372,14 @@ void VVSTConverter::ToV0_4_4()
|
|||
SetVersion(QStringLiteral("0.4.4"));
|
||||
Save();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VVSTConverter::ToV0_5_0()
|
||||
{
|
||||
// TODO. Delete if minimal supported version is 0.5.0
|
||||
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FORMAT_VERSION(0, 5, 0),
|
||||
"Time to refactor the code.");
|
||||
|
||||
SetVersion(QStringLiteral("0.5.0"));
|
||||
Save();
|
||||
}
|
||||
|
|
|
@ -51,10 +51,10 @@ public:
|
|||
// GCC 4.6 doesn't allow constexpr and const together
|
||||
#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 MeasurementMaxVer = FORMAT_VERSION(0, 4, 4);
|
||||
static Q_DECL_CONSTEXPR int MeasurementMaxVer = FORMAT_VERSION(0, 5, 0);
|
||||
#else
|
||||
static Q_DECL_CONSTEXPR const int MeasurementMinVer = FORMAT_VERSION(0, 3, 0);
|
||||
static Q_DECL_CONSTEXPR const int MeasurementMaxVer = FORMAT_VERSION(0, 4, 4);
|
||||
static Q_DECL_CONSTEXPR const int MeasurementMaxVer = FORMAT_VERSION(0, 5, 0);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
@ -85,6 +85,7 @@ private:
|
|||
void ToV0_4_2();
|
||||
void ToV0_4_3();
|
||||
void ToV0_4_4();
|
||||
void ToV0_5_0();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user