From d2122aff38231e2134e77d07d6904d4caed0a2f3 Mon Sep 17 00:00:00 2001 From: Emmanuel Benoit Date: Mon, 30 Apr 2018 09:10:39 +0200 Subject: [PATCH] Buffers - append() method --- include/ebcl/Buffers.hh | 1 + include/ebcl/inline/Buffers.hh | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/ebcl/Buffers.hh b/include/ebcl/Buffers.hh index ae388d6..bb3229f 100644 --- a/include/ebcl/Buffers.hh +++ b/include/ebcl/Buffers.hh @@ -98,6 +98,7 @@ class T_Buffer : public T_BufferBase MyType_& resize( size_t newSize ); MyType_& setAll( T const& value ); MyType_& copyAll( T const* data ); + MyType_& append( T const* data , size_t size ); }; diff --git a/include/ebcl/inline/Buffers.hh b/include/ebcl/inline/Buffers.hh index bb58030..6aa0ee8 100644 --- a/include/ebcl/inline/Buffers.hh +++ b/include/ebcl/inline/Buffers.hh @@ -260,6 +260,20 @@ inline T_Buffer< T >& T_Buffer< T >::copyAll( T const* data ) return *this; } +template< typename T > +inline T_Buffer< T >& T_Buffer< T >::append( + T const* data , + size_t size ) +{ + if ( size != 0 ) { + const auto os{ size_ }; + resize( os + size ); + memcpy( data_ + os * sizeof( T ) , + data , size * sizeof( T ) ); + } + return *this; +} + } // namespace #endif // _H_EBCL_INLINE_BUFFERS