diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-08-08 11:44:27 +0100 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-08-08 11:53:23 +0100 |
commit | fea75ad3caa29972db32d3ce7e0fe125ec77a0eb (patch) | |
tree | 08d2d1c87ca5b45d5128b858e26504928ffeff6d | |
parent | 857526e8cbb0847a865e9c2509425960d458f535 (diff) |
refactor: Drop `boost/algorithm/string/replace.hpp` dependency
-rw-r--r-- | src/util/string.cpp | 9 | ||||
-rw-r--r-- | src/util/string.h | 2 | ||||
-rwxr-xr-x | test/lint/lint-includes.py | 3 |
3 files changed, 7 insertions, 7 deletions
diff --git a/src/util/string.cpp b/src/util/string.cpp index dff782c330..db6dbe4135 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -4,11 +4,12 @@ #include <util/string.h> -#include <boost/algorithm/string/replace.hpp> - +#include <regex> #include <string> +#include <utility> -void ReplaceAll(std::string& in_out, std::string_view search, std::string_view substitute) +void ReplaceAll(std::string& in_out, const std::string& search, const std::string& substitute) { - boost::replace_all(in_out, search, substitute); + if (search.empty()) return; + in_out = std::regex_replace(in_out, std::regex(std::move(search)), substitute); } diff --git a/src/util/string.h b/src/util/string.h index df20e34ae9..dd4de888bb 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -17,7 +17,7 @@ #include <string_view> #include <vector> -void ReplaceAll(std::string& in_out, std::string_view search, std::string_view substitute); +void ReplaceAll(std::string& in_out, const std::string& search, const std::string& substitute); [[nodiscard]] inline std::vector<std::string> SplitString(std::string_view str, char sep) { diff --git a/test/lint/lint-includes.py b/test/lint/lint-includes.py index afdca0d418..b3fa4b9303 100755 --- a/test/lint/lint-includes.py +++ b/test/lint/lint-includes.py @@ -21,8 +21,7 @@ EXCLUDED_DIRS = ["src/leveldb/", "src/minisketch/", ] -EXPECTED_BOOST_INCLUDES = ["boost/algorithm/string/replace.hpp", - "boost/date_time/posix_time/posix_time.hpp", +EXPECTED_BOOST_INCLUDES = ["boost/date_time/posix_time/posix_time.hpp", "boost/multi_index/hashed_index.hpp", "boost/multi_index/ordered_index.hpp", "boost/multi_index/sequenced_index.hpp", |