ProjectLoader: replace access to listific with iterator; minor fixes

This commit is contained in:
Michael Ehrenreich
2023-02-27 02:21:37 +01:00
parent 3fd8b9e674
commit 38203d1653
2 changed files with 10 additions and 8 deletions

View File

@ -1,4 +1,10 @@
#include <concepts>
#include <list>
#include <type_traits>
#include <vector>
#include <QJsonArray>
#include <QJsonObject>
#include "projectloader.h"
@ -299,9 +305,9 @@ template <detail::Listific T>
std::expected<QJsonArray, QString> save(const T &val) {
QJsonArray arr;
for (size_t i = 0; i < val.size(); i++) {
const auto &el = val[i];
auto json = save<typename T::value_type>(el);
size_t i = 0;
for (auto it = std::cbegin(val); it != std::cend(val); it++, i++) {
auto json = save<typename T::value_type>(*it);
if (json) {
arr.push_back(json.value());
} else {

View File

@ -2,16 +2,12 @@
#define PROJECTLOADER_H
#include <expected>
#include <vector>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QString>
#include "lightproject.h"
#include "projectloader.h"
namespace ProjectLoader {
std::expected<LightProject, QString> loadProject(const QJsonDocument &json);