From 206cb7a528729a096b6e9d8d500704454ed3b15e Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Thu, 29 Dec 2022 10:14:03 +0100 Subject: [PATCH] MT#55831 dsm: helper functions / macros for modules: replaceParams/SET_ERROR/CLR_ERROR use resolveVars in module actions/condition to replace only one variable/param, use replaceParams to replace substrings as well, e.g. myAction($myvar) - resolveVars myOtherAction("this is $(myvar) and #(myparam) replaced") - replaceParams Change-Id: Ia8d39259e2c24111b4ffe765cbd637627be346ab --- apps/dsm/DSMCoreModule.h | 4 ++++ apps/dsm/DSMSession.h | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/apps/dsm/DSMCoreModule.h b/apps/dsm/DSMCoreModule.h index b02f1d13..a15c48e1 100644 --- a/apps/dsm/DSMCoreModule.h +++ b/apps/dsm/DSMCoreModule.h @@ -171,6 +171,10 @@ class TestDSMCondition map* event_params); }; +/** return string q with variables/params/selects replaced */ +string replaceParams(const string& q, AmSession* sess, DSMSession* sc_sess, + map* event_params); + /** return string q with variables/params/selects replaced */ string replaceParams(const string& q, AmSession* sess, DSMSession* sc_sess, map* event_params); diff --git a/apps/dsm/DSMSession.h b/apps/dsm/DSMSession.h index fbc46b17..c2840926 100644 --- a/apps/dsm/DSMSession.h +++ b/apps/dsm/DSMSession.h @@ -111,6 +111,18 @@ using std::map; s->CLR_STRERROR; \ } while (0) +#define SET_ERROR(s, errno, errstr) \ + do { \ + s->SET_ERRNO(errno); \ + s->SET_STRERROR(errstr); \ + } while (0) + +#define CLR_ERROR(s) \ + do { \ + s->CLR_ERRNO; \ + s->CLR_STRERROR; \ + } while (0) + typedef map VarMapT; typedef map AVarMapT;