mirror of
https://github.com/HenkKalkwater/harbour-sailfin.git
synced 2024-05-10 08:02:43 +00:00
Chris Josten
90db983c30
There were some constructors in the DTOs which allowed construction of DTO which weren't fully initialized. These constructors have been made private, as they are still used in the 'fromJson' methods. Additionally, a constructor with all required parameters to fully initialize the class has been added. Additionally, the Loader class has been modified, since it no longer can assume it is able to default construct the parameter type. The parameter is now stored as an optional. Closes #15
157 lines
4.5 KiB
C++
157 lines
4.5 KiB
C++
/*
|
|
* Sailfin: a Jellyfin client written using Qt
|
|
* Copyright (C) 2021 Chris Josten and the Sailfin Contributors.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library 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
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
/*
|
|
* WARNING: THIS IS AN AUTOMATICALLY GENERATED FILE! PLEASE DO NOT EDIT THIS, AS YOUR EDITS WILL GET
|
|
* OVERWRITTEN AT SOME POINT!
|
|
*
|
|
* If there is a bug in this file, please fix the code generator used to generate this file found in
|
|
* core/openapigenerator.d.
|
|
*
|
|
* This file is generated based on Jellyfin's OpenAPI description, "openapi.json". Please update that
|
|
* file with a newer file if needed instead of manually updating the files.
|
|
*/
|
|
|
|
#include <JellyfinQt/dto/version.h>
|
|
|
|
namespace Jellyfin {
|
|
namespace DTO {
|
|
|
|
Version::Version() {}
|
|
Version::Version (
|
|
qint32 major,
|
|
qint32 minor,
|
|
qint32 build,
|
|
qint32 revision,
|
|
qint32 majorRevision,
|
|
qint32 minorRevision
|
|
) :
|
|
m_major(major),
|
|
m_minor(minor),
|
|
m_build(build),
|
|
m_revision(revision),
|
|
m_majorRevision(majorRevision),
|
|
m_minorRevision(minorRevision) { }
|
|
|
|
|
|
|
|
Version::Version(const Version &other) :
|
|
|
|
m_major(other.m_major),
|
|
m_minor(other.m_minor),
|
|
m_build(other.m_build),
|
|
m_revision(other.m_revision),
|
|
m_majorRevision(other.m_majorRevision),
|
|
m_minorRevision(other.m_minorRevision){}
|
|
|
|
|
|
void Version::replaceData(Version &other) {
|
|
m_major = other.m_major;
|
|
m_minor = other.m_minor;
|
|
m_build = other.m_build;
|
|
m_revision = other.m_revision;
|
|
m_majorRevision = other.m_majorRevision;
|
|
m_minorRevision = other.m_minorRevision;
|
|
}
|
|
|
|
Version Version::fromJson(QJsonObject source) {
|
|
Version instance;
|
|
instance.setFromJson(source);
|
|
return instance;
|
|
}
|
|
|
|
|
|
void Version::setFromJson(QJsonObject source) {
|
|
m_major = Jellyfin::Support::fromJsonValue<qint32>(source["Major"]);
|
|
m_minor = Jellyfin::Support::fromJsonValue<qint32>(source["Minor"]);
|
|
m_build = Jellyfin::Support::fromJsonValue<qint32>(source["Build"]);
|
|
m_revision = Jellyfin::Support::fromJsonValue<qint32>(source["Revision"]);
|
|
m_majorRevision = Jellyfin::Support::fromJsonValue<qint32>(source["MajorRevision"]);
|
|
m_minorRevision = Jellyfin::Support::fromJsonValue<qint32>(source["MinorRevision"]);
|
|
|
|
}
|
|
|
|
QJsonObject Version::toJson() const {
|
|
QJsonObject result;
|
|
|
|
result["Major"] = Jellyfin::Support::toJsonValue<qint32>(m_major);
|
|
result["Minor"] = Jellyfin::Support::toJsonValue<qint32>(m_minor);
|
|
result["Build"] = Jellyfin::Support::toJsonValue<qint32>(m_build);
|
|
result["Revision"] = Jellyfin::Support::toJsonValue<qint32>(m_revision);
|
|
result["MajorRevision"] = Jellyfin::Support::toJsonValue<qint32>(m_majorRevision);
|
|
result["MinorRevision"] = Jellyfin::Support::toJsonValue<qint32>(m_minorRevision);
|
|
return result;
|
|
}
|
|
|
|
qint32 Version::major() const { return m_major; }
|
|
|
|
void Version::setMajor(qint32 newMajor) {
|
|
m_major = newMajor;
|
|
}
|
|
|
|
qint32 Version::minor() const { return m_minor; }
|
|
|
|
void Version::setMinor(qint32 newMinor) {
|
|
m_minor = newMinor;
|
|
}
|
|
|
|
qint32 Version::build() const { return m_build; }
|
|
|
|
void Version::setBuild(qint32 newBuild) {
|
|
m_build = newBuild;
|
|
}
|
|
|
|
qint32 Version::revision() const { return m_revision; }
|
|
|
|
void Version::setRevision(qint32 newRevision) {
|
|
m_revision = newRevision;
|
|
}
|
|
|
|
qint32 Version::majorRevision() const { return m_majorRevision; }
|
|
|
|
void Version::setMajorRevision(qint32 newMajorRevision) {
|
|
m_majorRevision = newMajorRevision;
|
|
}
|
|
|
|
qint32 Version::minorRevision() const { return m_minorRevision; }
|
|
|
|
void Version::setMinorRevision(qint32 newMinorRevision) {
|
|
m_minorRevision = newMinorRevision;
|
|
}
|
|
|
|
|
|
} // NS DTO
|
|
|
|
namespace Support {
|
|
|
|
using Version = Jellyfin::DTO::Version;
|
|
|
|
template <>
|
|
Version fromJsonValue(const QJsonValue &source, convertType<Version>) {
|
|
if (!source.isObject()) throw ParseException("Expected JSON Object");
|
|
return Version::fromJson(source.toObject());
|
|
}
|
|
|
|
template<>
|
|
QJsonValue toJsonValue(const Version &source, convertType<Version>) {
|
|
return source.toJson();
|
|
}
|
|
|
|
} // NS DTO
|
|
} // NS Jellyfin
|