diff --git a/eo/src/serial/Serialize.h b/eo/src/serial/Serialize.h index f833f427a..fe3d21ab8 100644 --- a/eo/src/serial/Serialize.h +++ b/eo/src/serial/Serialize.h @@ -88,6 +88,7 @@ Authors: */ # include +# include # include # include // std::runtime_error # include // std::is_convertible (C++11) @@ -157,6 +158,7 @@ namespace eoserial MKSIMPLE(long) MKSIMPLE(float) MKSIMPLE(double) + MKSIMPLE(char) MKSIMPLE(std::string) # undef MKSIMPLE @@ -173,6 +175,7 @@ namespace eoserial DSSIMPLE(long); DSSIMPLE(float); DSSIMPLE(double); + DSSIMPLE(char); DSSIMPLE(std::string); # undef DSSIMPLE @@ -182,11 +185,11 @@ namespace eoserial value.unpack( static_cast( json ) ); } - template - eoserial::Entity* makeSimple( const std::vector & v ) + template + eoserial::Entity* makeSimpleIterable( const Container & c ) { eoserial::Array* array = new eoserial::Array; - for( auto it = v.begin(), end = v.end(); + for( auto it = c.begin(), end = c.end(); it != end; ++it ) { @@ -195,23 +198,47 @@ namespace eoserial return array; } + template + eoserial::Entity* makeSimple( const std::vector & v ) + { + return makeSimpleIterable( v ); + } + + template + eoserial::Entity* makeSimple( const std::list & l ) + { + return makeSimpleIterable( l ); + } + template void deserializeBase( const eoserial::Entity* json, T & value ); - template< class T > - void deserializeSimple( const eoserial::Entity* json, std::vector & v ) + template< class Container > + void deserializeSimplePushBack( const eoserial::Entity* json, Container & c ) { const eoserial::Array* sArray = static_cast(json); for( auto it = sArray->begin(), end = sArray->end(); it != end; ++it ) { - T single; + typename Container::value_type single; eoserial::deserializeBase( *it, single ); - v.push_back( single ); + c.push_back( single ); } } + template< class T > + void deserializeSimple( const eoserial::Entity* json, std::vector & v ) + { + deserializeSimplePushBack( json, v ); + } + + template< class T > + void deserializeSimple( const eoserial::Entity* json, std::list & v ) + { + deserializeSimplePushBack( json, v ); + } + template void deserializeBase( const eoserial::Entity* json, T & value ) {