diff options
author | MarcoFalke <falke.marco@gmail.com> | 2018-07-24 14:49:54 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2018-07-24 14:50:05 -0400 |
commit | 1211b15bf6c0b2904d90b96a9b3834c5cb9e7b4e (patch) | |
tree | f759e03bdb78463726b80e83c1ce189773bb50de /src/core_read.cpp | |
parent | 7a9bca61fa5598455d854662a68b560725341f20 (diff) | |
parent | e3245f2e7b6f98cda38a3806da854f7d513fec2f (diff) | |
download | bitcoin-1211b15bf6c0b2904d90b96a9b3834c5cb9e7b4e.tar.xz |
Merge #13656: Remove the boost/algorithm/string/predicate.hpp dependency
e3245f2e7b Removes Boost predicate.hpp dependency (251)
Pull request description:
This pull request removes the `boost/algorithm/string/predicate.hpp` dependency from the project.
To replace the the `predicate.hpp` dependency from the project the function calls to `boost::algorithm::starts_with` and `boost::algorithm::ends_with` have been replaced with respectively C++11's `std::basic_string::front` and `std::basic_string::back` function calls.
Refactors that were not required, but have been done anyways:
- The Boost function `all` was implicitly made available via the `predicate.hpp` header. Instead of including the appropriate header, function calls to `all` have been replaced with function calls to `std::all_of`.
- The `boost::algorithm::is_digit` predicate has been replaced with a custom `IsDigit` function that is locale independent and ASCII deterministic.
Tree-SHA512: 22dda6adfb4d7ac0cabac8cc33e8fb8330c899805acc1ae4ede402c4b11ea75a399414b389dfaa3650d23b47f41351b4650077af9005d598fbe48d5277bdc320
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. |