5a42e15c4a
Squashed messages from 9 commits: 9. Properties now uses PropertyFamily and contained classes. Fetching,seting,clearing properties can be done with PropertyFamilyKey or PropertyTypeKey. Hierarchy of newly added clases is: Vertices -n-> PropertyFamily {name: String} <-1-n-> PropertyType {type: Property::Flags} Edges -n-> PropertyFamily {name: String} <-1-n-> PropertyType {type: Property::Flags} PropertyFamilyKey -> PropertyType PropertyTypeKey -> PropertyType PropertyType t0,t1; let t0!=t1 be true let t0.family==t1.family be true then next is true PropertyTypeKey{&t0}!=PropertyTypeKey{&t1} PropertyFamilyKey{&t0}==PropertyFamilyKey{&t1} PropertyFamilyKey{&t0}==PropertyTypeKey{&t1} PropertyTypeKey{&t0}==PropertyFamilyKey{&t1} 8. Intermedate commit. Noticed that integration queries throw SEGFAULT. 7. Defined interface for indexes. Fixed three memory leaks. Fixed integration_queries test which now passes. 6. Commit which return Xorshift128plus to valid shape. 5. Tmp commit. 4. Label Index is compiling. 3. tmp 2. Vertex::Accessor now updates Label index. 1. Applied changes for code review.
68 lines
1.4 KiB
C++
68 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "storage/model/properties/handler.hpp"
|
|
#include "storage/model/properties/properties.hpp"
|
|
|
|
template <class Buffer>
|
|
struct JsonWriter
|
|
{
|
|
public:
|
|
JsonWriter(Buffer &buffer) : buffer(buffer) { buffer << '{'; };
|
|
|
|
void handle(const prop_key_t &key, const Property &value)
|
|
{
|
|
if (!first) buffer << ',';
|
|
|
|
if (first) first = false;
|
|
|
|
buffer << '"' << key.family_name() << "\":";
|
|
// value.accept(*this);
|
|
accept(value, *this);
|
|
}
|
|
|
|
void handle(const Bool &b) { buffer << (b.value() ? "true" : "false"); }
|
|
|
|
void handle(const String &s) { buffer << '"' << s.value << '"'; }
|
|
|
|
void handle(const Int32 &int32) { buffer << std::to_string(int32.value); }
|
|
|
|
void handle(const Int64 &int64) { buffer << std::to_string(int64.value); }
|
|
|
|
void handle(const Float &f) { buffer << std::to_string(f.value); }
|
|
|
|
void handle(const Double &d) { buffer << std::to_string(d.value); }
|
|
|
|
void finish() { buffer << '}'; }
|
|
|
|
private:
|
|
bool first{true};
|
|
Buffer &buffer;
|
|
};
|
|
|
|
class StringBuffer
|
|
{
|
|
public:
|
|
StringBuffer &operator<<(const std::string &str)
|
|
{
|
|
data += str;
|
|
return *this;
|
|
}
|
|
|
|
StringBuffer &operator<<(const char *str)
|
|
{
|
|
data += str;
|
|
return *this;
|
|
}
|
|
|
|
StringBuffer &operator<<(char c)
|
|
{
|
|
data += c;
|
|
return *this;
|
|
}
|
|
|
|
std::string &str() { return data; }
|
|
|
|
private:
|
|
std::string data;
|
|
};
|