Add internal tag to VectorAlgorithms
[platform/core/uifw/dali-core.git] / dali / public-api / common / dali-vector.h
index 8422677..98fae38 100755 (executable)
@@ -1,8 +1,8 @@
-#ifndef __DALI_VECTOR_H__
-#define __DALI_VECTOR_H__
+#ifndef DALI_VECTOR_H
+#define DALI_VECTOR_H
 
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <cstddef>
 #include <algorithm>
+#include <cstdint> // uint32_t
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h>
@@ -58,7 +59,7 @@ namespace Dali
  * 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
 
@@ -209,7 +210,7 @@ protected: // for Derived classes
 
 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
 
@@ -219,6 +220,7 @@ protected: // Data
 
 };
 
+/// @cond internal
 /**
  * @brief Vector algorithm variant for trivial types.
  *
@@ -320,9 +322,9 @@ protected: // API for deriving classes
    * @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 );
   }
 
   /**
@@ -334,9 +336,9 @@ protected: // API for deriving classes
    * @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 ) );
   }
 
   /**
@@ -348,7 +350,7 @@ protected: // API for deriving classes
    * @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();
@@ -357,27 +359,29 @@ protected: // API for deriving classes
     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 );
   }
 };
+/// @endcond
 
+/// @cond internal
 /**
  * @brief Vector algorithm variant for complex types.
  *
@@ -395,6 +399,7 @@ private:
   ~VectorAlgorithms()
   { }
 };
+/// @endcond
 
 /**
  * @brief Vector class with minimum space allocation when it's empty.
@@ -584,8 +589,8 @@ public: // API
   {
     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 );
@@ -620,9 +625,9 @@ public: // API
       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 ) );
   }
 
@@ -693,7 +698,7 @@ public: // API
     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
     {
@@ -734,8 +739,8 @@ public: // API
     }
     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 ) ) );
     }
 
@@ -801,4 +806,4 @@ public: // API
  */
 } // namespace Dali
 
-#endif /* __DALI_VECTOR_H__ */
+#endif // DALI_VECTOR_H