Skip to content

Commit bf1418c

Browse files
MapleMaple
authored andcommitted
named constants moved into class
1 parent 702eee8 commit bf1418c

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

include/bfx-api-cpp/BitfinexAPI.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,20 @@ using CryptoPP::byte;
6868

6969
namespace BfxAPI
7070
{
71-
////////////////////////////////////////////////////////////////////////
72-
// Global variables
73-
////////////////////////////////////////////////////////////////////////
74-
75-
const auto API_URL = "https://api.bitfinex.com/v1";
76-
const auto CURL_TIMEOUT = 30L;
77-
const auto CURL_DEBUG_VERBOSE = 0L;
78-
const auto WITHDRAWAL_CONF_FILE_PATH = "doc/withdraw.conf";
79-
8071

8172
class BitfinexAPI
8273
{
8374
public:
8475

76+
////////////////////////////////////////////////////////////////////////
77+
// Class constants
78+
////////////////////////////////////////////////////////////////////////
79+
80+
static constexpr auto API_URL = "https://api.bitfinex.com/v1";
81+
static constexpr auto CURL_TIMEOUT = 30L;
82+
static constexpr auto CURL_DEBUG_VERBOSE = 0L;
83+
static constexpr auto WITHDRAWAL_CONF_FILE_PATH = "doc/withdraw.conf";
84+
8585
////////////////////////////////////////////////////////////////////////
8686
// Typedefs
8787
////////////////////////////////////////////////////////////////////////
@@ -199,7 +199,7 @@ namespace BfxAPI
199199
const string getWDconfFilePath() const noexcept
200200
{ return WDconfFilePath_; }
201201

202-
const bfxERR& getBfxApiStatusCode() const noexcept
202+
const BfxClientErrors& getBfxApiStatusCode() const noexcept
203203
{ return bfxApiStatusCode_; }
204204

205205
const CURLcode& getCurlStatusCode() const noexcept
@@ -454,7 +454,7 @@ namespace BfxAPI
454454
getTonce() + "\"";
455455

456456
// Add params from withdraw.conf
457-
bfxERR code(parseWDconfParams(params));
457+
BfxClientErrors code(parseWDconfParams(params));
458458
if (code != noError)
459459
bfxApiStatusCode_ = code;
460460
else
@@ -925,14 +925,14 @@ namespace BfxAPI
925925
string APIurl_;
926926
string accessKey_, secretKey_;
927927
// dynamic and status variables
928-
bfxERR bfxApiStatusCode_;
928+
BfxClientErrors bfxApiStatusCode_;
929929
string result_;
930930

931931
////////////////////////////////////////////////////////////////////////
932932
// Utility private methods
933933
////////////////////////////////////////////////////////////////////////
934934

935-
bfxERR parseWDconfParams(string &params)
935+
BfxClientErrors parseWDconfParams(string &params)
936936
{
937937
using std::getline;
938938
using std::ifstream;

include/bfx-api-cpp/error.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#pragma once
99

10-
enum bfxERR
10+
enum BfxClientErrors
1111
{
1212
noError = 0,
1313
curlERR, // 1

include/bfx-api-cpp/jsonutils.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ namespace jsonutils
192192
cerr << "Invalid json - response:" << endl;
193193
cerr << inputJson << endl;
194194
cerr << "API endpoint: " << apiEndPoint << endl;
195-
return bfxERR::responseParseError;
195+
return BfxClientErrors::responseParseError;
196196
}
197197

198198
// Create rapidjson validator and check for schema errors
@@ -210,10 +210,10 @@ namespace jsonutils
210210
cerr << "Invalid document: " << sb.GetString() << endl;
211211
cerr << "Invalid response: " << inputJson << endl;
212212
cerr << "Invalid API endpoint: " << apiEndPoint << endl;
213-
return bfxERR::responseSchemaError;
213+
return BfxClientErrors::responseSchemaError;
214214
}
215215

216-
return bfxERR::noError;
216+
return BfxClientErrors::noError;
217217
}
218218

219219
private:
@@ -280,7 +280,7 @@ namespace jsonutils
280280
// Routines
281281
////////////////////////////////////////////////////////////////////////////
282282

283-
bfxERR jsonStrToUset(unordered_set<string> &uSet, const string &inputJson)
283+
BfxClientErrors jsonStrToUset(unordered_set<string> &uSet, const string &inputJson)
284284
{
285285
// Create schema $ref resolver
286286
rj::Document sd;
@@ -322,12 +322,12 @@ namespace jsonutils
322322
cerr << "Invalid document: " << sb.GetString() << endl;
323323
cerr << "Invalid response: " << inputJson << endl;
324324
}
325-
return bfxERR::jsonStrToUSetError;
325+
return BfxClientErrors::jsonStrToUSetError;
326326
}
327327
else
328328
{
329329
uSet.swap(handler.handlerUSet_);
330-
return bfxERR::noError;
330+
return BfxClientErrors::noError;
331331
}
332332
}
333333
}

0 commit comments

Comments
 (0)