Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 208d09e4 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

ASS: Add the base INI parser for the AssFactory

parent b0eafae1
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!3Add documents
......@@ -6,10 +6,39 @@ bool
AssFactory::initFromStorage() noexcept
{
QTextStream in(&diskStorage);
QString currentSection{};
quint64 lineIndex = 0;
while (!in.atEnd()) {
QString line = in.readLine();
/* TODO */
return false;
const QString line = in.readLine().trimmed();
/* Dectect comment */
if (line.startsWith(";") || line.isEmpty()) {
lineIndex++;
continue;
}
/* Dectect sections */
else if (line.startsWith("[") && line.endsWith("]")) {
currentSection = line.mid(1, line.size() - 2);
qDebug() << "Parsing section" << currentSection;
if (!validSections.contains(currentSection)) {
qWarning() << "The current section" << currentSection << "is invalid, ignoring it";
currentSection = "";
}
}
/* Other lines */
else if (!currentSection.isEmpty()) {
const int separatorIndex = line.indexOf(": ");
const int baseValueIndex = separatorIndex + 2;
if (separatorIndex < 0) {
qWarning() << "Invalid line #" << lineIndex << ":" << line;
}
assContent[currentSection].insert(line.mid(0, separatorIndex), line.mid(baseValueIndex));
}
lineIndex++;
}
/* Construct the styles and the lines */
......
......@@ -40,6 +40,7 @@ private:
static inline const QString sectionScriptInfo = "Script Info";
static inline const QString sectionStyles = "V4+ Styles";
static inline const QString sectionEvents = "Events";
static inline const QStringList validSections = { sectionEvents, sectionScriptInfo, sectionStyles };
static inline const QStringList intTypeFields = { "PlayResX", "PlayResY", "WrapStyle" };
static inline const QList<QPair<QString, QString>> checkedValues = { { "ScriptType", "v4.00+" },
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter