MQTTSuite
Loading...
Searching...
No Matches
mqtt::lib::MqttMapper Class Reference

#include <MqttMapper.h>

Collaboration diagram for mqtt::lib::MqttMapper:

Classes

struct  ScheduledPublish

Public Types

using MappedPublishes = std::pair<std::vector<iot::mqtt::packets::Publish>, std::vector<ScheduledPublish>>

Public Member Functions

 MqttMapper ()
 MqttMapper (const MqttMapper &)=delete
MqttMapperoperator= (const MqttMapper &)=delete
virtual ~MqttMapper ()
bool setMapping (nlohmann::json mappingJson)
const nlohmann::json & getMapping () const
std::string dump ()
const nlohmann::json & getConnection () const
std::list< iot::mqtt::Topic > extractSubscriptions () const
MappedPublishes getMappings (const iot::mqtt::packets::Publish &publish)

Static Public Member Functions

static const std::string & getSchema ()
static const nlohmann::json validate (const nlohmann::json &json)
static const nlohmann::json validate (const nlohmann::json &json, nlohmann::json_schema::basic_error_handler &err)

Private Member Functions

nlohmann::json findMatchingTopicLevel (const nlohmann::json &topicLevel, const std::string &topic)
void publishMappedTemplate (const nlohmann::json &templateMapping, nlohmann::json &json, MappedPublishes &mappedPublishes)
void getTemplateMappings (const nlohmann::json &templateMapping, nlohmann::json &json, const iot::mqtt::packets::Publish &publish, MappedPublishes &mappedPublishes)

Static Private Member Functions

static void extractSubscription (const nlohmann::json &topicLevelJson, const std::string &topic, std::list< iot::mqtt::Topic > &topicList)
static void extractSubscriptions (const nlohmann::json &mappingJson, const std::string &topic, std::list< iot::mqtt::Topic > &topicList)
static void publishMappedMessage (const std::string &topic, const std::string &message, uint8_t qoS, bool retain, double delay, MappedPublishes &mappedPublishes)
static void publishMappedMessage (const nlohmann::json &staticMapping, const iot::mqtt::packets::Publish &publish, MappedPublishes &mappedPublishes)
static void getStaticMappings (const nlohmann::json &staticMapping, const iot::mqtt::packets::Publish &publish, MappedPublishes &mappedPublishes)

Private Attributes

nlohmann::json mappingJson
std::list< void * > pluginHandles
inja::EnvironmentinjaEnvironment

Static Private Attributes

static const nlohmann::json_schema::json_validator validator
static const std::string mappingJsonSchemaString

Detailed Description

Definition at line 76 of file MqttMapper.h.

Member Typedef Documentation

◆ MappedPublishes

using mqtt::lib::MqttMapper::MappedPublishes = std::pair<std::vector<iot::mqtt::packets::Publish>, std::vector<ScheduledPublish>>

Definition at line 83 of file MqttMapper.h.

Constructor & Destructor Documentation

◆ MqttMapper() [1/2]

mqtt::lib::MqttMapper::MqttMapper ( )

Definition at line 99 of file MqttMapper.cpp.

100 : injaEnvironment(new inja::Environment) {
101 }
inja::Environment * injaEnvironment
Definition MqttMapper.h:133

References injaEnvironment.

◆ MqttMapper() [2/2]

mqtt::lib::MqttMapper::MqttMapper ( const MqttMapper & )
delete

◆ ~MqttMapper()

mqtt::lib::MqttMapper::~MqttMapper ( )
virtual

Definition at line 103 of file MqttMapper.cpp.

103 {
104 delete injaEnvironment;
105
106 for (void* pluginHandle : pluginHandles) {
107 core::DynamicLoader::dlClose(pluginHandle);
108 }
109 }
std::list< void * > pluginHandles
Definition MqttMapper.h:131

References injaEnvironment.

Member Function Documentation

◆ dump()

std::string mqtt::lib::MqttMapper::dump ( )

