Skip to content

Commit 4f74c59

Browse files
committed
util: Move util/string.h functions to util namespace
There are no changes to behavior. Changes in this commit are all additions, and are easiest to review using "git diff -U0 --word-diff-regex=." options. Motivation for this change is to keep util functions with really generic names like "Split" and "Join" out of the global namespace so it is easier to see where these functions are defined, and so they don't interfere with function overloading, especially since the util library is a dependency of the kernel library and intended to be used with external code.
1 parent 4d05d3f commit 4f74c59

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+159
-14
lines changed

src/base58.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
#include <limits>
1616

17+
using util::ContainsNoNUL;
18+
1719
/** All alphanumeric characters except for "0", "I", "O", and "l" */
1820
static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
1921
static const int8_t mapBase58[256] = {

src/bench/bench.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <vector>
1919

2020
using namespace std::chrono_literals;
21+
using util::Join;
2122

2223
const std::function<void(const std::string&)> G_TEST_LOG_FUN{};
2324

src/bench/bench_bitcoin.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <sstream>
1717
#include <vector>
1818

19+
using util::SplitString;
20+
1921
static const char* DEFAULT_BENCH_FILTER = ".*";
2022
static constexpr int64_t DEFAULT_MIN_TIME_MS{10};
2123
/** Priority level default value, run "all" priority levels */

src/bitcoin-cli.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
#include <event2/keyvalq_struct.h>
4343
#include <support/events.h>
4444

45+
using util::Join;
46+
using util::ToString;
47+
4548
// The server returns time values from a mockable system clock, but it is not
4649
// trivial to get the mocked time from the server, nor is it needed for now, so
4750
// just use a plain system_clock.

src/bitcoin-tx.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
#include <functional>
3333
#include <memory>
3434

35+
using util::SplitString;
36+
using util::ToString;
37+
using util::TrimString;
38+
using util::TrimStringView;
39+
3540
static bool fCreateBlank;
3641
static std::map<std::string,UniValue> registers;
3742
static const int CONTINUE_EXECUTION=-1;

src/bitcoin-wallet.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <string>
2525
#include <tuple>
2626

27+
using util::Join;
28+
2729
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
2830

2931
static void SetupWalletToolArgs(ArgsManager& argsman)

src/blockfilter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <util/golombrice.h>
1717
#include <util/string.h>
1818

19+
using util::Join;
20+
1921
static const std::map<BlockFilterType, std::string> g_filter_types = {
2022
{BlockFilterType::BASIC, "basic"},
2123
};

src/chainparams.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <stdexcept>
2222
#include <vector>
2323

24+
using util::SplitString;
25+
2426
void ReadSigNetArgs(const ArgsManager& args, CChainParams::SigNetOptions& options)
2527
{
2628
if (args.IsArgSet("-signetseednode")) {

src/clientversion.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <string>
1414
#include <vector>
1515

16+
using util::Join;
17+
1618
/**
1719
* Name of client reported in the 'version' message. Report the same name
1820
* for both bitcoind and bitcoin-qt, to make it harder for attackers to

src/common/config.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#include <utility>
2828
#include <vector>
2929

30+
using util::TrimString;
31+
using util::TrimStringView;
32+
3033
static bool GetConfigOptions(std::istream& stream, const std::string& filepath, std::string& error, std::vector<std::pair<std::string, std::string>>& options, std::list<SectionInfo>& sections)
3134
{
3235
std::string str, prefix;

0 commit comments

Comments
 (0)