Skip to content

Commit 729ba31

Browse files
committed
Merge pull request #5513
856e862 namespace: drop most boost namespaces and a few header cleanups (Cory Fields) 9b1ab86 namespace: drop boost::assign altogether here (Cory Fields) a324199 namespace: remove boost namespace pollution (Cory Fields)
2 parents 3b95808 + 856e862 commit 729ba31

20 files changed

+90
-128
lines changed

src/bitcoin-cli.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#define _(x) std::string(x) /* Keep the _() around in case gettext or such will be used later to translate non-UI */
1616

1717
using namespace std;
18-
using namespace boost;
19-
using namespace boost::asio;
2018
using namespace json_spirit;
2119

2220
std::string HelpMessageCli()
@@ -108,12 +106,12 @@ Object CallRPC(const string& strMethod, const Array& params)
108106

109107
// Connect to localhost
110108
bool fUseSSL = GetBoolArg("-rpcssl", false);
111-
asio::io_service io_service;
112-
ssl::context context(io_service, ssl::context::sslv23);
113-
context.set_options(ssl::context::no_sslv2 | ssl::context::no_sslv3);
114-
asio::ssl::stream<asio::ip::tcp::socket> sslStream(io_service, context);
115-
SSLIOStreamDevice<asio::ip::tcp> d(sslStream, fUseSSL);
116-
iostreams::stream< SSLIOStreamDevice<asio::ip::tcp> > stream(d);
109+
boost::asio::io_service io_service;
110+
boost::asio::ssl::context context(io_service, boost::asio::ssl::context::sslv23);
111+
context.set_options(boost::asio::ssl::context::no_sslv2 | boost::asio::ssl::context::no_sslv3);
112+
boost::asio::ssl::stream<boost::asio::ip::tcp::socket> sslStream(io_service, context);
113+
SSLIOStreamDevice<boost::asio::ip::tcp> d(sslStream, fUseSSL);
114+
boost::iostreams::stream< SSLIOStreamDevice<boost::asio::ip::tcp> > stream(d);
117115

118116
const bool fConnected = d.connect(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", itostr(BaseParams().RPCPort())));
119117
if (!fConnected)

src/bitcoin-tx.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <boost/algorithm/string.hpp>
2323
#include <boost/assign/list_of.hpp>
2424

25-
using namespace boost::assign;
2625
using namespace std;
2726

2827
static bool fCreateBlank;
@@ -375,7 +374,7 @@ static void MutateTxSign(CMutableTransaction& tx, const string& flagStr)
375374
if (!prevOut.isObject())
376375
throw runtime_error("expected prevtxs internal object");
377376

378-
map<string,UniValue::VType> types = map_list_of("txid", UniValue::VSTR)("vout",UniValue::VNUM)("scriptPubKey",UniValue::VSTR);
377+
map<string,UniValue::VType> types = boost::assign::map_list_of("txid", UniValue::VSTR)("vout",UniValue::VNUM)("scriptPubKey",UniValue::VSTR);
379378
if (!prevOut.checkObject(types))
380379
throw runtime_error("prevtxs internal object typecheck fail");
381380

src/chainparams.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <boost/assign/list_of.hpp>
1515

1616
using namespace std;
17-
using namespace boost::assign;
1817

1918
struct SeedSpec6 {
2019
uint8_t addr[16];
@@ -157,11 +156,11 @@ class CMainParams : public CChainParams {
157156
vSeeds.push_back(CDNSSeedData("bitcoinstats.com", "seed.bitcoinstats.com"));
158157
vSeeds.push_back(CDNSSeedData("xf2.org", "bitseed.xf2.org"));
159158

160-
base58Prefixes[PUBKEY_ADDRESS] = list_of(0);
161-
base58Prefixes[SCRIPT_ADDRESS] = list_of(5);
162-
base58Prefixes[SECRET_KEY] = list_of(128);
163-
base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x88)(0xB2)(0x1E);
164-
base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x88)(0xAD)(0xE4);
159+
base58Prefixes[PUBKEY_ADDRESS] = boost::assign::list_of(0);
160+
base58Prefixes[SCRIPT_ADDRESS] = boost::assign::list_of(5);
161+
base58Prefixes[SECRET_KEY] = boost::assign::list_of(128);
162+
base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x88)(0xB2)(0x1E);
163+
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xAD)(0xE4);
165164

166165
convertSeed6(vFixedSeeds, pnSeed6_main, ARRAYLEN(pnSeed6_main));
167166

