diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2021-09-11 13:02:47 +0200 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2022-04-11 22:19:46 +0200 |
commit | 9cc8e876e412056ed22d364538f0da3d5d71946d (patch) | |
tree | cf30bf1d489e1bd7a37274deedf06fe60fb175b4 /src/util/string.h | |
parent | 2b5a741e98f186e50d9fbe1ceadcc8b8c91547f7 (diff) |
refactor: introduce single-separator split helper `SplitString`
This helper uses spanparsing::Split internally and enables to replace
all calls to boost::split where only a single separator is passed.
Co-authored-by: Martin Ankerl <Martin.Ankerl@gmail.com>
Co-authored-by: MarcoFalke <falke.marco@gmail.com>
Diffstat (limited to 'src/util/string.h')
-rw-r--r-- | src/util/string.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/util/string.h b/src/util/string.h index a3b8df8d78..bcd6905fd5 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -6,6 +6,7 @@ #define BITCOIN_UTIL_STRING_H #include <attributes.h> +#include <util/spanparsing.h> #include <algorithm> #include <array> @@ -15,6 +16,11 @@ #include <string> #include <vector> +[[nodiscard]] inline std::vector<std::string> SplitString(std::string_view str, char sep) +{ + return spanparsing::Split<std::string>(str, sep); +} + [[nodiscard]] inline std::string TrimString(const std::string& str, const std::string& pattern = " \f\n\r\t\v") { std::string::size_type front = str.find_first_not_of(pattern); |