diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-03-21 16:42:52 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-03-21 16:42:52 -0700 |
commit | e37eb0aa542ef8aee8532c5bfdde7f09ed343a28 (patch) | |
tree | c2900b4814847fb3249b41e7dcfe5ab6dbac9215 /ext/librethinkdbxx/src/json.cc | |
parent | 130fa35bb1707ea232015c1a3672f0585632dea1 (diff) | |
download | infinitytier-e37eb0aa542ef8aee8532c5bfdde7f09ed343a28.tar.gz infinitytier-e37eb0aa542ef8aee8532c5bfdde7f09ed343a28.zip |
More cleanup of old stuff no longer used.
Diffstat (limited to 'ext/librethinkdbxx/src/json.cc')
-rw-r--r-- | ext/librethinkdbxx/src/json.cc | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/ext/librethinkdbxx/src/json.cc b/ext/librethinkdbxx/src/json.cc deleted file mode 100644 index c908eefb..00000000 --- a/ext/librethinkdbxx/src/json.cc +++ /dev/null @@ -1,62 +0,0 @@ -#include "json_p.h" -#include "error.h" -#include "utils.h" - -#include "rapidjson-config.h" -#include "rapidjson/document.h" -#include "rapidjson/stringbuffer.h" -#include "rapidjson/writer.h" -#include "rapidjson/prettywriter.h" - -namespace RethinkDB { - -Datum read_datum(const std::string& json) { - rapidjson::Document document; - document.Parse(json); - return read_datum(document); -} - -Datum read_datum(const rapidjson::Value &json) { - switch(json.GetType()) { - case rapidjson::kNullType: return Nil(); - case rapidjson::kFalseType: return false; - case rapidjson::kTrueType: return true; - case rapidjson::kNumberType: return json.GetDouble(); - case rapidjson::kStringType: - return std::string(json.GetString(), json.GetStringLength()); - - case rapidjson::kObjectType: { - Object result; - for (rapidjson::Value::ConstMemberIterator it = json.MemberBegin(); - it != json.MemberEnd(); ++it) { - result.insert(std::make_pair(std::string(it->name.GetString(), - it->name.GetStringLength()), - read_datum(it->value))); - } - - if (result.count("$reql_type$")) - return Datum(std::move(result)).from_raw(); - return std::move(result); - } break; - case rapidjson::kArrayType: { - Array result; - result.reserve(json.Size()); - for (rapidjson::Value::ConstValueIterator it = json.Begin(); - it != json.End(); ++it) { - result.push_back(read_datum(*it)); - } - return std::move(result); - } break; - default: - throw Error("invalid rapidjson value"); - } -} - -std::string write_datum(const Datum& datum) { - rapidjson::StringBuffer buffer; - rapidjson::Writer<rapidjson::StringBuffer> writer(buffer); - datum.write_json(&writer); - return std::string(buffer.GetString(), buffer.GetSize()); -} - -} |