@@ -215,11 +214,11 @@ class CTestNetParams : public CMainParams {
215214
vSeeds.push_back(CDNSSeedData("bluematt.me", "testnet-seed.bluematt.me"));
216215
vSeeds.push_back(CDNSSeedData("bitcoin.schildbach.de", "testnet-seed.bitcoin.schildbach.de"));
217216

218-
base58Prefixes[PUBKEY_ADDRESS] = list_of(111);
219-
base58Prefixes[SCRIPT_ADDRESS] = list_of(196);
220-
base58Prefixes[SECRET_KEY] = list_of(239);
221-
base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF);
222-
base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x35)(0x83)(0x94);
217+
base58Prefixes[PUBKEY_ADDRESS] = boost::assign::list_of(111);
218+
base58Prefixes[SCRIPT_ADDRESS] = boost::assign::list_of(196);
219+
base58Prefixes[SECRET_KEY] = boost::assign::list_of(239);
220+
base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF);
221+
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94);
223222

224223
convertSeed6(vFixedSeeds, pnSeed6_test, ARRAYLEN(pnSeed6_test));
225224

src/chainparamsbase.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99

1010
#include <assert.h>
1111

12-
#include <boost/assign/list_of.hpp>
13-
14-
using namespace boost::assign;
15-
1612
/**
1713
* Main network
1814
*/

src/core_read.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#include <boost/algorithm/string/split.hpp>
2121
#include <boost/assign/list_of.hpp>
2222

23-
using namespace boost;
24-
using namespace boost::algorithm;
2523
using namespace std;
2624

2725
CScript ParseScript(std::string s)
@@ -44,34 +42,34 @@ CScript ParseScript(std::string s)
4442
string strName(name);
4543
mapOpNames[strName] = (opcodetype)op;
4644
// Convenience: OP_ADD and just ADD are both recognized:
47-
replace_first(strName, "OP_", "");
45+
boost::algorithm::replace_first(strName, "OP_", "");
4846
mapOpNames[strName] = (opcodetype)op;
4947
}
5048
}
5149

5250
vector<string> words;
53-
split(words, s, is_any_of(" \t\n"), token_compress_on);
51+
boost::algorithm::split(words, s, boost::algorithm::is_any_of(" \t\n"), boost::algorithm::token_compress_on);
5452

