96 lines
3.3 KiB
C++
96 lines
3.3 KiB
C++
/************************************************************************
|
|
**
|
|
** @file vgeometrydef.cpp
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
** @date 1 7, 2019
|
|
**
|
|
** @brief
|
|
** @copyright
|
|
** This source code is part of the Valentina project, a pattern making
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
** Copyright (C) 2019 Valentina project
|
|
** <https://gitlab.com/smart-pattern/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/>.
|
|
**
|
|
*************************************************************************/
|
|
|
|
#include "vgeometrydef.h"
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
|
# include "../vmisc/vdatastreamenum.h"
|
|
#endif
|
|
#include "../ifc/exception/vexception.h"
|
|
|
|
#include <QCoreApplication>
|
|
|
|
const quint32 VLayoutPassmark::streamHeader = 0x943E2759; // CRC-32Q string "VLayoutPassmark"
|
|
const quint16 VLayoutPassmark::classVersion = 1;
|
|
|
|
// Friend functions
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
QDataStream &operator<<(QDataStream &dataStream, const VLayoutPassmark &data)
|
|
{
|
|
dataStream << VLayoutPassmark::streamHeader << VLayoutPassmark::classVersion;
|
|
|
|
// Added in classVersion = 1
|
|
dataStream << data.lines;
|
|
dataStream << data.type;
|
|
dataStream << data.baseLine;
|
|
dataStream << data.isBuiltIn;
|
|
|
|
// Added in classVersion = 2
|
|
|
|
return dataStream;
|
|
}
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
QDataStream &operator>>(QDataStream &dataStream, VLayoutPassmark &data)
|
|
{
|
|
quint32 actualStreamHeader = 0;
|
|
dataStream >> actualStreamHeader;
|
|
|
|
if (actualStreamHeader != VLayoutPassmark::streamHeader)
|
|
{
|
|
QString message = QCoreApplication::tr("VLayoutPassmark prefix mismatch error: actualStreamHeader = 0x%1 and "
|
|
"streamHeader = 0x%2")
|
|
.arg(actualStreamHeader, 8, 0x10, QChar('0'))
|
|
.arg(VLayoutPassmark::streamHeader, 8, 0x10, QChar('0'));
|
|
throw VException(message);
|
|
}
|
|
|
|
quint16 actualClassVersion = 0;
|
|
dataStream >> actualClassVersion;
|
|
|
|
if (actualClassVersion > VLayoutPassmark::classVersion)
|
|
{
|
|
QString message = QCoreApplication::tr("VLayoutPassmark compatibility error: actualClassVersion = %1 and "
|
|
"classVersion = %2")
|
|
.arg(actualClassVersion).arg(VLayoutPassmark::classVersion);
|
|
throw VException(message);
|
|
}
|
|
|
|
dataStream >> data.lines;
|
|
dataStream >> data.type;
|
|
dataStream >> data.baseLine;
|
|
dataStream >> data.isBuiltIn;
|
|
|
|
// if (actualClassVersion >= 2)
|
|
// {
|
|
|
|
// }
|
|
|
|
return dataStream;
|
|
}
|