mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-19 12:34:15 +02:00
a475383915
Second stage of the zipped project file (#1440): QetContainer::split() turns a project document into the entries of a .qetz -- mimetype first and stored, a manifest with the format and the oldest format allowed to read it, project.xml with each part replaced by <qetz-part file=.../>, one file per folio, per symbol definition and per title block template, and folio pictures as PNG files named by their SHA-256, stored once each. join() puts it back and refuses a file of a later format, a missing part or anything that is not a .qetz. A picture leaves its folio only if its base64 comes back exactly, so nothing here can change a project. Parts are written as QET writes a .qet and read as it reads one. Still nothing opens or saves a .qetz. Test: tst_qetcontainer, every example split, zipped, unzipped and joined back to the same document (whitespace between elements aside); pictures out of the folios once each; later format and missing part refused. With QET_CONTAINER_CORPUS it also runs on a folder of projects: 341 of 341 readable projects collected from the bugtracker, GitHub and the forum come back the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019Wga9B92BNurDEtxxtCDxf
60 lines
2.1 KiB
C++
60 lines
2.1 KiB
C++
/*
|
|
Copyright 2006-2026 The QElectroTech Team
|
|
This file is part of QElectroTech.
|
|
|
|
QElectroTech 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 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
QElectroTech 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 QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#ifndef QETCONTAINER_H
|
|
#define QETCONTAINER_H
|
|
|
|
#include "qetzip.h"
|
|
|
|
#include <QDomDocument>
|
|
|
|
/**
|
|
@brief The QetContainer namespace
|
|
Splits a project document into the parts of a .qetz file and joins
|
|
them back:
|
|
|
|
mimetype first, stored
|
|
manifest.xml format and oldest format allowed to read it
|
|
project.xml the project, each part replaced by
|
|
<qetz-part file="..."/>
|
|
folios/<uuid>.xml one per folio
|
|
elements/.../<name> the project's symbol definitions
|
|
titleblocks/<name>.titleblock
|
|
images/<sha256>.png folio pictures, once each, not base64
|
|
|
|
join(split(d)) is d. Nothing here knows what the parts mean: the
|
|
project is read and written by the same code as a .qet file.
|
|
*/
|
|
namespace QetContainer
|
|
{
|
|
extern const char MimeType[];
|
|
/// The format written; files of a later format are refused by join()
|
|
/// unless their min-reader allows this one.
|
|
constexpr int Format = 1;
|
|
|
|
QList<QetZip::Entry> split(const QDomDocument &project,
|
|
const QString &writer = QString(),
|
|
QString *error = nullptr);
|
|
bool join(const QList<QetZip::Entry> &entries, QDomDocument *project,
|
|
QString *error = nullptr);
|
|
|
|
/// Parse @p xml as a .qet is read (QETProject::openFile)
|
|
bool parse(const QByteArray &xml, QDomDocument *document, QString *error = nullptr);
|
|
}
|
|
|
|
#endif // QETCONTAINER_H
|