Loading src/TNL/Containers/Array.hpp +4 −6 Original line number Diff line number Diff line Loading @@ -579,7 +579,7 @@ operator<<( File& file, const Array< Value, Device, Index, Allocator >& array ) { using IO = detail::ArrayIO< Value, Index, Allocator >; saveObjectType( file, IO::getSerializationType() ); const Index size = array.getSize(); const std::size_t size = array.getSize(); file.save( &size ); IO::save( file, array.getData(), array.getSize() ); return file; Loading @@ -603,11 +603,9 @@ operator>>( File& file, Array< Value, Device, Index, Allocator >& array ) if( type != IO::getSerializationType() ) throw Exceptions::FileDeserializationError( file.getFileName(), "object type does not match (expected " + IO::getSerializationType() + ", found " + type + ")." ); Index _size; file.load( &_size ); if( _size < 0 ) throw Exceptions::FileDeserializationError( file.getFileName(), "invalid array size: " + std::to_string( _size ) ); array.setSize( _size ); std::size_t size; file.load( &size ); array.setSize( size ); IO::load( file, array.getData(), array.getSize() ); return file; } Loading src/TNL/Containers/ArrayView.hpp +5 −5 Original line number Diff line number Diff line Loading @@ -355,7 +355,7 @@ operator<<( File& file, const ArrayView< Value, Device, Index > view ) { using IO = detail::ArrayIO< Value, Index, typename Allocators::Default< Device >::template Allocator< Value > >; saveObjectType( file, IO::getSerializationType() ); const Index size = view.getSize(); const std::size_t size = view.getSize(); file.save( &size ); IO::save( file, view.getData(), view.getSize() ); return file; Loading @@ -379,11 +379,11 @@ operator>>( File& file, ArrayView< Value, Device, Index > view ) if( type != IO::getSerializationType() ) throw Exceptions::FileDeserializationError( file.getFileName(), "object type does not match (expected " + IO::getSerializationType() + ", found " + type + ")." ); Index _size; file.load( &_size ); if( _size != view.getSize() ) std::size_t size; file.load( &size ); if( size != static_cast< std::size_t >( view.getSize() ) ) throw Exceptions::FileDeserializationError( file.getFileName(), "invalid array size: " + std::to_string( _size ) + " (expected " "invalid array size: " + std::to_string( size ) + " (expected " + std::to_string( view.getSize() ) + ")." ); IO::load( file, view.getData(), view.getSize() ); return file; Loading src/TNL/Containers/detail/ArrayIO.h +2 −4 Original line number Diff line number Diff line Loading @@ -26,8 +26,7 @@ struct ArrayIO< Value, Index, Allocator, true > static std::string getSerializationType() { return "Containers::Array< " + TNL::getSerializationType< Value >() + ", [any_device], " + TNL::getSerializationType< Index >() + ", [any_allocator] >"; return "TNL::Containers::Array< " + TNL::getSerializationType< Value >() + " >"; } static void Loading Loading @@ -92,8 +91,7 @@ struct ArrayIO< Value, Index, Allocator, false > static std::string getSerializationType() { return "Containers::Array< " + TNL::getSerializationType< Value >() + ", [any_device], " + TNL::getSerializationType< Index >() + ", [any_allocator] >"; return "TNL::Containers::Array< " + TNL::getSerializationType< Value >() + " >"; } template< typename TargetValue = Value > Loading src/UnitTests/Containers/ArrayTest.h +2 −2 Original line number Diff line number Diff line Loading @@ -676,9 +676,9 @@ TYPED_TEST( ArrayTest, SaveAndLoadSubrangeWithCast ) const std::string type = getObjectType( file ); ASSERT_EQ( type, ArrayType::getSerializationType() ); // read size Index elementsInFile; std::size_t elementsInFile; file.load( &elementsInFile ); EXPECT_EQ( elementsInFile, v.getSize() ); EXPECT_EQ( elementsInFile, static_cast< std::size_t >( v.getSize() ) ); // read data, cast from Value to short int using IO = ArrayIO< CastValue, Index, typename Allocators::Default< typename ArrayType::DeviceType >::template Allocator< CastValue > >; // hack for the test... Loading Loading
src/TNL/Containers/Array.hpp +4 −6 Original line number Diff line number Diff line Loading @@ -579,7 +579,7 @@ operator<<( File& file, const Array< Value, Device, Index, Allocator >& array ) { using IO = detail::ArrayIO< Value, Index, Allocator >; saveObjectType( file, IO::getSerializationType() ); const Index size = array.getSize(); const std::size_t size = array.getSize(); file.save( &size ); IO::save( file, array.getData(), array.getSize() ); return file; Loading @@ -603,11 +603,9 @@ operator>>( File& file, Array< Value, Device, Index, Allocator >& array ) if( type != IO::getSerializationType() ) throw Exceptions::FileDeserializationError( file.getFileName(), "object type does not match (expected " + IO::getSerializationType() + ", found " + type + ")." ); Index _size; file.load( &_size ); if( _size < 0 ) throw Exceptions::FileDeserializationError( file.getFileName(), "invalid array size: " + std::to_string( _size ) ); array.setSize( _size ); std::size_t size; file.load( &size ); array.setSize( size ); IO::load( file, array.getData(), array.getSize() ); return file; } Loading
src/TNL/Containers/ArrayView.hpp +5 −5 Original line number Diff line number Diff line Loading @@ -355,7 +355,7 @@ operator<<( File& file, const ArrayView< Value, Device, Index > view ) { using IO = detail::ArrayIO< Value, Index, typename Allocators::Default< Device >::template Allocator< Value > >; saveObjectType( file, IO::getSerializationType() ); const Index size = view.getSize(); const std::size_t size = view.getSize(); file.save( &size ); IO::save( file, view.getData(), view.getSize() ); return file; Loading @@ -379,11 +379,11 @@ operator>>( File& file, ArrayView< Value, Device, Index > view ) if( type != IO::getSerializationType() ) throw Exceptions::FileDeserializationError( file.getFileName(), "object type does not match (expected " + IO::getSerializationType() + ", found " + type + ")." ); Index _size; file.load( &_size ); if( _size != view.getSize() ) std::size_t size; file.load( &size ); if( size != static_cast< std::size_t >( view.getSize() ) ) throw Exceptions::FileDeserializationError( file.getFileName(), "invalid array size: " + std::to_string( _size ) + " (expected " "invalid array size: " + std::to_string( size ) + " (expected " + std::to_string( view.getSize() ) + ")." ); IO::load( file, view.getData(), view.getSize() ); return file; Loading
src/TNL/Containers/detail/ArrayIO.h +2 −4 Original line number Diff line number Diff line Loading @@ -26,8 +26,7 @@ struct ArrayIO< Value, Index, Allocator, true > static std::string getSerializationType() { return "Containers::Array< " + TNL::getSerializationType< Value >() + ", [any_device], " + TNL::getSerializationType< Index >() + ", [any_allocator] >"; return "TNL::Containers::Array< " + TNL::getSerializationType< Value >() + " >"; } static void Loading Loading @@ -92,8 +91,7 @@ struct ArrayIO< Value, Index, Allocator, false > static std::string getSerializationType() { return "Containers::Array< " + TNL::getSerializationType< Value >() + ", [any_device], " + TNL::getSerializationType< Index >() + ", [any_allocator] >"; return "TNL::Containers::Array< " + TNL::getSerializationType< Value >() + " >"; } template< typename TargetValue = Value > Loading
src/UnitTests/Containers/ArrayTest.h +2 −2 Original line number Diff line number Diff line Loading @@ -676,9 +676,9 @@ TYPED_TEST( ArrayTest, SaveAndLoadSubrangeWithCast ) const std::string type = getObjectType( file ); ASSERT_EQ( type, ArrayType::getSerializationType() ); // read size Index elementsInFile; std::size_t elementsInFile; file.load( &elementsInFile ); EXPECT_EQ( elementsInFile, v.getSize() ); EXPECT_EQ( elementsInFile, static_cast< std::size_t >( v.getSize() ) ); // read data, cast from Value to short int using IO = ArrayIO< CastValue, Index, typename Allocators::Default< typename ArrayType::DeviceType >::template Allocator< CastValue > >; // hack for the test... Loading