Definition at line 207 of file MqttMapper.cpp.

207 {
208 return mappingJson.dump();
209 }
nlohmann::json mappingJson
Definition MqttMapper.h:129

References mappingJson.

◆ extractSubscription()

void mqtt::lib::MqttMapper::extractSubscription ( const nlohmann::json & topicLevelJson,
const std::string & topic,
std::list< iot::mqtt::Topic > & topicList )
staticprivate

Definition at line 290 of file MqttMapper.cpp.

292 {
293 const std::string name = topicLevelJson["name"];
294
295 if (topicLevelJson.contains("subscription")) {
296 const uint8_t qoS = topicLevelJson["subscription"]["qos"];
297
298 topicList.emplace_back(topic + ((topic.empty() || topic == "/") && !name.empty() ? "" : "/") + name, qoS);
299 }
300
301 if (topicLevelJson.contains("topic_level")) {
302 extractSubscriptions(topicLevelJson, topic + ((topic.empty() || topic == "/") && !name.empty() ? "" : "/") + name, topicList);
303 }
304 }
std::list< iot::mqtt::Topic > extractSubscriptions() const

Referenced by extractSubscriptions().

Here is the caller graph for this function:

◆ extractSubscriptions() [1/2]

std::list< iot::mqtt::Topic > mqtt::lib::MqttMapper::extractSubscriptions ( ) const

Definition at line 215 of file MqttMapper.cpp.

215 {
216 std::list<iot::mqtt::Topic> topicList;
217
218 extractSubscriptions(mappingJson["mapping"], "", topicList);
219
220 return topicList;
221 }

Referenced by mqtt::mqttintegrator::lib::Mqtt::Mqtt(), and mqtt::mqttintegrator::lib::Mqtt::resubscribe().

Here is the caller graph for this function:

◆ extractSubscriptions() [2/2]

void mqtt::lib::MqttMapper::extractSubscriptions ( const nlohmann::json & mappingJson,
const std::string & topic,
std::list< iot::mqtt::Topic > & topicList )
staticprivate

Definition at line 307 of file MqttMapper.cpp.

307 {
308 if (mappingJson.contains("topic_level")) {
309 const nlohmann::json& topicLevels = mappingJson["topic_level"];
310
311 if (topicLevels.is_object()) {
312 extractSubscription(topicLevels, topic, topicList);
313 } else {
314 for (const nlohmann::json& topicLevel : topicLevels) {
315 extractSubscription(topicLevel, topic, topicList);
316 }
317 }
318 }
319 }
static void extractSubscription(const nlohmann::json &topicLevelJson, const std::string &topic, std::list< iot::mqtt::Topic > &topicList)

References extractSubscription().

Here is the call graph for this function:

◆ findMatchingTopicLevel()

nlohmann::json mqtt::lib::MqttMapper::findMatchingTopicLevel ( const nlohmann::json & topicLevel,
const std::string & topic )
private

Definition at line 321 of file MqttMapper.cpp.

321 {
322 nlohmann::json foundTopicLevel;
323
324 if (topicLevel.is_object()) {
325 const std::string::size_type slashPosition = topic.find('/');
326 const std::string topicLevelName = topic.substr(0, slashPosition);
327
328 if (topicLevel["name"] == topicLevelName || topicLevel["name"] == "+" || topicLevel["name"] == "#") {
329 if (slashPosition == std::string::npos) {
330 foundTopicLevel = topicLevel;
331 } else if (topicLevel.contains("topic_level")) {
332 foundTopicLevel = findMatchingTopicLevel(topicLevel["topic_level"], topic.substr(slashPosition + 1));
333 }
334 }
335 } else if (topicLevel.is_array()) {
336 for (const nlohmann::json& topicLevelEntry : topicLevel) {
337 foundTopicLevel = findMatchingTopicLevel(topicLevelEntry, topic);
338
339 if (!foundTopicLevel.empty()) {
340 break;
341 }
342 }
343 }
344
345 return foundTopicLevel;
346 }
nlohmann::json findMatchingTopicLevel(const nlohmann::json &topicLevel, const std::string &topic)

