mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-22 09:54:54 -05:00
The "core" macro conditions and actions have been extracted out to the "base" plugin. The library now mostly contains functionality which is required across all plugins and (e.g. definitions for macro segments). The goal is to reduce the complexity and cross-dependencies and group the source files in a better way. This should relsove the "library limit of 65535 objects exceeded" build issue occuring in some Windows build environments.
38 lines
719 B
C++
38 lines
719 B
C++
#include "json-helpers.hpp"
|
|
|
|
#include <QJsonDocument>
|
|
|
|
namespace advss {
|
|
|
|
QString FormatJsonString(std::string s)
|
|
{
|
|
return FormatJsonString(QString::fromStdString(s));
|
|
}
|
|
|
|
QString FormatJsonString(QString json)
|
|
{
|
|
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
|
return QString::fromUtf8(doc.toJson(QJsonDocument::Indented));
|
|
}
|
|
|
|
bool MatchJson(const std::string &json1, const std::string &json2,
|
|
const RegexConfig ®ex)
|
|
{
|
|
auto j1 = FormatJsonString(json1).toStdString();
|
|
auto j2 = FormatJsonString(json2).toStdString();
|
|
|
|
if (j1.empty()) {
|
|
j1 = json1;
|
|
}
|
|
if (j2.empty()) {
|
|
j2 = json2;
|
|
}
|
|
|
|
if (regex.Enabled()) {
|
|
return regex.Matches(j1, j2);
|
|
}
|
|
return j1 == j2;
|
|
}
|
|
|
|
} // namespace advss
|