15 static bool parseAndSetTriggerRules(
const std::string& trigger) {
17 std::forward_list<std::shared_ptr<TriggerRule>> rules;
19 for (
size_t i = 0, j = 0; i < trigger.size(); i = j + 1) {
20 j = trigger.find(
'|', i);
21 if (j == std::string::npos) {
24 auto token = trigger.substr(i, j - i);
27 rules.push_front(std::move(ptr));
51 if (argv.size() < 2) {
56 if (!parseAndSetTriggerRules(argv[1])) {
61 if (!called_by_event) {
67 encoder.
write(
"trigger_rules", argv[1]);
69 transport.
send(
reinterpret_cast<const char*
>(encoder.
data()), encoder.
size());
79 encoder.
write(
"trigger_rules", trigger);
81 transport.
send(
reinterpret_cast<const char*
>(encoder.
data()), encoder.
size());
90 if (!transport || !*transport) {
98 std::vector<std::string> args{
"INIT@TRIGGER", std::move(trigger)};
Definition: ma_codec_base.h:14
virtual ma_err_t end()=0
Encoder type for end.
virtual const void * data() const =0
Encoder type for get data.
virtual ma_err_t begin()=0
Encoder type for begin.
virtual ma_err_t write(const std::string &key, int8_t value)=0
Encoder type for write int8_t value.
virtual const size_t size() const =0
Encoder type for get size.
Definition: ma_transport.h:12
virtual size_t send(const char *data, size_t length) noexcept=0
#define MA_LOGD(TAG,...)
Definition: ma_debug.h:79
#define MA_TAG
Definition: ma_debug.h:9
#define MA_STORAGE_KEY_TRIGGER_RULES
Definition: ma_definations.h:43
@ MA_MSG_TYPE_RESP
Definition: ma_types.h:252
ma_err_t
Definition: ma_types.h:21
@ MA_OK
Definition: ma_types.h:23
@ MA_EINVAL
Definition: ma_types.h:28
Definition: algorithm.hpp:11
void initDefaultTrigger(Encoder &encoder)
Definition: trigger.hpp:84
void getTrigger(const std::vector< std::string > &argv, Transport &transport, Encoder &encoder)
Definition: trigger.hpp:72
void configureTrigger(const std::vector< std::string > &argv, Transport &transport, Encoder &encoder, bool called_by_event=false)
Definition: trigger.hpp:40
std::forward_list< std::shared_ptr< TriggerRule > > trigger_rules
Definition: refactor_required.hpp:296
ma::Mutex trigger_rules_mutex
Definition: refactor_required.hpp:297
#define static_resource
Definition: resource.hpp:64
static std::shared_ptr< TriggerRule > create(const std::string &rule_str)
Definition: refactor_required.hpp:147