References findMatchingTopicLevel().

Referenced by findMatchingTopicLevel(), and getMappings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getConnection()

const nlohmann::json & mqtt::lib::MqttMapper::getConnection ( ) const

Definition at line 211 of file MqttMapper.cpp.

211 {
212 return mappingJson["connection"];
213 }

Referenced by mqtt::mqttintegrator::lib::Mqtt::Mqtt(), and mqtt::mqttintegrator::lib::Mqtt::onConnected().

Here is the caller graph for this function:

◆ getMapping()

const nlohmann::json & mqtt::lib::MqttMapper::getMapping ( ) const

Definition at line 203 of file MqttMapper.cpp.

203 {
204 return mappingJson;
205 }

References mappingJson.

Referenced by mqtt::lib::admin::makeMappingAdminRouter().

Here is the caller graph for this function:

◆ getMappings()

MqttMapper::MappedPublishes mqtt::lib::MqttMapper::getMappings ( const iot::mqtt::packets::Publish & publish)

Definition at line 231 of file MqttMapper.cpp.

231 {
232 MappedPublishes mappedPublishes;
233 if (mappingJson.contains("mapping") && !mappingJson["mapping"].empty()) {
234 nlohmann::json matchingTopicLevel = findMatchingTopicLevel(mappingJson["mapping"]["topic_level"], publish.getTopic());
235
236 if (!matchingTopicLevel.empty()) {
237 const nlohmann::json& subscription = matchingTopicLevel["subscription"];
238
239 if (subscription.contains("static")) {
240 VLOG(1) << "Topic mapping found for:";
241 VLOG(1) << " Type: static";
242 VLOG(1) << " Topic: " << publish.getTopic();
243 VLOG(1) << " Message: " << publish.getMessage();
244 VLOG(1) << " QoS: " << static_cast<uint16_t>(publish.getQoS());
245 VLOG(1) << " Retain: " << publish.getRetain();
246
247 getStaticMappings(subscription["static"], publish, mappedPublishes);
248 }
249
250 if (subscription.contains("value")) {
251 VLOG(1) << "Topic mapping found for:";
252 VLOG(1) << " Type: value";
253 VLOG(1) << " Topic: " << publish.getTopic();
254 VLOG(1) << " Message: " << publish.getMessage();
255 VLOG(1) << " QoS: " << static_cast<uint16_t>(publish.getQoS());
256 VLOG(1) << " Retain: " << publish.getRetain();
257
258 nlohmann::json json;
259 json["message"] = publish.getMessage();
260
261 getTemplateMappings(subscription["value"], json, publish, mappedPublishes);
262 }
263
264 if (subscription.contains("json")) {
265 VLOG(1) << "Topic mapping found for:";
266 VLOG(1) << " Type: json";
267 VLOG(1) << " Topic: " << publish.getTopic();
268 VLOG(1) << " Message: " << publish.getMessage();
269 VLOG(1) << " QoS: " << static_cast<uint16_t>(publish.getQoS());
270 VLOG(1) << " Retain: " << publish.getRetain();
271
272 try {
273 nlohmann::json json;
274 json["message"] = nlohmann::json::parse(publish.getMessage());
275
276 getTemplateMappings(subscription["json"], json, publish, mappedPublishes);
277 } catch (const nlohmann::json::parse_error& e) {
278 VLOG(1) << " Parsing message into json failed: " << publish.getMessage();
279 VLOG(1) << " What: " << e.what() << '\n'
280 << " Exception Id: " << e.id << '\n'
281 << " Byte position of error: " << e.byte;
282 }
283 }
284 }
285 }
286
287 return mappedPublishes;
288 }
nlohmann::json json
std::pair< std::vector< iot::mqtt::packets::Publish >, std::vector< ScheduledPublish > > MappedPublishes
Definition MqttMapper.h:83
void getTemplateMappings(const nlohmann::json &templateMapping, nlohmann::json &json, const iot::mqtt::packets::Publish &publish, MappedPublishes &mappedPublishes)
static void getStaticMappings(const nlohmann::json &staticMapping, const iot::mqtt::packets::Publish &publish, MappedPublishes &mappedPublishes)

