3#include <nlohmann/json.hpp>
43 [[nodiscard]] nlohmann::json
ToJson()
const
45 nlohmann::json subDirs = nlohmann::json::object();
48 nlohmann::json capAliases = nlohmann::json::object();
56 {
"subActorDirectedTo", subDirs},
57 {
"captureAliases", capAliases}};
63 d.
name = j.value(
"name",
"");
64 d.
pattern = j.value(
"pattern",
"");
65 d.
field = j.value(
"field",
"");
66 d.
enabled = j.value(
"enabled",
true);
67 d.
isSelf = j.value(
"isSelf",
false);
68 d.
alias = j.value(
"alias",
"");
71 auto loadMap = [&](
const char* key, std::map<std::string,std::string>& out) {
72 if (j.contains(key) && j.at(key).is_object())
73 for (
const auto& [k, v] : j.at(key).items())
74 if (v.is_string()) out[k] = v.get<std::string>();
82 static nlohmann::json
ListToJson(
const std::vector<ActorDefinition>& defs)
84 nlohmann::json arr = nlohmann::json::array();
85 for (
const auto& d : defs) arr.push_back(d.ToJson());
89 static std::vector<ActorDefinition>
ListFromJson(
const nlohmann::json& j)
91 std::vector<ActorDefinition> defs;
92 if (!j.is_array())
return defs;
93 for (
const auto& item : j)
95 try { defs.push_back(
FromJson(item)); }
catch (...) {}
146 const auto pos = key.find(
'\0');
147 if (pos == std::string::npos)
149 return {key.substr(0, pos), key.substr(pos + 1)};
Definition ConfigEditorDialog.cpp:19
Describes a named actor matched by a regular expression.
Definition ActorDefinition.hpp:18
std::string field
Log field to match against (empty = any field)
Definition ActorDefinition.hpp:21
bool isSelf
Definition ActorDefinition.hpp:24
bool useCaptures
Definition ActorDefinition.hpp:34
std::map< std::string, std::string > subActorDirectedTo
Definition ActorDefinition.hpp:37
nlohmann::json ToJson() const
Definition ActorDefinition.hpp:43
static nlohmann::json ListToJson(const std::vector< ActorDefinition > &defs)
Definition ActorDefinition.hpp:82
static ActorDefinition FromJson(const nlohmann::json &j)
Definition ActorDefinition.hpp:60
bool enabled
Definition ActorDefinition.hpp:23
std::map< std::string, std::string > captureAliases
Definition ActorDefinition.hpp:40
std::string alias
Definition ActorDefinition.hpp:31
std::string name
Display name shown in the Actors panel.
Definition ActorDefinition.hpp:19
std::string directedTo
Name of the actor this actor's events are directed to (optional)
Definition ActorDefinition.hpp:22
static std::vector< ActorDefinition > ListFromJson(const nlohmann::json &j)
Definition ActorDefinition.hpp:89
std::string pattern
ECMAScript/QRegularExpression pattern.
Definition ActorDefinition.hpp:20
Type-safe composite key identifying a single actor row in ActorsPanel.
Definition ActorDefinition.hpp:126
static ActorKey Decode(const std::string &key)
Definition ActorDefinition.hpp:144
std::string defName
Name of the owning ActorDefinition.
Definition ActorDefinition.hpp:127
std::string actorName
Matched actor name (or capture-group value)
Definition ActorDefinition.hpp:128
static std::string Encode(std::string_view defName, std::string_view actorName)
Encodes defName and actorName into a single opaque key string.
Definition ActorDefinition.hpp:131