#define __DALI_VECTOR_H__
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// EXTERNAL INCLUDES
#include <cstddef>
#include <algorithm>
+#include <cstdint> // uint32_t
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
* beginning of the first real item so that iterating the items is quick.
* @SINCE_1_0.0
*/
-class DALI_IMPORT_API VectorBase
+class DALI_CORE_API VectorBase
{
public: // Typedefs
private:
- // not copiable as it does not know the size of elements
+ // not copyable as it does not know the size of elements
VectorBase( const VectorBase& ); ///< Undefined @SINCE_1_0.0
VectorBase& operator=( const VectorBase& ); ///< Undefined @SINCE_1_0.0
* @param[in] address Address to erase from
* @param[in] elementSize Size to erase
*/
- void Erase( char* address, SizeType elementSize )
+ void Erase( uint8_t* address, SizeType elementSize )
{
- VectorBase::Erase( address, elementSize );
+ VectorBase::Erase( reinterpret_cast< char* >( address ), elementSize );
}
/**
* @param[in] elementSize Size of one of the elements to be erased
* @return Address pointing to the next element of the last one
*/
- char* Erase( char* first, char* last, SizeType elementSize )
+ uint8_t* Erase( uint8_t* first, uint8_t* last, SizeType elementSize )
{
- return VectorBase::Erase( first, last, elementSize );
+ return reinterpret_cast< uint8_t* >( VectorBase::Erase( reinterpret_cast< char* >( first ), reinterpret_cast< char *>( last ), elementSize ) );
}
/**
* @param[in] to Address to the last element to be inserted
* @param[in] elementSize Size of one of the elements to be inserted
*/
- void Insert( char* at, char* from, char* to, SizeType elementSize )
+ void Insert( uint8_t* at, uint8_t* from, uint8_t* to, SizeType elementSize )
{
const SizeType size = to - from;
const SizeType count = Count();
if( newCount > Capacity() )
{
// Calculate the at offset as the pointer is invalid after the Reserve() call.
- std::size_t offset = at - reinterpret_cast<char*>( mData );
+ std::size_t offset = at - reinterpret_cast<uint8_t*>( mData );
// need more space
- Reserve( NextPowerOfTwo( newCount ), elementSize ); // reserve enough space to store at least the next power of two elements of the new required size.
+ Reserve( NextPowerOfTwo( static_cast<uint32_t>( newCount ) ), elementSize ); // reserve enough space to store at least the next power of two elements of the new required size.
// Set the new at pointer.
- at = reinterpret_cast<char*>( mData ) + offset;
+ at = reinterpret_cast<uint8_t*>( mData ) + offset;
}
// set new count first as otherwise the debug assert will hit us
SetCount( newCount );
// Move current items to a new position inside the vector.
- CopyMemory( at + size,
- at,
- ( reinterpret_cast<char*>( mData ) + count * elementSize ) - at );
+ CopyMemory( reinterpret_cast< char* >( at + size ),
+ reinterpret_cast< const char* >( at ),
+ ( reinterpret_cast<uint8_t*>( mData ) + count * elementSize ) - at );
// Copy the given items.
- CopyMemory( at, from, size );
+ CopyMemory( reinterpret_cast< char* >( at ), reinterpret_cast< const char* >( from ), size );
}
};
{
DALI_ASSERT_VECTOR( ( at <= End() ) && ( at >= Begin() ) && "Iterator not inside vector" );
const SizeType size = sizeof( ItemType );
- char* address = const_cast<char*>( reinterpret_cast<const char*>( &element ) );
- VectorAlgorithms<BaseType>::Insert( reinterpret_cast< char* >( at ),
+ uint8_t* address = const_cast<uint8_t*>( reinterpret_cast<const uint8_t*>( &element ) );
+ VectorAlgorithms<BaseType>::Insert( reinterpret_cast< uint8_t* >( at ),
address,
address + size,
size );
return;
}
- VectorAlgorithms<BaseType>::Insert( reinterpret_cast< char* >( at ),
- reinterpret_cast< char* >( from ),
- reinterpret_cast< char* >( to ),
+ VectorAlgorithms<BaseType>::Insert( reinterpret_cast< uint8_t* >( at ),
+ reinterpret_cast< uint8_t* >( from ),
+ reinterpret_cast< uint8_t* >( to ),
sizeof( ItemType ) );
}
DALI_ASSERT_VECTOR( (iterator < End()) && (iterator >= Begin()) && "Iterator not inside vector" );
if( iterator < ( End() - 1u ) )
{
- VectorAlgorithms<BaseType>::Erase( reinterpret_cast< char* >( iterator ), sizeof( ItemType ) );
+ VectorAlgorithms<BaseType>::Erase( reinterpret_cast< uint8_t* >( iterator ), sizeof( ItemType ) );
}
else
{
}
else
{
- nextElement = reinterpret_cast<Iterator>( VectorAlgorithms<BaseType>::Erase( reinterpret_cast< char* >( first ),
- reinterpret_cast< char* >( last ),
+ nextElement = reinterpret_cast<Iterator>( VectorAlgorithms<BaseType>::Erase( reinterpret_cast< uint8_t* >( first ),
+ reinterpret_cast< uint8_t* >( last ),
sizeof( ItemType ) ) );
}