References findMatchingTopicLevel(), getStaticMappings(), and getTemplateMappings().

Referenced by mqtt::mqttbroker::lib::Mqtt::onPublish(), and mqtt::mqttintegrator::lib::Mqtt::onPublish().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSchema()

const std::string & mqtt::lib::MqttMapper::getSchema ( )
static

Definition at line 111 of file MqttMapper.cpp.

111 {
113 }
static const std::string mappingJsonSchemaString
Definition MqttMapper.h:137

References mappingJsonSchemaString.

Referenced by mqtt::lib::admin::makeMappingAdminRouter().

Here is the caller graph for this function:

◆ getStaticMappings()

void mqtt::lib::MqttMapper::getStaticMappings ( const nlohmann::json & staticMapping,
const iot::mqtt::packets::Publish & publish,
MappedPublishes & mappedPublishes )
staticprivate

Definition at line 484 of file MqttMapper.cpp.

486 {
487 if (staticMapping.is_object()) {
488 publishMappedMessage(staticMapping, publish, mappedPublishes);
489 } else if (staticMapping.is_array()) {
490 for (const nlohmann::json& concreteStaticMapping : staticMapping) {
491 publishMappedMessage(concreteStaticMapping, publish, mappedPublishes);
492 }
493 }
494 }
static void publishMappedMessage(const std::string &topic, const std::string &message, uint8_t qoS, bool retain, double delay, MappedPublishes &mappedPublishes)

References publishMappedMessage().

Referenced by getMappings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTemplateMappings()

void mqtt::lib::MqttMapper::getTemplateMappings ( const nlohmann::json & templateMapping,
nlohmann::json & json,
const iot::mqtt::packets::Publish & publish,
MappedPublishes & mappedPublishes )
private

Definition at line 403 of file MqttMapper.cpp.

406 {
407 json["topic"] = publish.getTopic();
408 json["qos"] = publish.getQoS();
409 json["retain"] = publish.getRetain();
410 json["package_identifier"] = publish.getPacketIdentifier();
411
412 try {
413 VLOG(1) << " Render data: " << json.dump();
414
415 if (templateMapping.is_object()) {
416 publishMappedTemplate(templateMapping, json, mappedPublishes);
417 } else {
418 for (const nlohmann::json& concreteTemplateMapping : templateMapping) {
419 publishMappedTemplate(concreteTemplateMapping, json, mappedPublishes);
420 }
421 }
422 } catch (const nlohmann::json::exception& e) {
423 VLOG(1) << "JSON Exception during Render data:\n" << e.what();
424 }
425 }
void publishMappedTemplate(const nlohmann::json &templateMapping, nlohmann::json &json, MappedPublishes &mappedPublishes)

References publishMappedTemplate().

Referenced by getMappings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

MqttMapper & mqtt::lib::MqttMapper::operator= ( const MqttMapper & )
delete

◆ publishMappedMessage() [1/2]

void mqtt::lib::MqttMapper::publishMappedMessage ( const nlohmann::json & staticMapping,
const iot::mqtt::packets::Publish & publish,
MappedPublishes & mappedPublishes )
staticprivate

Definition at line 447 of file MqttMapper.cpp.

