Sync changes.

This commit is contained in:
XMRig 2019-03-01 22:59:34 +07:00
parent a261fe8c75
commit bde77ebab4
3 changed files with 53 additions and 1 deletions

View file

@ -47,3 +47,47 @@ const char *xmrig::Json::getString(const rapidjson::Value &obj, const char *key,
return defaultValue; return defaultValue;
} }
int xmrig::Json::getInt(const rapidjson::Value &obj, const char *key, int defaultValue)
{
auto i = obj.FindMember(key);
if (i != obj.MemberEnd() && i->value.IsInt()) {
return i->value.GetInt();
}
return defaultValue;
}
int64_t xmrig::Json::getInt64(const rapidjson::Value &obj, const char *key, int64_t defaultValue)
{
auto i = obj.FindMember(key);
if (i != obj.MemberEnd() && i->value.IsInt64()) {
return i->value.GetInt64();
}
return defaultValue;
}
uint64_t xmrig::Json::getUint64(const rapidjson::Value &obj, const char *key, uint64_t defaultValue)
{
auto i = obj.FindMember(key);
if (i != obj.MemberEnd() && i->value.IsUint64()) {
return i->value.GetUint64();
}
return defaultValue;
}
unsigned xmrig::Json::getUint(const rapidjson::Value &obj, const char *key, unsigned defaultValue)
{
auto i = obj.FindMember(key);
if (i != obj.MemberEnd() && i->value.IsUint()) {
return i->value.GetUint();
}
return defaultValue;
}

View file

@ -37,6 +37,10 @@ class Json
public: public:
static bool getBool(const rapidjson::Value &obj, const char *key, bool defaultValue = false); static bool getBool(const rapidjson::Value &obj, const char *key, bool defaultValue = false);
static const char *getString(const rapidjson::Value &obj, const char *key, const char *defaultValue = nullptr); static const char *getString(const rapidjson::Value &obj, const char *key, const char *defaultValue = nullptr);
static int getInt(const rapidjson::Value &obj, const char *key, int defaultValue = 0);
static int64_t getInt64(const rapidjson::Value &obj, const char *key, int64_t defaultValue = 0);
static uint64_t getUint64(const rapidjson::Value &obj, const char *key, uint64_t defaultValue = 0);
static unsigned getUint(const rapidjson::Value &obj, const char *key, unsigned defaultValue = 0);
static bool get(const char *fileName, rapidjson::Document &doc); static bool get(const char *fileName, rapidjson::Document &doc);
static bool save(const char *fileName, const rapidjson::Document &doc); static bool save(const char *fileName, const rapidjson::Document &doc);

View file

@ -45,6 +45,8 @@
#endif #endif
namespace xmrig {
static const char *kEnabled = "enabled"; static const char *kEnabled = "enabled";
static const char *kFingerprint = "tls-fingerprint"; static const char *kFingerprint = "tls-fingerprint";
static const char *kKeepalive = "keepalive"; static const char *kKeepalive = "keepalive";
@ -56,6 +58,8 @@ static const char *kUrl = "url";
static const char *kUser = "user"; static const char *kUser = "user";
static const char *kVariant = "variant"; static const char *kVariant = "variant";
}
xmrig::Pool::Pool() : xmrig::Pool::Pool() :
m_enabled(true), m_enabled(true),