MQTTSuite
Loading...
Searching...
No Matches
JsonMappingReader.h
Go to the documentation of this file.
1/*
2 * MQTTSuite - A lightweight MQTT Integration System
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2022, 2023, 2024, 2025, 2026
5 * Tobias Pfeil
6 * 2025, 2026
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation, either version 3 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22/*
23 * MIT License
24 *
25 * Permission is hereby granted, free of charge, to any person obtaining a copy
26 * of this software and associated documentation files (the "Software"), to deal
27 * in the Software without restriction, including without limitation the rights
28 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29 * copies of the Software, and to permit persons to whom the Software is
30 * furnished to do so, subject to the following conditions:
31 *
32 * The above copyright notice and this permission notice shall be included in
33 * all copies or substantial portions of the Software.
34 *
35 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
41 * THE SOFTWARE.
42 */
43
44#ifndef MQTTBROKER_LIB_JSONMAPPINGREADER_H
45#define MQTTBROKER_LIB_JSONMAPPINGREADER_H
46
47#ifndef DOXYGEN_SHOULD_SKIP_THIS
48
49#include <nlohmann/json_fwd.hpp> // IWYU pragma: export
50#include <string>
51#include <vector>
52
53#endif // DOXYGEN_SHOULD_SKIP_THIS
54
55namespace mqtt::lib {
56
58 public:
60
61 public:
62 // Admin / Live Reload Support
63 static void saveDraft(const std::string& mapFilePath, const nlohmann::json& content);
64 static nlohmann::json readDraftOrActive(const std::string& mapFilePath);
65 static nlohmann::json deployDraft(const std::string& mapFilePath);
66 static void discardDraft(const std::string& mapFilePath);
67 static std::string getDraftPath(const std::string& mapFilePath);
68
69 struct VersionEntry {
70 std::string id;
71 std::string filename;
72 std::string comment;
73 std::string date;
74 };
75
76 static std::vector<VersionEntry> getHistory(const std::string& mapFilePath);
77 static nlohmann::json rollbackTo(const std::string& mapFilePath, const std::string& versionId);
78
79 private:
80 static nlohmann::json getDefaultPatch(const nlohmann::json& inputJson);
81 };
82
83} // namespace mqtt::lib
84
85#endif // MQTTBROKER_LIB_JSONMAPPINGREADER_H
static nlohmann::json deployDraft(const std::string &mapFilePath)
static nlohmann::json rollbackTo(const std::string &mapFilePath, const std::string &versionId)
static void discardDraft(const std::string &mapFilePath)
static std::vector< VersionEntry > getHistory(const std::string &mapFilePath)
static nlohmann::json readDraftOrActive(const std::string &mapFilePath)
static std::string getDraftPath(const std::string &mapFilePath)
static void saveDraft(const std::string &mapFilePath, const nlohmann::json &content)
static nlohmann::json getDefaultPatch(const nlohmann::json &inputJson)
static const nlohmann::json validate(const nlohmann::json &json)