summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-06-03 21:11:03 +0200
committerPetr Mrázek <peterix@gmail.com>2015-06-06 21:23:05 +0200
commit57b75dfcf79d738b955db1815284f5baaf91d2f8 (patch)
tree207379b573c376a16a32aece7afb03c92f24e6b6 /logic
parent06a67fbd3852cdaa9bb4d8e2900543b47360f0fc (diff)
downloadMultiMC-57b75dfcf79d738b955db1815284f5baaf91d2f8.tar
MultiMC-57b75dfcf79d738b955db1815284f5baaf91d2f8.tar.gz
MultiMC-57b75dfcf79d738b955db1815284f5baaf91d2f8.tar.lz
MultiMC-57b75dfcf79d738b955db1815284f5baaf91d2f8.tar.xz
MultiMC-57b75dfcf79d738b955db1815284f5baaf91d2f8.zip
NOISSUE document exceptions a bit more
Diffstat (limited to 'logic')
-rw-r--r--logic/Json.h16
-rw-r--r--logic/settings/INIFile.cpp1
2 files changed, 17 insertions, 0 deletions
diff --git a/logic/Json.h b/logic/Json.h
index d22aa606..9f4c5445 100644
--- a/logic/Json.h
+++ b/logic/Json.h
@@ -23,17 +23,25 @@ enum Requirement
Required
};
+/// @throw FileSystemException
void write(const QJsonDocument &doc, const QString &filename);
+/// @throw FileSystemException
void write(const QJsonObject &object, const QString &filename);
+/// @throw FileSystemException
void write(const QJsonArray &array, const QString &filename);
+
QByteArray toBinary(const QJsonObject &obj);
QByteArray toBinary(const QJsonArray &array);
QByteArray toText(const QJsonObject &obj);
QByteArray toText(const QJsonArray &array);
+/// @throw JsonException
QJsonDocument ensureDocument(const QByteArray &data, const QString &what = "Document");
+/// @throw JsonException
QJsonDocument ensureDocument(const QString &filename, const QString &what = "Document");
+/// @throw JsonException
QJsonObject ensureObject(const QJsonDocument &doc, const QString &what = "Document");
+/// @throw JsonException
QJsonArray ensureArray(const QJsonDocument &doc, const QString &what = "Document");
/////////////////// WRITING ////////////////////
@@ -127,6 +135,8 @@ T ensureIsType(const QJsonValue &value, const T default_, const QString &what =
}
return ensureIsType<T>(value, Required, what);
}
+
+/// @throw JsonException
template <typename T>
T ensureIsType(const QJsonObject &parent, const QString &key,
const Requirement requirement = Required,
@@ -139,6 +149,7 @@ T ensureIsType(const QJsonObject &parent, const QString &key,
}
return ensureIsType<T>(parent.value(key), requirement, localWhat);
}
+
template <typename T>
T ensureIsType(const QJsonObject &parent, const QString &key, const T default_,
const QString &what = "__placeholder__")
@@ -162,6 +173,7 @@ QList<T> ensureIsArrayOf(const QJsonDocument &doc)
}
return out;
}
+
template <typename T>
QList<T> ensureIsArrayOf(const QJsonValue &value, const Requirement = Required,
const QString &what = "Value")
@@ -174,6 +186,7 @@ QList<T> ensureIsArrayOf(const QJsonValue &value, const Requirement = Required,
}
return out;
}
+
template <typename T>
QList<T> ensureIsArrayOf(const QJsonValue &value, const QList<T> default_,
const QString &what = "Value")
@@ -184,6 +197,8 @@ QList<T> ensureIsArrayOf(const QJsonValue &value, const QList<T> default_,
}
return ensureIsArrayOf<T>(value, Required, what);
}
+
+/// @throw JsonException
template <typename T>
QList<T> ensureIsArrayOf(const QJsonObject &parent, const QString &key,
const Requirement requirement = Required,
@@ -196,6 +211,7 @@ QList<T> ensureIsArrayOf(const QJsonObject &parent, const QString &key,
}
return ensureIsArrayOf<T>(parent.value(key), requirement, localWhat);
}
+
template <typename T>
QList<T> ensureIsArrayOf(const QJsonObject &parent, const QString &key,
const QList<T> &default_, const QString &what = "__placeholder__")
diff --git a/logic/settings/INIFile.cpp b/logic/settings/INIFile.cpp
index 5f39f213..69a6b87e 100644
--- a/logic/settings/INIFile.cpp
+++ b/logic/settings/INIFile.cpp
@@ -109,6 +109,7 @@ bool INIFile::loadFile(QString fileName)
file.close();
return success;
}
+
bool INIFile::loadFile(QByteArray file)
{
QTextStream in(file);