449 {
450 const nlohmann::json& messageMapping = staticMapping["message_mapping"];
451
452 VLOG(1) << " Message mapping: " << messageMapping.dump();
453
454 if (messageMapping.is_object()) {
455 if (messageMapping["message"] == publish.getMessage()) {
456 publishMappedMessage(staticMapping["mapped_topic"],
457 messageMapping["mapped_message"],
458 staticMapping["qos"],
459 staticMapping["retain"],
460 staticMapping["delay"],
461 mappedPublishes);
462 } else {
463 VLOG(1) << " no matching mapped message found";
464 }
465 } else {
466 const nlohmann::json::const_iterator matchedMessageMappingIterator =
467 std::find_if(messageMapping.begin(), messageMapping.end(), [&publish](const nlohmann::json& messageMappingCandidat) {
468 return messageMappingCandidat["message"] == publish.getMessage();
469 });
470
471 if (matchedMessageMappingIterator != messageMapping.end()) {
472 publishMappedMessage(staticMapping["mapped_topic"],
473 (*matchedMessageMappingIterator)["mapped_message"],
474 staticMapping["qos"],
475 staticMapping["retain"],
476 staticMapping["delay"],
477 mappedPublishes);
478 } else {
479 VLOG(1) << " no matching mapped message found";
480 }
481 }
482 }

Referenced by getStaticMappings().

Here is the caller graph for this function:

◆ publishMappedMessage() [2/2]

void mqtt::lib::MqttMapper::publishMappedMessage ( const std::string & topic,
const std::string & message,
uint8_t qoS,
bool retain,
double delay,
MappedPublishes & mappedPublishes )
staticprivate

Definition at line 427 of file MqttMapper.cpp.

428 {
429 VLOG(1) << " Mapped topic:";
430 VLOG(1) << " -> " << topic;
431 VLOG(1) << " Mapped message:";
432 VLOG(1) << " -> " << message;
433 VLOG(1) << " Send mapping:" << (delay > 0 ? " delayed" : "");
434 VLOG(1) << " Topic: " << topic;
435 VLOG(1) << " Message: " << message;
436 VLOG(1) << " QoS: " << static_cast<int>(qoS);
437 VLOG(1) << " retain: " << retain;
438 VLOG(1) << " Delay: " << delay;
439
440 if (delay < 0.0) {
441 mappedPublishes.first.emplace_back(0, topic, message, qoS, false, retain);
442 } else {
443 mappedPublishes.second.push_back({delay, iot::mqtt::packets::Publish(0, topic, message, qoS, false, retain)});
444 }
445 }

Referenced by publishMappedTemplate().

Here is the caller graph for this function:

◆ publishMappedTemplate()

void mqtt::lib::MqttMapper::publishMappedTemplate ( const nlohmann::json & templateMapping,
nlohmann::json & json,
MappedPublishes & mappedPublishes )
private

Definition at line 348 of file MqttMapper.cpp.

