Moved readJSONStrictly to a client cpp to avoid duplicate definitions at link time.

This commit is contained in:
Stephen Atherton 2018-09-10 14:35:04 -07:00
parent 8ed8f290c4
commit 02d7b02036
2 changed files with 26 additions and 23 deletions

View File

@ -26,29 +26,7 @@
// Reads the entire string s as a JSON value
// Throws if no value can be parsed or if s contains data after the first JSON value
// Trailing whitespace in s is allowed
json_spirit::mValue readJSONStrictly(const std::string s) {
json_spirit::mValue val;
std::string::const_iterator i = s.begin();
if(!json_spirit::read_range(i, s.end(), val)) {
if(g_network->isSimulated()) {
printf("MALFORMED: %s\n", s.c_str());
}
throw json_malformed();
}
// Allow trailing whitespace
while(i != s.end()) {
if(!isspace(*i)) {
if(g_network->isSimulated()) {
printf("EXPECTED EOF: %s\n^^^\n%s\n", std::string(s.begin(), i).c_str(), std::string(i, s.end()).c_str());
}
throw json_eof_expected();
}
++i;
}
return val;
}
json_spirit::mValue readJSONStrictly(const std::string &s);
struct StatusObject : json_spirit::mObject {
typedef json_spirit::mObject Map;

View File

@ -26,8 +26,33 @@
#include "StatusClient.h"
#include "Status.h"
#include "json_spirit/json_spirit_writer_template.h"
#include "json_spirit/json_spirit_reader_template.h"
#include "fdbrpc/genericactors.actor.h"
json_spirit::mValue readJSONStrictly(const std::string &s) {
json_spirit::mValue val;
std::string::const_iterator i = s.begin();
if(!json_spirit::read_range(i, s.end(), val)) {
if(g_network->isSimulated()) {
printf("MALFORMED: %s\n", s.c_str());
}
throw json_malformed();
}
// Allow trailing whitespace
while(i != s.end()) {
if(!isspace(*i)) {
if(g_network->isSimulated()) {
printf("EXPECTED EOF: %s\n^^^\n%s\n", std::string(s.begin(), i).c_str(), std::string(i, s.end()).c_str());
}
throw json_eof_expected();
}
++i;
}
return val;
}
uint64_t JSONDoc::expires_reference_version = std::numeric_limits<uint64_t>::max();
// Template specializations for mergeOperator