diff options
author | 2019-01-10 00:30:51 +0100 | |
---|---|---|
committer | 2019-01-10 00:30:51 +0100 | |
commit | 4213a396d8652e7ea26c07c133932bd9f5a87faa (patch) | |
tree | 8f20d8db7d066c535f2ea5d60b5556537219de59 /src/lib/netlist/plib/putil.cpp | |
parent | f8d5b95e373ede549c730998d9cfe3be04fdbd43 (diff) |
Improve type safety on string->numeric conversions. (nw)
Also fixed an issue with 7497.
./nltool -t 5 -f src/mame/machine/nl_tp1983.cpp -v
now runs again.
Diffstat (limited to 'src/lib/netlist/plib/putil.cpp')
-rw-r--r-- | src/lib/netlist/plib/putil.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/lib/netlist/plib/putil.cpp b/src/lib/netlist/plib/putil.cpp index 0d3a0ebca3f..92e0e6b3ab1 100644 --- a/src/lib/netlist/plib/putil.cpp +++ b/src/lib/netlist/plib/putil.cpp @@ -64,6 +64,36 @@ namespace plib return ret; } + std::vector<std::string> psplit_r(const std::string &stri, + const std::string &token, + const std::size_t maxsplit) + { + std::string str(stri); + std::vector<std::string> result; + std::size_t splits = 0; + + while(str.size()) + { + std::size_t index = str.rfind(token); + bool found = index!=std::string::npos; + if (found) + splits++; + if ((splits <= maxsplit || maxsplit == 0) && found) + { + result.push_back(str.substr(index+token.size())); + str = str.substr(0, index); + if (str.size()==0) + result.push_back(str); + } + else + { + result.push_back(str); + str = ""; + } + } + return result; + } + std::vector<pstring> psplit(const pstring &str, const std::vector<pstring> &onstrl) { pstring col = ""; |