348 {
349 const std::string& mappingTemplate = templateMapping["mapping_template"];
350 const std::string& mappedTopic = templateMapping["mapped_topic"];
351
352 try {
353 // Render topic
354 const std::string renderedTopic = injaEnvironment->render(mappedTopic, json);
355 json["mapped_topic"] = renderedTopic;
356
357 VLOG(1) << " Mapped topic template: " << mappedTopic;
358 VLOG(1) << " -> " << renderedTopic;
359
360 try {
361 // Render message
362 const std::string renderedMessage = injaEnvironment->render(mappingTemplate, json);
363 VLOG(1) << " Mapped message template: " << mappingTemplate;
364 VLOG(1) << " -> " << renderedMessage;
365
366 const nlohmann::json& suppressions = templateMapping["suppressions"];
367 const bool retain = templateMapping["retain"];
368
369 if (suppressions.empty() || std::find(suppressions.begin(), suppressions.end(), renderedMessage) == suppressions.end() ||
370 (retain && renderedMessage.empty())) {
371 const uint8_t qoS = templateMapping["qos"];
372 const double delay = templateMapping["delay"];
373
374 VLOG(1) << " Send mapping:" << (delay > 0 ? " delayed" : "");
375 VLOG(1) << " Topic: " << renderedTopic;
376 VLOG(1) << " Message: " << renderedMessage << "";
377 VLOG(1) << " QoS: " << static_cast<int>(qoS);
378 VLOG(1) << " retain: " << retain;
379 VLOG(1) << " Delay: " << delay;
380
381 publishMappedMessage(renderedTopic, renderedMessage, qoS, retain, delay, mappedPublishes);
382 } else {
383 VLOG(1) << " Rendered message: '" << renderedMessage << "' in suppression list:";
384 for (const nlohmann::json& item : suppressions) {
385 VLOG(1) << " '" << item.get<std::string>() << "'";
386 }
387 VLOG(1) << " Send mapping: suppressed";
388 }
389 } catch (const inja::InjaError& e) {
390 VLOG(1) << " Message template rendering failed: " << mappingTemplate << " : " << json.dump();
391 VLOG(1) << " What: " << e.what();
392 VLOG(1) << " INJA: " << e.type << ": " << e.message;
393 VLOG(1) << " INJA (line:column):" << e.location.line << ":" << e.location.column;
394 }
395 } catch (const inja::InjaError& e) {
396 VLOG(1) << " Topic template rendering failed: " << mappingTemplate << " : " << json.dump();
397 VLOG(1) << " What: " << e.what();
398 VLOG(1) << " INJA: " << e.type << ": " << e.message;
399 VLOG(1) << " INJA (line:column):" << e.location.line << ":" << e.location.column;
400 }
401 }
const std::string type
Definition inja.hpp:283
const SourceLocation location
Definition inja.hpp:286
const std::string message
Definition inja.hpp:284

References inja::SourceLocation::column, injaEnvironment, inja::SourceLocation::line, inja::InjaError::location, inja::InjaError::message, publishMappedMessage(), inja::Environment::render(), and inja::InjaError::type.

Referenced by getTemplateMappings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMapping()

bool mqtt::lib::MqttMapper::setMapping ( nlohmann::json mappingJson)

Definition at line 115 of file MqttMapper.cpp.

115 { // can throw
116 delete injaEnvironment;
117
118 for (void* handle : pluginHandles) {
119 core::DynamicLoader::dlClose(handle);
120 }
121 pluginHandles.clear();
122
123 injaEnvironment = new inja::Environment;
124
125 nlohmann::json defaultPatch;
126
127 try {
128 defaultPatch = validator.validate(mappingJson);
129 } catch (const std::exception& e) {
130 throw std::runtime_error("Validating JSON failed: Mapping JSON = " + mappingJson.dump(4) + "\n" + e.what());
131 }
132
133 try {
134 mappingJson = mappingJson.patch(defaultPatch);
135 } catch (const std::exception& e) {
136 throw std::runtime_error("Patching JSON with default patch failed: Default patch = " + defaultPatch.dump(4) + "\n" + e.what());
137 }
138
139 bool mustReconnect = this->mappingJson["connection"] != mappingJson["connection"];
140
141 this->mappingJson = mappingJson;
142
143 if (mappingJson["mapping"].contains("plugins")) {
144 for (const nlohmann::json& pluginJson : mappingJson["mapping"]["plugins"]) {
145 const std::string plugin = pluginJson;
146
147 void* handle = core::DynamicLoader::dlOpen(plugin);
148
149 if (handle != nullptr) {
150 pluginHandles.push_back(handle);
151
152 VLOG(1) << " Loading plugin: " << plugin << " ...";
153
154 const std::vector<mqtt::lib::Function>* loadedFunctions =
155 static_cast<std::vector<mqtt::lib::Function>*>(core::DynamicLoader::dlSym(handle, "functions"));
156 if (loadedFunctions != nullptr) {
157 VLOG(1) << " Registering inja 'none void callbacks'";
158 for (const mqtt::lib::Function& function : *loadedFunctions) {
159 VLOG(1) << " " << function.name;
160
161 if (function.numArgs >= 0) {
162 injaEnvironment->add_callback(function.name, function.numArgs, function.function);
163 } else {
164 injaEnvironment->add_callback(function.name, function.function);
165 }
166 }
167 VLOG(1) << " Registering inja 'none void callbacks done'";
168 } else {
169 VLOG(1) << " No inja none 'void callbacks found' in plugin " << plugin;
170 }
171
172 const std::vector<mqtt::lib::VoidFunction>* loadedVoidFunctions =
173 static_cast<std::vector<mqtt::lib::VoidFunction>*>(core::DynamicLoader::dlSym(handle, "voidFunctions"));
174 if (loadedVoidFunctions != nullptr) {
175 VLOG(1) << " Registering inja 'void callbacks'";
176 for (const mqtt::lib::VoidFunction& voidFunction : *loadedVoidFunctions) {
177 VLOG(1) << " " << voidFunction.name;
178
179 if (voidFunction.numArgs >= 0) {
180 injaEnvironment->add_void_callback(voidFunction.name, voidFunction.numArgs, voidFunction.function);
181 } else {
182 injaEnvironment->add_void_callback(voidFunction.name, voidFunction.function);
183 }
184 }
185 VLOG(1) << " Registering inja 'void callbacks' done";
186 } else {
187 VLOG(1) << " No inja 'void callbacks' found in plugin " << plugin;
188 }
189
190 VLOG(1) << " Loading plugin done: " << plugin;
191 } else {
192 VLOG(1) << " Error loading plugin: " << plugin;
193 throw std::runtime_error("Error loading plugin '" + plugin + "': " + core::DynamicLoader::dlError());
194 }
195 }
196
197 VLOG(1) << "Loading plugins done";
198 }
199
200 return mustReconnect;
201 }
static const nlohmann::json_schema::json_validator validator
Definition MqttMapper.h:135

