Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
MigrationRunner.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include "phosphorconfig_export.h"
7
9
10#include <QJsonObject>
11#include <QString>
12#include <QVector>
13
14namespace PhosphorConfig {
15
22class PHOSPHORCONFIG_EXPORT MigrationRunner
23{
24public:
25 explicit MigrationRunner(const Schema& schema);
26
30 explicit MigrationRunner(Schema&&) = delete;
31
36 void runInMemory(QJsonObject& root) const;
37
50 bool runOnFile(const QString& jsonPath) const;
51
53 int readVersion(const QJsonObject& root) const;
54
56 void stampVersion(QJsonObject& root) const;
57
58private:
59 const Schema& m_schema;
62 QVector<MigrationStep> m_orderedSteps;
63};
64
65} // namespace PhosphorConfig
bool runOnFile(const QString &jsonPath) const
Read the file at jsonPath, run the chain, and — if the version advanced — atomically write the result...
void stampVersion(QJsonObject &root) const
Stamp root with the schema's current version.
int readVersion(const QJsonObject &root) const
Current version persisted in root, or 1 if unset / invalid.
void runInMemory(QJsonObject &root) const
Apply the full migration chain in memory.
MigrationRunner(const Schema &schema)
MigrationRunner(Schema &&)=delete
Forbid construction from a temporary Schema — the runner stores a const reference,...
Definition HostDirectory.h:19
Declarative description of a configuration store.
Definition Schema.h:127