mirror of
https://github.com/xmrig/xmrig.git
synced 2026-02-01 09:43:03 -05:00
Improved JSON config error reporting
Show incorrect lines in config.json together with line number and position.
This commit is contained in:
@@ -191,6 +191,37 @@ rapidjson::Value xmrig::Json::normalize(double value, bool zero)
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Json::convertOffset(std::ifstream& ifs, size_t offset, size_t& line, size_t& pos, std::vector<std::string>& s)
|
||||
{
|
||||
std::string prev_t;
|
||||
std::string t;
|
||||
line = 0;
|
||||
pos = 0;
|
||||
size_t k = 0;
|
||||
|
||||
while (!ifs.eof()) {
|
||||
prev_t = t;
|
||||
std::getline(ifs, t);
|
||||
k += t.length() + 1;
|
||||
++line;
|
||||
|
||||
if (k > offset) {
|
||||
pos = offset + t.length() + 1 - k + 1;
|
||||
|
||||
s.clear();
|
||||
if (!prev_t.empty()) {
|
||||
s.emplace_back(prev_t);
|
||||
}
|
||||
s.emplace_back(t);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::JsonReader::isEmpty() const
|
||||
{
|
||||
return Json::isEmpty(m_obj);
|
||||
|
||||
Reference in New Issue
Block a user