Enable build with iniparser v 3.1
[platform/framework/native/appfw.git] / inc / FBaseBuffer.h
index 9b2b194..a3476c8 100644 (file)
@@ -1,5 +1,4 @@
 //
-// Open Service Platform
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
 // Licensed under the Apache License, Version 2.0 (the License);
@@ -21,7 +20,6 @@
  *
  * This header file contains the declarations of the %Buffer classes.
  */
-
 #ifndef _FBASE_BUFFER_H_
 #define _FBASE_BUFFER_H_
 
@@ -52,11 +50,11 @@ class ByteBuffer;
  * The following example demonstrates how to use the %Buffer class.
  *
  * @code
- *     
+ *
  *     #include <FBase.h>
  *
  *     using namespace Tizen::Base;
- *     
+ *
  *     void
  *     MyClass::BufferSample(void)
  *     {
@@ -68,7 +66,7 @@ class ByteBuffer;
  *             intBuf.Construct(BUFFER_SIZE_MAX);
  *
  *             int intArray[] = {0,1,2,3,4,5,6,7,8,9};
- *     
+ *
  *             // Copies all values from intArray to intBuffer instance
  *             // position = 10 (num of element copied)
  *             intBuf.SetArray(intArray, 0, (sizeof(intArray) / sizeof(int)));
@@ -76,46 +74,46 @@ class ByteBuffer;
  *             // Flips the buffer: The limit is set to the current position and
  *             // then the position is set to zero
  *             intBuf.Flip(); // position = 0, limit = 10
- *     
+ *
  *             // Gets the number of elements between the current position and the limit
  *             int remaining = intBuf.GetRemaining();
- *     
+ *
  *             // Initializes a doubleBuf with capacity(10) using Construct() method
  *             DoubleBuffer doubleBuf;
  *             doubleBuf.Construct(remaining);
- *     
+ *
  *             // Reads and writes elements from the intBuf to the doubleBuf
  *             for (int i = 0; i < remaining; i++)
  *             {
  *                     int value;
  *
  *                     // Demonstrates relative reading and writing
- *     
+ *
  *                     // Reads the value at the current position, and then increments the position
  *                     intBuf.Get(value);
- *     
+ *
  *                     // Writes the value * 12.34 at the current position of the doubleBuf
  *                     // and then increment the position
  *                     doubleBuf.Set(value * 12.34);
- *     
+ *
  *                     // Now, positions of the intBuf and the doubleBuf have been incremented by one
  *             }
- *     
+ *
  *             // Flips the doubleBuf
  *             doubleBuf.Flip();
  *             // Now, the doubleBuf's position = 0 and limit = 10
- *     
+ *
  *             // Gets the remaining elements of the doubleBuf
  *             remaining = doubleBuf.GetRemaining();
- *     
+ *
  *             // Gets the second double value with index
  *             double doubleValue;
  *             doubleBuf.Get(1, doubleValue);                  // 12.34
  *     }
- *     
+ *
  * @endcode
  */
