summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/plib/pfunction.cpp
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2019-01-06 13:17:20 +0100
committer couriersud <couriersud@gmx.org>2019-01-06 13:17:20 +0100
commit1415421fd707ad02e0cfddf20bf70bbd045a9203 (patch)
treea5df29611fa9a0e2670ab5f45b13b37aaf1c04d4 /src/lib/netlist/plib/pfunction.cpp
parentc5b3f76360813e6a8caa139c3d1c743ce31d9560 (diff)
More c++ alignment. pstring now behaves like std::string. (nw)
This change removes all string extensions like trim, rpad, left, right, ... from pstring and replaces them by function templates. This aligns a lot better with the intentions of the standard library.
Diffstat (limited to 'src/lib/netlist/plib/pfunction.cpp')
-rw-r--r--src/lib/netlist/plib/pfunction.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/lib/netlist/plib/pfunction.cpp b/src/lib/netlist/plib/pfunction.cpp
index 79f09cb4a46..e9e2de009c8 100644
--- a/src/lib/netlist/plib/pfunction.cpp
+++ b/src/lib/netlist/plib/pfunction.cpp
@@ -17,7 +17,7 @@ namespace plib {
void pfunction::compile(const std::vector<pstring> &inputs, const pstring &expr)
{
- if (expr.startsWith("rpn:"))
+ if (plib::startsWith(expr, "rpn:"))
compile_postfix(inputs, expr.substr(4));
else
compile_infix(inputs, expr);
@@ -68,10 +68,8 @@ void pfunction::compile_postfix(const std::vector<pstring> &inputs,
}
if (rc.m_cmd != PUSH_INPUT)
{
- bool err = false;
rc.m_cmd = PUSH_CONST;
- rc.m_param = cmd.as_double(&err);
- if (err)
+ if (!plib::pstod_ne(cmd, rc.m_param))
throw plib::pexception(plib::pfmt("nld_function: unknown/misformatted token <{1}> in <{2}>")(cmd)(expr));
stk += 1;
}
@@ -88,7 +86,7 @@ static int get_prio(pstring v)
{
if (v == "(" || v == ")")
return 1;
- else if (v.left(1) >= "a" && v.left(1) <= "z")
+ else if (plib::left(v, 1) >= "a" && plib::left(v, 1) <= "z")
return 0;
else if (v == "*" || v == "/")
return 20;
@@ -113,7 +111,7 @@ void pfunction::compile_infix(const std::vector<pstring> &inputs, const pstring
{
// Shunting-yard infix parsing
std::vector<pstring> sep = {"(", ")", ",", "*", "/", "+", "-", "^"};
- std::vector<pstring> sexpr(plib::psplit(expr.replace_all(" ",""), sep));
+ std::vector<pstring> sexpr(plib::psplit(plib::replace_all(expr, pstring(" "), pstring("")), sep));
std::stack<pstring> opstk;
std::vector<pstring> postfix;