NOISSUE document exceptions a bit more
This commit is contained in:
parent
06a67fbd38
commit
57b75dfcf7
16
logic/Json.h
16
logic/Json.h
@ -23,17 +23,25 @@ enum Requirement
|
|||||||
Required
|
Required
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @throw FileSystemException
|
||||||
void write(const QJsonDocument &doc, const QString &filename);
|
void write(const QJsonDocument &doc, const QString &filename);
|
||||||
|
/// @throw FileSystemException
|
||||||
void write(const QJsonObject &object, const QString &filename);
|
void write(const QJsonObject &object, const QString &filename);
|
||||||
|
/// @throw FileSystemException
|
||||||
void write(const QJsonArray &array, const QString &filename);
|
void write(const QJsonArray &array, const QString &filename);
|
||||||
|
|
||||||
QByteArray toBinary(const QJsonObject &obj);
|
QByteArray toBinary(const QJsonObject &obj);
|
||||||
QByteArray toBinary(const QJsonArray &array);
|
QByteArray toBinary(const QJsonArray &array);
|
||||||
QByteArray toText(const QJsonObject &obj);
|
QByteArray toText(const QJsonObject &obj);
|
||||||
QByteArray toText(const QJsonArray &array);
|
QByteArray toText(const QJsonArray &array);
|
||||||
|
|
||||||
|
/// @throw JsonException
|
||||||
QJsonDocument ensureDocument(const QByteArray &data, const QString &what = "Document");
|
QJsonDocument ensureDocument(const QByteArray &data, const QString &what = "Document");
|
||||||
|
/// @throw JsonException
|
||||||
QJsonDocument ensureDocument(const QString &filename, const QString &what = "Document");
|
QJsonDocument ensureDocument(const QString &filename, const QString &what = "Document");
|
||||||
|
/// @throw JsonException
|
||||||
QJsonObject ensureObject(const QJsonDocument &doc, const QString &what = "Document");
|
QJsonObject ensureObject(const QJsonDocument &doc, const QString &what = "Document");
|
||||||
|
/// @throw JsonException
|
||||||
QJsonArray ensureArray(const QJsonDocument &doc, const QString &what = "Document");
|
QJsonArray ensureArray(const QJsonDocument &doc, const QString &what = "Document");
|
||||||
|
|
||||||
/////////////////// WRITING ////////////////////
|
/////////////////// WRITING ////////////////////
|
||||||
@ -127,6 +135,8 @@ T ensureIsType(const QJsonValue &value, const T default_, const QString &what =
|
|||||||
}
|
}
|
||||||
return ensureIsType<T>(value, Required, what);
|
return ensureIsType<T>(value, Required, what);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @throw JsonException
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T ensureIsType(const QJsonObject &parent, const QString &key,
|
T ensureIsType(const QJsonObject &parent, const QString &key,
|
||||||
const Requirement requirement = Required,
|
const Requirement requirement = Required,
|
||||||
@ -139,6 +149,7 @@ T ensureIsType(const QJsonObject &parent, const QString &key,
|
|||||||
}
|
}
|
||||||
return ensureIsType<T>(parent.value(key), requirement, localWhat);
|
return ensureIsType<T>(parent.value(key), requirement, localWhat);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T ensureIsType(const QJsonObject &parent, const QString &key, const T default_,
|
T ensureIsType(const QJsonObject &parent, const QString &key, const T default_,
|
||||||
const QString &what = "__placeholder__")
|
const QString &what = "__placeholder__")
|
||||||
@ -162,6 +173,7 @@ QList<T> ensureIsArrayOf(const QJsonDocument &doc)
|
|||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
QList<T> ensureIsArrayOf(const QJsonValue &value, const Requirement = Required,
|
QList<T> ensureIsArrayOf(const QJsonValue &value, const Requirement = Required,
|
||||||
const QString &what = "Value")
|
const QString &what = "Value")
|
||||||
@ -174,6 +186,7 @@ QList<T> ensureIsArrayOf(const QJsonValue &value, const Requirement = Required,
|
|||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
QList<T> ensureIsArrayOf(const QJsonValue &value, const QList<T> default_,
|
QList<T> ensureIsArrayOf(const QJsonValue &value, const QList<T> default_,
|
||||||
const QString &what = "Value")
|
const QString &what = "Value")
|
||||||
@ -184,6 +197,8 @@ QList<T> ensureIsArrayOf(const QJsonValue &value, const QList<T> default_,
|
|||||||
}
|
}
|
||||||
return ensureIsArrayOf<T>(value, Required, what);
|
return ensureIsArrayOf<T>(value, Required, what);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @throw JsonException
|
||||||
template <typename T>
|
template <typename T>
|
||||||
QList<T> ensureIsArrayOf(const QJsonObject &parent, const QString &key,
|
QList<T> ensureIsArrayOf(const QJsonObject &parent, const QString &key,
|
||||||
const Requirement requirement = Required,
|
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);
|
return ensureIsArrayOf<T>(parent.value(key), requirement, localWhat);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
QList<T> ensureIsArrayOf(const QJsonObject &parent, const QString &key,
|
QList<T> ensureIsArrayOf(const QJsonObject &parent, const QString &key,
|
||||||
const QList<T> &default_, const QString &what = "__placeholder__")
|
const QList<T> &default_, const QString &what = "__placeholder__")
|
||||||
|
@ -109,6 +109,7 @@ bool INIFile::loadFile(QString fileName)
|
|||||||
file.close();
|
file.close();
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool INIFile::loadFile(QByteArray file)
|
bool INIFile::loadFile(QByteArray file)
|
||||||
{
|
{
|
||||||
QTextStream in(file);
|
QTextStream in(file);
|
||||||
|
Loading…
Reference in New Issue
Block a user