MT#59962 DSM: Add new function 'removeFromString()'

To simplify the work in DSM with strings, the new function
which removes patterns from the source string, has been added.

This allows us to remove unneeded stuff from the given value,
avoiding usage of complex regexes.

Change-Id: I07fd08938a10475120affb395c5b506e8d412f78
mr13.0.1
Donat Zenichev 2 years ago
parent b9c825cbdc
commit fa2b78c782

@ -124,6 +124,8 @@ DSMAction* DSMCoreModule::getAction(const string& from_str) {
DEF_CMD("unregisterEventQueue", SCUnregisterEventQueueAction);
DEF_CMD("createSystemDSM", SCCreateSystemDSMAction);
DEF_CMD("removeFromString", SCRemovePatternAction);
DEF_CMD("getErrorCodePlayback", SCGetErrorCodePlaybackAction);
if (cmd == "DI") {
@ -1008,6 +1010,20 @@ EXEC_ACTION_START(SCArrayIndexAction) {
}
} EXEC_ACTION_END;
CONST_ACTION_2P(SCRemovePatternAction, ',', false);
EXEC_ACTION_START(SCRemovePatternAction) {
string source_name = (par1.length() && par1[0] == '$') ? par1.substr(1) : par1;
string source_value = resolveVars(par1, sess, sc_sess, event_params);
string pattern = par2;
size_t pos = std::string::npos;
while ((pos = source_value.find(pattern)) != std::string::npos)
{
source_value.erase(pos, pattern.length());
}
sc_sess->var[source_name] = source_value;
} EXEC_ACTION_END;
CONST_ACTION_3P(SCGetErrorCodePlaybackAction, ',', false);
EXEC_ACTION_START(SCGetErrorCodePlaybackAction) {
string source_value = resolveVars(par1, sess, sc_sess, event_params);

@ -135,6 +135,8 @@ DEF_ACTION_1P(SCUnregisterEventQueueAction);
DEF_ACTION_2P(SCCreateSystemDSMAction);
DEF_ACTION_2P(SCRemovePatternAction);
DEF_ACTION_3P(SCGetErrorCodePlaybackAction);
DEF_ACTION_1P(SCTrackObjectAction);

Loading…
Cancel
Save