5553
for (std::vector<std::string>::const_iterator w = words.begin(); w != words.end(); ++w)
5654
{
5755
if (w->empty())
5856
{
5957
// Empty string, ignore. (boost::split given '' will return one word)
6058
}
61-
else if (all(*w, is_digit()) ||
62-
(starts_with(*w, "-") && all(string(w->begin()+1, w->end()), is_digit())))
59+
else if (all(*w, boost::algorithm::is_digit()) ||
60+
(boost::algorithm::starts_with(*w, "-") && all(string(w->begin()+1, w->end()), boost::algorithm::is_digit())))
6361
{
6462
// Number
6563
int64_t n = atoi64(*w);
6664
result << n;
6765
}
68-
else if (starts_with(*w, "0x") && (w->begin()+2 != w->end()) && IsHex(string(w->begin()+2, w->end())))
66+
else if (boost::algorithm::starts_with(*w, "0x") && (w->begin()+2 != w->end()) && IsHex(string(w->begin()+2, w->end())))
6967
{
7068
// Raw hex data, inserted NOT pushed onto stack:
7169
std::vector<unsigned char> raw = ParseHex(string(w->begin()+2, w->end()));
7270
result.insert(result.end(), raw.begin(), raw.end());
7371
}
74-
else if (w->size() >= 2 && starts_with(*w, "'") && ends_with(*w, "'"))
72+
else if (w->size() >= 2 && boost::algorithm::starts_with(*w, "'") && boost::algorithm::ends_with(*w, "'"))
7573
{
7674
// Single-quoted string, pushed as data. NOTE: this is poor-man's
7775
// parsing, spaces/tabs/newlines in single-quoted strings won't work.

src/db.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <openssl/rand.h>
2525

2626
using namespace std;
27-
using namespace boost;
2827

2928

3029
unsigned int nWalletDBUpdated;
@@ -73,9 +72,9 @@ bool CDBEnv::Open(const boost::filesystem::path& pathIn)
7372
boost::this_thread::interruption_point();
7473

7574
path = pathIn;
76-
filesystem::path pathLogDir = path / "database";
75+
boost::filesystem::path pathLogDir = path / "database";
7776
TryCreateDirectory(pathLogDir);
78-
filesystem::path pathErrorFile = path / "db.log";
77+
boost::filesystem::path pathErrorFile = path / "db.log";
7978
LogPrintf("CDBEnv::Open : LogDir=%s ErrorFile=%s\n", pathLogDir.string(), pathErrorFile.string());
8079

8180
unsigned int nEnvFlags = 0;

src/init.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#include <boost/thread.hpp>
4444
#include <openssl/crypto.h>
4545

46-
using namespace boost;
4746
using namespace std;
4847

4948
#ifdef ENABLE_WALLET
@@ -427,12 +426,12 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
427426
}
428427

429428
// hardcoded $DATADIR/bootstrap.dat
430-
filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat";
431-
if (filesystem::exists(pathBootstrap)) {
429+
boost::filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat";
430+
if (boost::filesystem::exists(pathBootstrap)) {
432431
FILE *file = fopen(pathBootstrap.string().c_str(), "rb");
433432
if (file) {
434433
CImportingNow imp;
435-
filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old";
434+
boost::filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old";
436435
LogPrintf("Importing bootstrap.dat...\n");
437436
LoadExternalBlockFile(file);
438437
RenameOver(pathBootstrap, pathBootstrapOld);
@@ -816,7 +815,7 @@ bool AppInit2(boost::thread_group& threadGroup)
816815
return false;
817816
}
818817

819-
if (filesystem::exists(GetDataDir() / strWalletFile))
818+
if (boost::filesystem::exists(GetDataDir() / strWalletFile))
820819
{
821820
CDBEnv::VerifyResult r = bitdb.Verify(strWalletFile, CWalletDB::Recover);
822821
if (r == CDBEnv::RECOVER_OK)
@@ -937,20 +936,20 @@ bool AppInit2(boost::thread_group& threadGroup)
937936
fReindex = GetBoolArg("-reindex", false);
938937

939938
// Upgrading to 0.8; hard-link the old blknnnn.dat files into /blocks/
940-
filesystem::path blocksDir = GetDataDir() / "blocks";
941-
if (!filesystem::exists(blocksDir))
939+
boost::filesystem::path blocksDir = GetDataDir() / "blocks";
940+
if (!boost::filesystem::exists(blocksDir))
942941
{
943-
filesystem::create_directories(blocksDir);
942+
boost::filesystem::create_directories(blocksDir);
944943
bool linked = false;
945944
for (unsigned int i = 1; i < 10000; i++) {
946-
filesystem::path source = GetDataDir() / strprintf("blk%04u.dat", i);
947-
if (!filesystem::exists(source)) break;
948-
filesystem::path dest = blocksDir / strprintf("blk%05u.dat", i-1);
945+
boost::filesystem::path source = GetDataDir() / strprintf("blk%04u.dat", i);
946+
if (!boost::filesystem::exists(source)) break;
947+
boost::filesystem::path dest = blocksDir / strprintf("blk%05u.dat", i-1);
949948
try {
950-
filesystem::create_hard_link(source, dest);
949+
boost::filesystem::create_hard_link(source, dest);
951950
LogPrintf("Hardlinked %s -> %s\n", source.string(), dest.string());
952951
linked = true;
953-
} catch (const filesystem::filesystem_error& e) {
952+
} catch (const boost::filesystem::filesystem_error& e) {
954953
// Note: hardlink creation failing is not a disaster, it just means
955954
// blocks will get re-downloaded from peers.
956955
LogPrintf("Error hardlinking blk%04u.dat : %s\n", i, e.what());

src/main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <boost/filesystem/fstream.hpp>
3030
#include <boost/thread.hpp>
3131

32-
using namespace boost;
3332
using namespace std;
3433

3534
#if defined(NDEBUG)
@@ -2789,7 +2788,7 @@ bool AbortNode(const std::string &strMessage, const std::string &userMessage) {
27892788

27902789
bool CheckDiskSpace(uint64_t nAdditionalBytes)
27912790
{
2792-
uint64_t nFreeBytesAvailable = filesystem::space(GetDataDir()).available;
2791+
uint64_t nFreeBytesAvailable = boost::filesystem::space(GetDataDir()).available;
27932792

27942793
// Check for nMinDiskSpace bytes (currently 50MB)
27952794
if (nFreeBytesAvailable < nMinDiskSpace + nAdditionalBytes)

src/net.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
#endif
5050
#endif
5151

52-
using namespace boost;
5352
using namespace std;
5453

5554
namespace {

src/qt/paymentserver.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
#include <QUrlQuery>
4747
#endif
4848

49-
using namespace boost;
5049
using namespace std;
5150

5251
const int BITCOIN_IPC_CONNECT_TIMEOUT = 1000; // milliseconds

0 commit comments

Comments
 (0)