diff options
author | 251 <13120787+251Labs@users.noreply.github.com> | 2018-07-22 21:34:45 +0200 |
---|---|---|
committer | 251 <13120787+251Labs@users.noreply.github.com> | 2018-07-22 21:34:45 +0200 |
commit | e3245f2e7b6f98cda38a3806da854f7d513fec2f (patch) | |
tree | 84407bc96e5c75f252079bdb3a8d07fa6f4314b9 /src/core_read.cpp | |
parent | 0a34593ddb7a6d10c19533754d7a23345a155986 (diff) |
Removes Boost predicate.hpp dependency
This is a squashed commit that squashes the following commits:
This commit removes the `boost/algorithm/string/predicate.hpp` dependenc
from the project by replacing the function calls to `boost::algorithm::starts_with`
`boost::algorithm::ends_with` and `all` with respectively C++11'
`std::basic_string::front`, `std::basic_string::back`, `std::all_of` function calls
This commit replaces `boost::algorithm::is_digit` with a locale independent isdigi
function, because the use of the standard library's `isdigit` and `std::isdigit
functions is discoraged in the developer notes
Diffstat (limited to 'src/core_read.cpp')
-rw-r--r-- | src/core_read.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/core_read.cpp b/src/core_read.cpp index 067e1b91bd..7225ecc4bb 100644 --- a/src/core_read.cpp +++ b/src/core_read.cpp @@ -16,10 +16,11 @@ #include <version.h> #include <boost/algorithm/string/classification.hpp> -#include <boost/algorithm/string/predicate.hpp> #include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/split.hpp> +#include <algorithm> + CScript ParseScript(const std::string& s) { CScript result; @@ -54,20 +55,20 @@ CScript ParseScript(const std::string& s) { // Empty string, ignore. (boost::split given '' will return one word) } - else if (all(*w, boost::algorithm::is_digit()) || - (boost::algorithm::starts_with(*w, "-") && all(std::string(w->begin()+1, w->end()), boost::algorithm::is_digit()))) + else if (std::all_of(w->begin(), w->end(), ::IsDigit) || + (w->front() == '-' && w->size() > 1 && std::all_of(w->begin()+1, w->end(), ::IsDigit))) { // Number int64_t n = atoi64(*w); result << n; } - else if (boost::algorithm::starts_with(*w, "0x") && (w->begin()+2 != w->end()) && IsHex(std::string(w->begin()+2, w->end()))) + else if (w->substr(0,2) == "0x" && w->size() > 2 && IsHex(std::string(w->begin()+2, w->end()))) { // Raw hex data, inserted NOT pushed onto stack: std::vector<unsigned char> raw = ParseHex(std::string(w->begin()+2, w->end())); result.insert(result.end(), raw.begin(), raw.end()); } - else if (w->size() >= 2 && boost::algorithm::starts_with(*w, "'") && boost::algorithm::ends_with(*w, "'")) + else if (w->size() >= 2 && w->front() == '\'' && w->back() == '\'') { // Single-quoted string, pushed as data. NOTE: this is poor-man's // parsing, spaces/tabs/newlines in single-quoted strings won't work. |