Removed using namespace std from bitcoin-cli/-tx and added std:: in appropriate places.

This commit is contained in:
Karl-Johan Alm
2016-11-25 17:17:57 +09:00
committed by Jack Grigg
parent c06245c1e3
commit 3b26f5c361
2 changed files with 107 additions and 111 deletions

View File

@@ -19,14 +19,12 @@
#include <univalue.h>
using namespace std;
static const int DEFAULT_HTTP_CLIENT_TIMEOUT=900;
static const int CONTINUE_EXECUTION=-1;
std::string HelpMessageCli()
{
string strUsage;
std::string strUsage;
strUsage += HelpMessageGroup(_("Options:"));
strUsage += HelpMessageOpt("-?", _("This help message"));
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), "zcash.conf"));
@@ -183,7 +181,7 @@ static void http_error_cb(enum evhttp_request_error err, void *ctx)
}
#endif
UniValue CallRPC(const string& strMethod, const UniValue& params)
UniValue CallRPC(const std::string& strMethod, const UniValue& params)
{
std::string host = GetArg("-rpcconnect", "127.0.0.1");
int port = GetArg("-rpcport", BaseParams().RPCPort());
@@ -198,7 +196,7 @@ UniValue CallRPC(const string& strMethod, const UniValue& params)
HTTPReply response;
raii_evhttp_request req = obtain_evhttp_request(http_request_done, (void*)&response);
if (req == NULL)
throw runtime_error("create http request failed");
throw std::runtime_error("create http request failed");
#if LIBEVENT_VERSION_NUMBER >= 0x02010300
evhttp_request_set_error_cb(req.get(), http_error_cb);
#endif
@@ -208,7 +206,7 @@ UniValue CallRPC(const string& strMethod, const UniValue& params)
if (mapArgs["-rpcpassword"] == "") {
// Try fall back to cookie-based authentication if no password is provided
if (!GetAuthCookie(&strRPCUserColonPass)) {
throw runtime_error(strprintf(
throw std::runtime_error(strprintf(
_("Could not locate RPC credentials. No authentication cookie could be found,\n"
"and no rpcpassword is set in the configuration file (%s)."),
GetConfigFile().string().c_str()));
@@ -241,26 +239,26 @@ UniValue CallRPC(const string& strMethod, const UniValue& params)
if (response.status == 0)
throw CConnectionFailed(strprintf("couldn't connect to server: %s (code %d)\n(make sure server is running and you are connecting to the correct RPC port)", http_errorstring(response.error), response.error));
else if (response.status == HTTP_UNAUTHORIZED)
throw runtime_error("incorrect rpcuser or rpcpassword (authorization failed)");
throw std::runtime_error("incorrect rpcuser or rpcpassword (authorization failed)");
else if (response.status >= 400 && response.status != HTTP_BAD_REQUEST && response.status != HTTP_NOT_FOUND && response.status != HTTP_INTERNAL_SERVER_ERROR)
throw runtime_error(strprintf("server returned HTTP error %d", response.status));
throw std::runtime_error(strprintf("server returned HTTP error %d", response.status));
else if (response.body.empty())
throw runtime_error("no response from server");
throw std::runtime_error("no response from server");
// Parse reply
UniValue valReply(UniValue::VSTR);
if (!valReply.read(response.body))
throw runtime_error("couldn't parse reply from server");
throw std::runtime_error("couldn't parse reply from server");
const UniValue& reply = valReply.get_obj();
if (reply.empty())
throw runtime_error("expected reply to have result, error and id properties");
throw std::runtime_error("expected reply to have result, error and id properties");
return reply;
}
int CommandLineRPC(int argc, char *argv[])
{
string strPrint;
std::string strPrint;
int nRet = 0;
try {
// Skip switches
@@ -276,7 +274,7 @@ int CommandLineRPC(int argc, char *argv[])
args.push_back(line);
}
if (args.size() < 1)
throw runtime_error("too few parameters (need at least command)");
throw std::runtime_error("too few parameters (need at least command)");
std::string strMethod = args[0];
UniValue params = RPCConvertValues(strMethod, std::vector<std::string>(args.begin()+1, args.end()));
@@ -330,7 +328,7 @@ int CommandLineRPC(int argc, char *argv[])
throw;
}
catch (const std::exception& e) {
strPrint = string("error: ") + e.what();
strPrint = std::string("error: ") + e.what();
nRet = EXIT_FAILURE;
}
catch (...) {