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")
77 for (
auto it = json.constBegin(); it != json.constEnd(); ++it) {
78 if (!knownKeys.contains(it.key()))
79 ref.
extras.insert(it.key(), it.value());
89 QCborMap cbor = QCborMap::fromJsonObject(
extras);
91 cbor[QLatin1String(
"path")] =
path;
92 cbor[QLatin1String(
"sha256")] =
sha256;
93 cbor[QLatin1String(
"format")] =
format;
94 cbor[QLatin1String(
"size_bytes")] =
sizeBytes;
95 cbor[QLatin1String(
"embedded")] =
embedded;
97 cbor[QLatin1String(
"data")] = QCborValue(
data);
108 ref.
path = cbor[QLatin1String(
"path")].toString();
109 ref.
sha256 = cbor[QLatin1String(
"sha256")].toString();
110 ref.
format = cbor[QLatin1String(
"format")].toString();
111 ref.
sizeBytes = cbor[QLatin1String(
"size_bytes")].toInteger();
112 ref.
embedded = cbor[QLatin1String(
"embedded")].toBool();
114 ref.
data = cbor[QLatin1String(
"data")].toByteArray();
117 static const QSet<QString> knownKeys = {
118 QStringLiteral(
"role"), QStringLiteral(
"path"),
119 QStringLiteral(
"sha256"), QStringLiteral(
"format"),
120 QStringLiteral(
"size_bytes"), QStringLiteral(
"embedded"),
121 QStringLiteral(
"data")
123 QJsonObject cborJson = cbor.toJsonObject();
124 for (
auto it = cborJson.constBegin(); it != cborJson.constEnd(); ++it) {
125 if (!knownKeys.contains(it.key()))
126 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)