References injaEnvironment, mappingJson, pluginHandles, nlohmann::json_schema::json_validator::validate(), and validator.

Referenced by mqtt::lib::ConfigApplication::ConfigApplication(), and mqtt::lib::ConfigApplication::setMapping().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate() [1/2]

const nlohmann::json mqtt::lib::MqttMapper::validate ( const nlohmann::json & json)
static

Definition at line 223 of file MqttMapper.cpp.

223 {
224 return validator.validate(json);
225 }

References nlohmann::json_schema::json_validator::validate(), and validator.

Referenced by mqtt::lib::JsonMappingReader::rollbackTo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate() [2/2]

const nlohmann::json mqtt::lib::MqttMapper::validate ( const nlohmann::json & json,
nlohmann::json_schema::basic_error_handler & err )
static

Definition at line 227 of file MqttMapper.cpp.

227 {
228 return validator.validate(json, err);
229 }

References nlohmann::json_schema::json_validator::validate(), and validator.

Referenced by mqtt::lib::admin::makeMappingAdminRouter().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ injaEnvironment

inja::Environment* mqtt::lib::MqttMapper::injaEnvironment
private

Definition at line 133 of file MqttMapper.h.

Referenced by MqttMapper(), publishMappedTemplate(), setMapping(), and ~MqttMapper().

◆ mappingJson

nlohmann::json mqtt::lib::MqttMapper::mappingJson
private

Definition at line 129 of file MqttMapper.h.

Referenced by dump(), getMapping(), and setMapping().

◆ mappingJsonSchemaString

const std::string mqtt::lib::MqttMapper::mappingJsonSchemaString
staticprivate

Definition at line 137 of file MqttMapper.h.

Referenced by getSchema().

◆ pluginHandles

std::list<void*> mqtt::lib::MqttMapper::pluginHandles
private

Definition at line 131 of file MqttMapper.h.

Referenced by setMapping().

◆ validator

const nlohmann::json_schema::json_validator mqtt::lib::MqttMapper::validator
staticprivate

Definition at line 135 of file MqttMapper.h.

Referenced by setMapping(), validate(), and validate().


The documentation for this class was generated from the following files: