Skip to content

Commit c047b16

Browse files
committed
Merge #9643: [refactor] Remove using namespace <xxx> from wallet/ & util*
a57845c Refactor: Remove using namespace <xxx> from util* (Karl-Johan Alm) 8a52281 Refactor: Remove using namespace <xxx> from wallet/ (Karl-Johan Alm) Tree-SHA512: cd06b569fee0ce25db753ade5ee694b582733a8883bfd62a27613020266d2a902af079ef23b58a5412f7af4afd7681e689af3c7780e5ea00c77b16d144d72db5
2 parents 6996e06 + a57845c commit c047b16

File tree

10 files changed

+349
-368
lines changed

10 files changed

+349
-368
lines changed

src/util.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ namespace boost {
9797

9898
} // namespace boost
9999

100-
using namespace std;
100+
101101

102102
const char * const BITCOIN_CONF_FILENAME = "bitcoin.conf";
103103
const char * const BITCOIN_PID_FILENAME = "bitcoind.pid";
104104

105105
CCriticalSection cs_args;
106-
map<string, string> mapArgs;
107-
static map<string, vector<string> > _mapMultiArgs;
108-
const map<string, vector<string> >& mapMultiArgs = _mapMultiArgs;
106+
std::map<std::string, std::string> mapArgs;
107+
static std::map<std::string, std::vector<std::string> > _mapMultiArgs;
108+
const std::map<std::string, std::vector<std::string> >& mapMultiArgs = _mapMultiArgs;
109109
bool fDebug = false;
110110
bool fPrintToConsole = false;
111111
bool fPrintToDebugLog = true;
@@ -191,7 +191,7 @@ static boost::once_flag debugPrintInitFlag = BOOST_ONCE_INIT;
191191
*/
192192
static FILE* fileout = NULL;
193193
static boost::mutex* mutexDebugLog = NULL;
194-
static list<string> *vMsgsBeforeOpenLog;
194+
static std::list<std::string>* vMsgsBeforeOpenLog;
195195

196196
static int FileWriteStr(const std::string &str, FILE *fp)
197197
{
@@ -202,7 +202,7 @@ static void DebugPrintInit()
202202
{
203203
assert(mutexDebugLog == NULL);
204204
mutexDebugLog = new boost::mutex();
205-
vMsgsBeforeOpenLog = new list<string>;
205+
vMsgsBeforeOpenLog = new std::list<std::string>;
206206
}
207207

208208
void OpenDebugLog()
@@ -238,22 +238,22 @@ bool LogAcceptCategory(const char* category)
238238
// This helps prevent issues debugging global destructors,
239239
// where mapMultiArgs might be deleted before another
240240
// global destructor calls LogPrint()
241-
static boost::thread_specific_ptr<set<string> > ptrCategory;
241+
static boost::thread_specific_ptr<std::set<std::string> > ptrCategory;
242242
if (ptrCategory.get() == NULL)
243243
{
244244
if (mapMultiArgs.count("-debug")) {
245-
const vector<string>& categories = mapMultiArgs.at("-debug");
246-
ptrCategory.reset(new set<string>(categories.begin(), categories.end()));
245+
const std::vector<std::string>& categories = mapMultiArgs.at("-debug");
246+
ptrCategory.reset(new std::set<std::string>(categories.begin(), categories.end()));
247247
// thread_specific_ptr automatically deletes the set when the thread ends.
248248
} else
249-
ptrCategory.reset(new set<string>());
249+
ptrCategory.reset(new std::set<std::string>());
250250
}
251-
const set<string>& setCategories = *ptrCategory.get();
251+
const std::set<std::string>& setCategories = *ptrCategory.get();
252252

253253
// if not debugging everything and not debugging specific category, LogPrint does nothing.
254-
if (setCategories.count(string("")) == 0 &&
255-
setCategories.count(string("1")) == 0 &&
256-
setCategories.count(string(category)) == 0)
254+
if (setCategories.count(std::string("")) == 0 &&
255+
setCategories.count(std::string("1")) == 0 &&
256+
setCategories.count(std::string(category)) == 0)
257257
return false;
258258
}
259259
return true;
@@ -266,7 +266,7 @@ bool LogAcceptCategory(const char* category)
266266
*/
267267
static std::string LogTimestampStr(const std::string &str, std::atomic_bool *fStartedNewLine)
268268
{
269-
string strStamped;
269+
std::string strStamped;
270270

271271
if (!fLogTimestamps)
272272
return str;
@@ -293,7 +293,7 @@ int LogPrintStr(const std::string &str)
293293
int ret = 0; // Returns total number of characters written
294294
static std::atomic_bool fStartedNewLine(true);
295295

296-
string strTimestamped = LogTimestampStr(str, &fStartedNewLine);
296+
std::string strTimestamped = LogTimestampStr(str, &fStartedNewLine);
297297

298298
if (fPrintToConsole)
299299
{
@@ -561,14 +561,14 @@ void ReadConfigFile(const std::string& confPath)
561561

562562
{
563563
LOCK(cs_args);
564-
set<string> setOptions;
564+
std::set<std::string> setOptions;
565565
setOptions.insert("*");
566566

567567
for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it)
568568
{
569569
// Don't overwrite existing settings so command line settings override bitcoin.conf
570-
string strKey = string("-") + it->string_key;
571-
string strValue = it->value[0];
570+
std::string strKey = std::string("-") + it->string_key;
571+
std::string strValue = it->value[0];
572572
InterpretNegativeSetting(strKey, strValue);
573573
if (mapArgs.count(strKey) == 0)
574574
mapArgs[strKey] = strValue;

src/utilmoneystr.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99
#include "tinyformat.h"
1010
#include "utilstrencodings.h"
1111

12-
using namespace std;
13-
1412
std::string FormatMoney(const CAmount& n)
1513
{
1614
// Note: not using straight sprintf here because we do NOT want
1715
// localized number formatting.
1816
int64_t n_abs = (n > 0 ? n : -n);
1917
int64_t quotient = n_abs/COIN;
2018
int64_t remainder = n_abs%COIN;
21-
string str = strprintf("%d.%08d", quotient, remainder);
19+
std::string str = strprintf("%d.%08d", quotient, remainder);
2220

2321
// Right-trim excess zeros before the decimal point:
2422
int nTrim = 0;
@@ -33,14 +31,14 @@ std::string FormatMoney(const CAmount& n)
3331
}
3432

3533

36-
bool ParseMoney(const string& str, CAmount& nRet)
34+
bool ParseMoney(const std::string& str, CAmount& nRet)
3735
{
3836
return ParseMoney(str.c_str(), nRet);
3937
}
4038

4139
bool ParseMoney(const char* pszIn, CAmount& nRet)
4240
{
43-
string strWhole;
41+
std::string strWhole;
4442
int64_t nUnits = 0;
4543
const char* p = pszIn;
4644
while (isspace(*p))

src/utilstrencodings.cpp

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,18 @@
1212
#include <errno.h>
1313
#include <limits>
1414

15-
using namespace std;
15+
static const std::string CHARS_ALPHA_NUM = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
1616

17-
static const string CHARS_ALPHA_NUM = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
18-
19-
static const string SAFE_CHARS[] =
17+
static const std::string SAFE_CHARS[] =
2018
{
2119
CHARS_ALPHA_NUM + " .,;-_/:?@()", // SAFE_CHARS_DEFAULT
2220
CHARS_ALPHA_NUM + " .,;-_?@", // SAFE_CHARS_UA_COMMENT
2321
CHARS_ALPHA_NUM + ".-_", // SAFE_CHARS_FILENAME
2422
};
2523

26-
string SanitizeString(const string& str, int rule)
24+
std::string SanitizeString(const std::string& str, int rule)
2725
{
28-
string strResult;
26+
std::string strResult;
2927
for (std::string::size_type i = 0; i < str.size(); i++)
3028
{
3129
if (SAFE_CHARS[rule].find(str[i]) != std::string::npos)
@@ -57,7 +55,7 @@ signed char HexDigit(char c)
5755
return p_util_hexdigit[(unsigned char)c];
5856
}
5957

60-
bool IsHex(const string& str)
58+
bool IsHex(const std::string& str)
6159
{
6260
for(std::string::const_iterator it(str.begin()); it != str.end(); ++it)
6361
{
@@ -67,10 +65,10 @@ bool IsHex(const string& str)
6765
return (str.size() > 0) && (str.size()%2 == 0);
6866
}
6967

70-
vector<unsigned char> ParseHex(const char* psz)
68+
std::vector<unsigned char> ParseHex(const char* psz)
7169
{
7270
// convert hex dump to vector
73-
vector<unsigned char> vch;
71+
std::vector<unsigned char> vch;
7472
while (true)
7573
{
7674
while (isspace(*psz))
@@ -88,16 +86,16 @@ vector<unsigned char> ParseHex(const char* psz)
8886
return vch;
8987
}
9088

91-
vector<unsigned char> ParseHex(const string& str)
89+
std::vector<unsigned char> ParseHex(const std::string& str)
9290
{
9391
return ParseHex(str.c_str());
9492
}
9593

96-
string EncodeBase64(const unsigned char* pch, size_t len)
94+
std::string EncodeBase64(const unsigned char* pch, size_t len)
9795
{
9896
static const char *pbase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
9997

100-
string strRet="";
98+
std::string strRet = "";
10199
strRet.reserve((len+2)/3*4);
102100

103101
int mode=0, left=0;
@@ -139,12 +137,12 @@ string EncodeBase64(const unsigned char* pch, size_t len)
139137
return strRet;
140138
}
141139

142-
string EncodeBase64(const string& str)
140+
std::string EncodeBase64(const std::string& str)
143141
{
144142
return EncodeBase64((const unsigned char*)str.c_str(), str.size());
145143
}
146144

147-
vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid)
145+
std::vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid)
148146
{
149147
static const int decode64_table[256] =
150148
{
@@ -166,7 +164,7 @@ vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid)
166164
if (pfInvalid)
167165
*pfInvalid = false;
168166

169-
vector<unsigned char> vchRet;
167+
std::vector<unsigned char> vchRet;
170168
vchRet.reserve(strlen(p)*3/4);
171169

172170
int mode = 0;
@@ -227,17 +225,17 @@ vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid)
227225
return vchRet;
228226
}
229227

230-
string DecodeBase64(const string& str)
228+
std::string DecodeBase64(const std::string& str)
231229
{
232-
vector<unsigned char> vchRet = DecodeBase64(str.c_str());
233-
return (vchRet.size() == 0) ? string() : string((const char*)&vchRet[0], vchRet.size());
230+
std::vector<unsigned char> vchRet = DecodeBase64(str.c_str());
231+
return (vchRet.size() == 0) ? std::string() : std::string((const char*)&vchRet[0], vchRet.size());
234232
}
235233

236-
string EncodeBase32(const unsigned char* pch, size_t len)
234+
std::string EncodeBase32(const unsigned char* pch, size_t len)
237235
{
238236
static const char *pbase32 = "abcdefghijklmnopqrstuvwxyz234567";
239237

240-
string strRet="";
238+
std::string strRet="";
241239
strRet.reserve((len+4)/5*8);
242240

243241
int mode=0, left=0;
@@ -292,12 +290,12 @@ string EncodeBase32(const unsigned char* pch, size_t len)
292290
return strRet;
293291
}
294292

295-
string EncodeBase32(const string& str)
293+
std::string EncodeBase32(const std::string& str)
296294
{
297295
return EncodeBase32((const unsigned char*)str.c_str(), str.size());
298296
}
299297

300-
vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid)
298+
std::vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid)
301299
{
302300
static const int decode32_table[256] =
303301
{
@@ -319,7 +317,7 @@ vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid)
319317
if (pfInvalid)
320318
*pfInvalid = false;
321319

322-
vector<unsigned char> vchRet;
320+
std::vector<unsigned char> vchRet;
323321
vchRet.reserve((strlen(p))*5/8);
324322

325323
int mode = 0;
@@ -414,10 +412,10 @@ vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid)
414412
return vchRet;
415413
}
416414

417-
string DecodeBase32(const string& str)
415+
std::string DecodeBase32(const std::string& str)
418416
{
419-
vector<unsigned char> vchRet = DecodeBase32(str.c_str());
420-
return (vchRet.size() == 0) ? string() : string((const char*)&vchRet[0], vchRet.size());
417+
std::vector<unsigned char> vchRet = DecodeBase32(str.c_str());
418+
return (vchRet.size() == 0) ? std::string() : std::string((const char*)&vchRet[0], vchRet.size());
421419
}
422420

423421
static bool ParsePrechecks(const std::string& str)

src/utiltime.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#include <boost/date_time/posix_time/posix_time.hpp>
1313
#include <boost/thread.hpp>
1414

15-
using namespace std;
16-
1715
static int64_t nMockTime = 0; //!< For unit testing
1816

1917
int64_t GetTime()

0 commit comments

Comments
 (0)