-template<class Type>
+template< class Type >
 class _OSP_EXPORT_ Buffer
        : public BufferBase
 {
@@ -152,13 +150,13 @@ public:
         *
         * @since 2.0
         *
-        * @param[in]   buffer          The other %Buffer instance
+        * @param[in]   buffer                  The other %Buffer instance
         * @exception   E_SUCCESS               The method is successful.
         * @exception   E_INVALID_ARG   The specified input parameter is invalid, or
         *                                                              the source buffer is not constructed.
         * @see                 Buffer()
         */
-       result Construct(const Buffer <Type>& buffer)
+       result Construct(const Buffer< Type >& buffer)
        {
                TryReturn(null != buffer._pData, E_INVALID_ARG, ("[E_INVALID_ARG] The source buffer is not constructed."));
 
@@ -180,7 +178,7 @@ public:
         * @since 2.0
         *
         * @return              An error code
-        * @param[in]   capacity        The number of elements
+        * @param[in]   capacity                The number of elements
         * @exception   E_SUCCESS               The method is successful.
         * @exception   E_INVALID_ARG   The specified @c capacity is negative.
         * @see                 Buffer()
@@ -195,21 +193,21 @@ public:
        *
        * @since 2.0
        *
-       * @return           An error code
-       * @param[in]       pBuffer                The buffer which is shared
-       * @param[in]       index                  The starting index of the buffer from where the first @c byte value is read
-       * @param[in]       length                 The number of bytes to read from the given buffer @n This is a limit of this instance.
-       * @param[in]       capacity               The capacity of this instance
-       * @exception       E_SUCCESS           The method is successful.
-       * @exception       E_INVALID_ARG     A specified input parameter is invalid, or
-       *                                               the @c pBuffer is @c null.
-       * @exception       E_OUT_OF_RANGE  The specified @c index is outside the bounds of the data structure, or
-       *                                               the @c index is larger than the @c length.
+       * @return                       An error code
+       * @param[in]            pBuffer                         The buffer which is shared
+       * @param[in]            index                           The starting index of the buffer from where the first @c byte value is read
+       * @param[in]            length                          The number of bytes to read from the given buffer @n This is a limit of this instance.
+       * @param[in]            capacity                        The capacity of this instance
+       * @exception       E_SUCCESS                    The method is successful.
+       * @exception       E_INVALID_ARG                A specified input parameter is invalid, or
+       *                                                                               the @c pBuffer is @c null.
+       * @exception       E_OUT_OF_RANGE               The specified @c index is outside the bounds of the data structure, or
+       *                                                                               the @c index is larger than the @c length.
        */
        result Construct(const Type* pBuffer, int index, int length, int capacity)
        {
                TryReturn(pBuffer != null, E_INVALID_ARG, "[E_INVALID_ARG] The pBuffer is null.");
-               TryReturn(index >= 0 && length >= 0 && capacity >=0, E_OUT_OF_RANGE,
+               TryReturn(index >= 0 && length >= 0 && capacity >= 0, E_OUT_OF_RANGE,
                        "[E_OUT_OF_RANGE] index(%d), length(%d) and capacity(%d) MUST be greater than or equal to 0.", index,
                        length, capacity);
                TryReturn(index < capacity && length <= capacity && index + length <= capacity, E_OUT_OF_RANGE,
@@ -219,14 +217,14 @@ public:
                void* pTemp = null;
                int sizeofBufferData = sizeof(_BufferData);
 
-               Type* tempByte = const_cast <Type *> (pBuffer + index);
-               __pArrayStart = reinterpret_cast <byte *> (tempByte);
+               Type* tempByte = const_cast< Type* >(pBuffer + index);
+               __pArrayStart = reinterpret_cast< byte* >(tempByte);
 
                pTemp = malloc(sizeofBufferData);
                TryReturn(pTemp != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
 
                memset(pTemp, 0, sizeofBufferData);
-               _pData = static_cast <_BufferData*>(pTemp);
+               _pData = static_cast< _BufferData* >(pTemp);
 
                _pData->refCount = 1;
                _pData->capacityInByte = capacity * sizeof(Type);
@@ -244,7 +242,7 @@ public:
         *
         * @return              A reference to the indexed element
         * @param[in]   index   The index of the element @n
-        *                                              It must be less than the limit.
+        *                              It must be less than the limit.
         */
        Type& operator [](int index) const
        {
@@ -260,13 +258,13 @@ public:
         * @since 2.0
         *
         * @return              @c true if the buffers being compared are equal, @n
-        *               else @c false
+        *                              else @c false
         * @param[in]   buffer The buffer to compare with the current instance of %Buffer
-        * @remarks             This method returns @c true only if the two buffers have the same number of remaining elements @n
+        * @remarks     This method returns @c true only if the two buffers have the same number of remaining elements @n
         *                              and the two sequences of remaining elements are equal (considered independently of their starting positions).
-        * @see                         Equals()
+        * @see                 Equals()
         */
-       bool operator ==(const Buffer <Type>& buffer) const
+       bool operator ==(const Buffer< Type >& buffer) const
        {
                bool r = true;
                if (this == (void*) (&buffer))
@@ -296,14 +294,14 @@ public:
         * @since 2.0
         *
         * @return              @c true if the buffers are not equal, @n
-        *               else @c false
+        *                              else @c false
         * @param[in]   buffer The buffer to compare with the current instance of %Buffer
-        * @remarks             This method returns @c false only if the two buffers being compared have the same @n
+        * @remarks     This method returns @c false only if the two buffers being compared have the same @n
         *                              number of remaining elements and the two sequences of remaining elements are equal @n
         *                              (considered independently of their starting positions).
-        * @see                         Equals()
+        * @see                 Equals()
         */
-       bool operator !=(const Buffer <Type>& buffer) const
+       bool operator !=(const Buffer< Type >& buffer) const
        {
                return !(*this == buffer);
        }
@@ -326,7 +324,7 @@ public:
         * @exception   E_OVERFLOW              The operation (arithmetic/casting/conversion) has caused an overflow. @n
         *                                                              The number of remaining bytes of the current buffer is less than
         *                                                              the number of remaining bytes of the given buffer.
-        * @remarks             After the copy operation, the current (destination) buffer's position and the given
+        * @remarks     After the copy operation, the current (destination) buffer's position and the given
         *                              (source) buffer's position are incremented by the number of elements copied (the number
         *                              of remaining elements of the given buffer). @n
         *                              If the remaining part of the current instance is not less than the remaining part of the input instance,
@@ -384,15 +382,15 @@ public:
         *      }
         * @endcode
         */
-       result CopyFrom(Buffer<Type>& buffer)
+       result CopyFrom(Buffer< Type >& buffer)
        {
-               TryReturn(this != static_cast <void*>(&buffer), E_INVALID_ARG,
+               TryReturn(this != static_cast< void* >(&buffer), E_INVALID_ARG,
                        "[E_INVALID_ARG] The source and target buffers are identical.");
                int copyLength = buffer.GetRemaining();
                TryReturn(GetRemaining() >= copyLength, E_OVERFLOW, "[E_OVERFLOW]");
 
                memcpy(__pArrayStart + _position * sizeof(Type), buffer.__pArrayStart + buffer._position * sizeof(Type),
-                          copyLength * sizeof(Type));
+                       copyLength * sizeof(Type));
 
                _position += copyLength;
                buffer._position += copyLength;
@@ -407,11 +405,11 @@ public:
         * @since 2.0
         *
         * @return                      An error code
-        * @param[out]  value The value at the current position
+        * @param[out]          value The value at the current position
         * @exception           E_SUCCESS               The method is successful.
         * @exception           E_UNDERFLOW             The operation (arithmetic/casting/conversion) has caused an underflow. @n
-        *                                                              The current position is greater than the limit.
-        * @see                                 Set()
+        *                                                                      The current position is greater than the limit.
+        * @see                         Set()
         */
        result Get(Type& value)
        {
@@ -429,11 +427,11 @@ public:
         *
         * @return                      An error code
         * @param[in]           index The index into the buffer from where the value is read
-        * @param[out]  value The value at the given index
+        * @param[out]          value The value at the given index
         * @exception           E_SUCCESS                       The method is successful.
         * @exception           E_OUT_OF_RANGE          The specified @c index is outside the bounds of the data structure. @n
-        *                                                                      The @c index is greater than the limit or less than @c 0.
-        * @see                                 Set()
+        *                                                                              The @c index is greater than the limit or less than @c 0.
+        * @see                         Set()
         */
        result Get(int index, Type& value) const
        {
@@ -462,7 +460,7 @@ public:
         *                                                                      the @c index or length is less than @c 0.
         * @exception   E_UNDERFLOW                     The operation (arithmetic/casting/conversion) has caused an underflow. @n
         *                                                                      The remaining elements of this buffer are smaller than @c length.
-        * @remarks             After the copy operation, the position is incremented by @c length.
+        * @remarks     After the copy operation, the position is incremented by @c length.
         * @see                 SetArray()
         */
        result GetArray(Type* pArray, int index, int length)
@@ -489,10 +487,10 @@ public:
         * @return              An error code
         * @param[in]   buffer  The source buffer from where the bytes are read @n
         *                                              It must not be this buffer.
-        * @exception   E_SUCCESS               The method is successful.
+        * @exception   E_SUCCESS               The method is successful.
         * @exception   E_INVALID_ARG   The specified input parameter is invalid. @n
         *                                                              The given buffer is same as the current buffer instance.
-        * @remarks             After the copy operation, the current (destination) buffer's position and the given
+        * @remarks     After the copy operation, the current (destination) buffer's position and the given
         *                              (source) buffer's position are  incremented by the number of elements copied (the smaller value
         *                              between the number of elements remaining in the calling buffer and the source buffer). @n
         *                              If there are more elements remaining in the calling buffer than elements remaining in the input instance,
@@ -557,15 +555,15 @@ public:
         *      }
         * @endcode
         */
-       result ReadFrom(Buffer<Type>& buffer)
+       result ReadFrom(Buffer< Type >& buffer)
        {
-               TryReturn(this != static_cast <void*>(&buffer), E_INVALID_ARG,
+               TryReturn(this != static_cast< void* >(&buffer), E_INVALID_ARG,
                        "[E_INVALID_ARG] The source and target buffers are identical.");
 
                int copyLength = (GetRemaining() < buffer.GetRemaining()) ? GetRemaining() : buffer.GetRemaining();
 
                memcpy(__pArrayStart + _position * sizeof(Type), buffer.__pArrayStart + buffer._position * sizeof(Type),
-                          copyLength * sizeof(Type));
+                       copyLength * sizeof(Type));
 
                _position += copyLength;
                buffer._position += copyLength;
@@ -579,7 +577,7 @@ public:
         * and then increments the position. @n
         * Provides a way for relative indexing and writing.
         *
-        * @since 2.0   
+        * @since 2.0
         *
         * @return              An error code
         * @param[in]   value           The value to write to the calling %Buffer
@@ -605,7 +603,7 @@ public:
         * @return              An error code
         * @param[in]   index   The index at which the value is written
         * @param[in]   value   The value to write
-        * @exception   E_SUCCESS                       The method is successful.
+        * @exception   E_SUCCESS           The method is successful.
         * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure, or
         *                                                                      the @c index is not smaller than the limit or less than @c 0.
         * @see                 Get()
@@ -636,7 +634,7 @@ public:
         *                                                                      the @c index or length is less than @c 0.
         * @exception   E_OVERFLOW                      The operation (arithmetic/casting/conversion) has caused an overflow. @n
         *                                                                      The remainder of this buffer is smaller than @c length.
-        * @remarks             This method copies @c length number of values from the source array,
+        * @remarks     This method copies @c length number of values from the source array,
         *                              starting from the given @c index in the array, into the calling
         *                              buffer, starting at the current position.
         *                              After the copy operation, the position is incremented by @c length.
@@ -663,14 +661,14 @@ public:
         * @since 2.0
         *
         * @return              A pointer to the new buffer
-        * @remarks             The content of the new buffer starts at the current position of this instance of %Buffer.
+        * @remarks     The content of the new buffer starts at the current position of this instance of %Buffer.
         *                              The new buffer's position is @c 0, its capacity and limit is
         *                              the number of bytes remaining in the current instance of %Buffer,
         *                              and it is marked as undefined.
         */
-       Buffer <Type>* SliceN(void) const
+       Buffer< Type >* SliceN(void) const
        {
-               Buffer <Type>* pBuffer = new Buffer <Type>();
+               Buffer< Type >* pBuffer = new Buffer< Type >();
                pBuffer->_pData = _pData;
                AddRef();
                pBuffer->_capacity = GetRemaining();
@@ -704,7 +702,7 @@ public:
         * @return              @c true if the input equals the calling %Buffer instance, @n
         *                              else @c false
         * @param[in]   obj     The object to compare with the calling %Buffer
-        * @remarks             This method returns @c true if and only if the specified object is also an instance of %Buffer class,
+        * @remarks     This method returns @c true if and only if the specified object is also an instance of %Buffer class,
         *                              the two buffers have the same number of remaining elements, and the two sequences of
         *                              remaining elements are equal (considered independently of their starting positions).
         * @see                 Tizen::Base::BufferBase::GetHashCode()
@@ -712,7 +710,7 @@ public:
        virtual bool Equals(const Tizen::Base::Object& obj) const
        {
                bool out = false;
-               const Buffer <Type>* other = static_cast <const Buffer <Type>*>(&obj);
+               const Buffer< Type >* other = static_cast< const Buffer< Type >* >(&obj);
                if ((other == this) || (*other == *this))
                {
                        out = true;
@@ -727,7 +725,7 @@ public:
         *      @since 2.0
         *
         *      @return         The hash value of the current instance
-        *      @remarks        The hash code of a buffer depends only upon its remaining elements.
+        *      @remarks                The hash code of a buffer depends only upon its remaining elements.
         */
        virtual int GetHashCode(void) const
        {
@@ -737,7 +735,7 @@ public:
                int offset = _position * GetTypeSize();
                for (int i = 0; i < len; ++i)
                {
-                       hash = (hash<<5) - hash + (int) __pArrayStart[offset + (i * sizeof(int))];
+                       hash = (hash << 5) - hash + (int) __pArrayStart[offset + (i * sizeof(int))];
                }
 
                return hash;
@@ -747,7 +745,7 @@ private:
        /**
         * This is the copy constructor for this class.
         */
-       Buffer(const Buffer <Type>& buffer)
+       Buffer(const Buffer< Type >& buffer)
        {
                Construct(buffer);
        }
@@ -755,7 +753,7 @@ private:
        /**
         * This is the assignment operator.
         */
-       Buffer <Type>& operator =(const Buffer <Type>& buffer);
+       Buffer< Type >& operator =(const Buffer< Type >& buffer);
 
        /**
         * Returns the size of the type of this buffer.
@@ -773,56 +771,56 @@ private:
 
 
 /**
- * The @c double buffer type.
+ * The @c double buffer type
  * @since 2.0
  */
-typedef Buffer <double> DoubleBuffer;
+typedef Buffer< double > DoubleBuffer;
 
 /**
-* The @c float buffer type.
+* The @c float buffer type
 * @since 2.0
 */
-typedef Buffer <float> FloatBuffer;
+typedef Buffer< float > FloatBuffer;
 
 /**
-* The @c int buffer type.
+* The @c int buffer type
 * @since 2.0
 */
-typedef Buffer <int> IntBuffer;
+typedef Buffer< int > IntBuffer;
 
 /**
-* The @c long buffer type.
+* The @c long buffer type
 * @since 2.0
 */
-typedef Buffer <long> LongBuffer;
+typedef Buffer< long > LongBuffer;
 
 /**
-* The @c long @c long buffer type.
+* The @c long @c long buffer type
 * @since 2.0
 */
-typedef Buffer <long long> LongLongBuffer;
+typedef Buffer< long long > LongLongBuffer;
 
 /**
-* The @c wchar_t buffer type.
+* The @c wchar_t buffer type
 * @since 2.0
 */
-typedef Buffer <wchar_t> WcharBuffer;
+typedef Buffer< wchar_t > WcharBuffer;
 
 /**
-* The @c short buffer type.
+* The @c short buffer type
 * @since 2.0
 */
-typedef Buffer <short> ShortBuffer;
+typedef Buffer< short > ShortBuffer;
 
 
 #ifdef _MSC_VER
-template class _OSP_EXPORT_ Buffer <double>;
-template class _OSP_EXPORT_ Buffer <float>;
-template class _OSP_EXPORT_ Buffer <int>;
-template class _OSP_EXPORT_ Buffer <long>;
-template class _OSP_EXPORT_ Buffer <long long>;
-template class _OSP_EXPORT_ Buffer <wchar_t>;
-template class _OSP_EXPORT_ Buffer <short>;
+template class _OSP_EXPORT_ Buffer< double >;
+template class _OSP_EXPORT_ Buffer< float >;
+template class _OSP_EXPORT_ Buffer< int >;
+template class _OSP_EXPORT_ Buffer< long >;
+template class _OSP_EXPORT_ Buffer< long long >;
+template class _OSP_EXPORT_ Buffer< wchar_t >;
+template class _OSP_EXPORT_ Buffer< short >;
 #endif
 
 }} // Tizen::Base