6#include <boost/core/demangle.hpp>
9namespace sysio {
namespace chain {
14 static const uint32_t current_snapshot_version = 1;
20 return boost::core::demangle(
typeid(
T).
name());
51 auto&
write(
const char* d,
size_t s ) {
63 auto&
seekp(std::ostream::pos_type
p) {
83 template<
typename DataStream>
103 return boost::core::demangle(
typeid(
T ).
name() );
142 template<
typename T,
typename F>
159 virtual void provide(std::istream& in)
const = 0;
166 static constexpr bool value =
false;
169 template<u
int16_t TypeNumber,
typename Derived>
178 template<
typename T,
typename F>
179 static auto apply(
const T& data, F
f) -> std::enable_if_t<is_chainbase_object_v<T>> {
182 SYS_ASSERT(orig == data.id, snapshot_exception,
183 "Snapshot for ${type} mutates row member \"id\" which is illegal",
184 (
"type",boost::core::demangle(
typeid(
T ).name() )));
187 template<
typename T,
typename F>
188 static auto apply(
const T&, F
f) -> std::enable_if_t<!is_chainbase_object_v<T>> {
199 void provide(std::istream& in)
const override {
212 return boost::core::demangle(
typeid(
T ).
name() );
243 bool result = _reader.
read_row(reader);
249 return _reader.
empty();
270 template<
typename T,
typename F>
307 std::string current_section_name;
316 bool has_section(
const string& section_name )
override;
317 void set_section(
const string& section_name )
override;
319 bool empty ( )
override;
342 std::streampos header_pos;
343 std::streampos section_pos;
353 bool has_section(
const string& section_name )
override;
354 void set_section(
const string& section_name )
override;
356 bool empty ( )
override;
361 bool validate_section()
const;
363 std::istream& snapshot;
364 std::streampos header_pos;
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
An order-preserving dictionary of variants.
An order-preserving dictionary of variants.
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
void write_end_section() override
void write_row(const detail::abstract_snapshot_row_writer &row_writer) override
integrity_hash_snapshot_writer(fc::sha256::encoder &enc)
void write_start_section(const std::string §ion_name) override
void clear_section() override
void set_section(const string §ion_name) override
istream_snapshot_reader(std::istream &snapshot)
bool read_row(detail::abstract_snapshot_row_reader &row_reader) override
void validate() const override
void return_to_header() override
bool has_section(const string §ion_name) override
static const uint32_t magic_number
void write_row(const detail::abstract_snapshot_row_writer &row_writer) override
void write_end_section() override
void write_start_section(const std::string §ion_name) override
ostream_snapshot_writer(std::ostream &snapshot)
auto read_row(T &out, chainbase::database &) -> std::enable_if_t< std::is_same< std::decay_t< T >, typename detail::snapshot_row_traits< T >::snapshot_type >::value, bool >
auto read_row(T &out, chainbase::database &db) -> std::enable_if_t<!std::is_same< std::decay_t< T >, typename detail::snapshot_row_traits< T >::snapshot_type >::value, bool >
auto read_row(T &out) -> std::enable_if_t< std::is_same< std::decay_t< T >, typename detail::snapshot_row_traits< T >::snapshot_type >::value, bool >
virtual ~snapshot_reader()
bool has_section(const std::string &suffix=std::string())
virtual void clear_section()=0
virtual bool has_section(const std::string §ion_name)=0
virtual void set_section(const std::string §ion_name)=0
virtual void validate() const =0
void read_section(const std::string §ion_name, F f)
virtual void return_to_header()=0
virtual bool read_row(detail::abstract_snapshot_row_reader &row_reader)=0
void add_row(const T &row, const chainbase::database &db)
virtual void write_start_section(const std::string §ion_name)=0
virtual void write_end_section()=0
void write_section(const std::string section_name, F f)
virtual void write_row(const detail::abstract_snapshot_row_writer &row_writer)=0
virtual ~snapshot_writer()
void clear_section() override
bool has_section(const string §ion_name) override
void return_to_header() override
void set_section(const string §ion_name) override
void validate() const override
variant_snapshot_reader(const fc::variant &snapshot)
bool read_row(detail::abstract_snapshot_row_reader &row_reader) override
void write_start_section(const std::string §ion_name) override
void write_row(const detail::abstract_snapshot_row_writer &row_writer) override
void write_end_section() override
variant_snapshot_writer(fc::mutable_variant_object &snapshot)
void unpack(Stream &s, std::deque< T > &value)
void pack(Stream &s, const std::deque< T > &value)
std::vector< fc::variant > variants
void from_variant(const fc::variant &v, sysio::chain::chain_id_type &cid)
void to_variant(const sysio::chain::shared_public_key &var, fc::variant &vo)
snapshot_row_reader< T > make_row_reader(T &data)
snapshot_row_writer< T > make_row_writer(const T &data)
constexpr bool is_chainbase_object_v
std::shared_ptr< snapshot_writer > snapshot_writer_ptr
std::shared_ptr< snapshot_reader > snapshot_reader_ptr
#define T(meth, val, expected)
unsigned __int64 uint64_t
virtual void provide(std::istream &in) const =0
virtual std::string row_type_name() const =0
virtual void provide(const fc::variant &) const =0
virtual void write(ostream_wrapper &out) const =0
virtual void write(fc::sha256::encoder &out) const =0
virtual fc::variant to_variant() const =0
virtual std::string row_type_name() const =0
static constexpr bool value
auto & write(const char *d, size_t s)
ostream_wrapper(ostream_wrapper &&)=default
ostream_wrapper(std::ostream &s)
ostream_wrapper(const ostream_wrapper &)=default
auto & seekp(std::ostream::pos_type p)
static auto apply(const T &, F f) -> std::enable_if_t<!is_chainbase_object_v< T > >
static auto apply(const T &data, F f) -> std::enable_if_t< is_chainbase_object_v< T > >
snapshot_row_reader(T &data)
std::string row_type_name() const override
void provide(const fc::variant &var) const override
void provide(std::istream &in) const override
static const snapshot_type & to_snapshot_row(const value_type &value, const chainbase::database &)
std::decay_t< T > value_type
void write(fc::sha256::encoder &out) const override
void write(ostream_wrapper &out) const override
std::string row_type_name() const override
void write_stream(DataStream &out) const
fc::variant to_variant() const override
snapshot_row_writer(const T &data)
static std::string section_name()
yh_object_descriptor object