5 #ifndef JODA_PATHJACCARD_H
6 #define JODA_PATHJACCARD_H
9 #include <rapidjson/istreamwrapper.h>
13 #include "../../../../src/RJPathsReader.h"
27 getPaths(lhs, prefix, paths);
28 std::sort(paths.begin(), paths.end());
34 rapidjson::Reader reader;
35 rapidjson::StringStream stream(lhs.c_str());
36 reader.Parse(stream, handler);
38 std::sort(paths.begin(), paths.end());
43 rapidjson::IStreamWrapper &lhs) {
45 rapidjson::Reader reader;
46 reader.Parse(lhs, handler);
52 inline static void getPaths(
const T &doc, std::string &prefix,
53 std::vector<std::string> &set) {
55 for (
const auto &m : doc.GetObject()) {
56 std::string path = prefix +
"/" + m.name.GetString();
57 set.emplace_back(path);
58 if (m.value.IsObject() || m.value.IsArray()) {
59 getPaths(m.value, path, set);
62 }
else if (doc.IsArray()) {
64 for (
const auto &item : doc.GetArray()) {
65 std::string path = prefix +
"/" + std::to_string(i);
67 if (item.IsObject() || item.IsArray()) {
68 getPaths(item, path, set);
rapidjson::GenericDocument< RJChar, RJMemoryPoolAlloc, RJBaseAlloc > RJDocument
Definition: RJFwd.h:28
#define JODA_DEFAULT_PATH_DEPTH
Definition: RJPathsReader.h:11
Definition: IJSONSimilarityMeasure.h:24
Definition: PathJaccard.h:79
double measure(const RJDocument &lhs, const RJDocument &rhs) override
Definition: PathJaccard.cpp:8
Definition: RJPathsReader.h:14
const std::vector< std::string > & getPaths() const
Definition: RJPathsReader.cpp:114
void clear()
Definition: RJPathsReader.cpp:134
std::vector< std::string > Representation
Definition: PathJaccard.h:21
const Representation getRepresentation(const RJDocument &lhs) const
Definition: PathJaccard.h:23
const Representation getRepresentation(rapidjson::IStreamWrapper &lhs)
Definition: PathJaccard.h:42
RJPathsReader handler
Definition: PathJaccard.h:20
const Representation getRepresentation(const std::string &lhs)
Definition: PathJaccard.h:32
static void getPaths(const T &doc, std::string &prefix, std::vector< std::string > &set)
Definition: PathJaccard.h:52
Definition: IJSONSimilarityMeasure.h:36
bool is_implemented
Definition: IJSONSimilarityMeasure.h:56