55 lines
1.5 KiB
C++
55 lines
1.5 KiB
C++
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <fc/io/raw.hpp>
|
||
|
|
#include <fc/variant.hpp>
|
||
|
|
|
||
|
|
#include <boost/interprocess/allocators/allocator.hpp>
|
||
|
|
#include <boost/interprocess/containers/string.hpp>
|
||
|
|
#include <boost/interprocess/containers/vector.hpp>
|
||
|
|
#include <boost/interprocess/containers/map.hpp>
|
||
|
|
#include <boost/interprocess/containers/deque.hpp>
|
||
|
|
|
||
|
|
|
||
|
|
namespace fc {
|
||
|
|
|
||
|
|
namespace bip = boost::interprocess;
|
||
|
|
|
||
|
|
template<typename... T >
|
||
|
|
void to_variant( const bip::deque< T... >& t, fc::variant& v ) {
|
||
|
|
std::vector<variant> vars(t.size());
|
||
|
|
for( size_t i = 0; i < t.size(); ++i ) {
|
||
|
|
vars[i] = t[i];
|
||
|
|
}
|
||
|
|
v = std::move(vars);
|
||
|
|
}
|
||
|
|
|
||
|
|
template<typename T, typename... A>
|
||
|
|
void from_variant( const fc::variant& v, bip::deque< T, A... >& d ) {
|
||
|
|
const variants& vars = v.get_array();
|
||
|
|
d.clear();
|
||
|
|
d.resize( vars.size() );
|
||
|
|
for( uint32_t i = 0; i < vars.size(); ++i ) {
|
||
|
|
from_variant( vars[i], d[i] );
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
template<typename... T >
|
||
|
|
void to_variant( const bip::vector< T... >& t, fc::variant& v ) {
|
||
|
|
std::vector<variant> vars(t.size());
|
||
|
|
for( size_t i = 0; i < t.size(); ++i ) {
|
||
|
|
vars[i] = t[i];
|
||
|
|
}
|
||
|
|
v = std::move(vars);
|
||
|
|
}
|
||
|
|
|
||
|
|
template<typename T, typename... A>
|
||
|
|
void from_variant( const fc::variant& v, bip::vector< T, A... >& d ) {
|
||
|
|
const variants& vars = v.get_array();
|
||
|
|
d.clear();
|
||
|
|
d.resize( vars.size() );
|
||
|
|
for( uint32_t i = 0; i < vars.size(); ++i ) {
|
||
|
|
from_variant( vars[i], d[i] );
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|