memgraph/include/import/fillings/id.hpp
Kruno Tomola Fabro 5d235b51f3 tmp commit
tmp commit

tmp commit v2

Finished reimplementation of propertys.
They now can be placed in a holder with different source of type information.

Tmp commit
2016-09-05 10:02:48 +01:00

43 lines
1.0 KiB
C++

#pragma once
#include "import/fillings/filler.hpp"
template <class TG>
class IdFiller : public Filler
{
public:
IdFiller()
: key(make_option<
typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey>())
{
}
IdFiller(
Option<typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey>
key)
: key(key)
{
assert(!key.is_present() ||
key.get().prop_type() == Type(Flags::Int64));
}
// Fills skeleton with data from str. Returns error description if
// error occurs.
Option<std::string> fill(ElementSkeleton &data, char *str) final
{
if (str[0] != '\0') {
data.set_element_id(atol(str));
if (key.is_present()) {
data.add_property(
StoredProperty<TG>(Int64(to_int64(str)), key.get()));
}
}
return make_option<std::string>();
}
private:
Option<typename PropertyFamily<TG>::PropertyType::PropertyFamilyKey> key;
};