45 json[QLatin1String(
"path")] =
path;
46 json[QLatin1String(
"sha256")] =
sha256;
47 json[QLatin1String(
"format")] =
format;
48 json[QLatin1String(
"size_bytes")] =
sizeBytes;
49 json[QLatin1String(
"embedded")] =
embedded;
51 json[QLatin1String(
"data")] = QString::fromLatin1(
data.toBase64());
62 ref.
path = json[QLatin1String(
"path")].toString();
63 ref.
sha256 = json[QLatin1String(
"sha256")].toString();
64 ref.
format = json[QLatin1String(
"format")].toString();
65 ref.
sizeBytes =
static_cast<qint64
>(json[QLatin1String(
"size_bytes")].toDouble());
66 ref.
embedded = json[QLatin1String(
"embedded")].toBool();
68 ref.
data = QByteArray::fromBase64(json[QLatin1String(
"data")].toString().toLatin1());
71 static const QSet<QString> knownKeys = {
72 QStringLiteral(
"role"), QStringLiteral(
"path"),
73 QStringLiteral(
"sha256"), QStringLiteral(
"format"),
74 QStringLiteral(
"size_bytes"), QStringLiteral(
"embedded"),
75 QStringLiteral(
"data")};
76 for (
auto it = json.constBegin(); it != json.constEnd(); ++it) {
77 if (!knownKeys.contains(it.key()))
78 ref.
extras.insert(it.key(), it.value());
88 QCborMap cbor = QCborMap::fromJsonObject(
extras);
90 cbor[QLatin1String(
"path")] =
path;
91 cbor[QLatin1String(
"sha256")] =
sha256;
92 cbor[QLatin1String(
"format")] =
format;
93 cbor[QLatin1String(
"size_bytes")] =
sizeBytes;
94 cbor[QLatin1String(
"embedded")] =
embedded;
96 cbor[QLatin1String(
"data")] = QCborValue(
data);
107 ref.
path = cbor[QLatin1String(
"path")].toString();
108 ref.
sha256 = cbor[QLatin1String(
"sha256")].toString();
109 ref.
format = cbor[QLatin1String(
"format")].toString();
110 ref.
sizeBytes = cbor[QLatin1String(
"size_bytes")].toInteger();
111 ref.
embedded = cbor[QLatin1String(
"embedded")].toBool();
113 ref.
data = cbor[QLatin1String(
"data")].toByteArray();
116 static const QSet<QString> knownKeys = {
117 QStringLiteral(
"role"), QStringLiteral(
"path"),
118 QStringLiteral(
"sha256"), QStringLiteral(
"format"),
119 QStringLiteral(
"size_bytes"), QStringLiteral(
"embedded"),
120 QStringLiteral(
"data")};
121 QJsonObject cborJson = cbor.toJsonObject();
122 for (
auto it = cborJson.constBegin(); it != cborJson.constEnd(); ++it) {
123 if (!knownKeys.contains(it.key()))
124 ref.
extras.insert(it.key(), it.value());
Reference to a file inside an MNA project — relative path, semantic role, SHA-256 hash,...
MNE Analysis Container Format (mna/mnx).
MnaFileRole mnaFileRoleFromString(const QString &str)
QString mnaFileRoleToString(MnaFileRole role)
static MnaFileRef fromJson(const QJsonObject &json)
QJsonObject toJson() const
static MnaFileRef fromCbor(const QCborMap &cbor)