eis/eqpalg/exp_macro/is_persist.cc

15 lines
471 B
C++
Raw Normal View History

#include <eqpalg/exp_macro/is_persist.h>
std::string replace_is_persist_macro(std::string&& exp_str) {
boost::regex base_regex("is_persist\\((\\d+),([+-]?\\d+\\.?\\d*)\\)");
std::string plv;
std::stringstream ss;
ss << "(";
for (auto i = 0; i < 3; i++) {
ss << "abs(pv$1_" << i << " - pv$1_" << i + 1 << ") < $2 && ";
}
ss << "abs(pv$1_3 - pv$1_4) < $2)";
plv = ss.str();
auto ret = boost::regex_replace(exp_str, base_regex, plv);
return ret;
}