X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fbase%2FFBaseByteBuffer.cpp;h=fe78b4b2cdcb9f507b045b85e397e05405b8201d;hb=12d3f7f5ba6bb63321777c77281594ebfd57dda1;hp=97eb2125ad1cd1bf8de35435e010de5806545cb5;hpb=27f1388665067f69d5eb64e0cae6bb5f4250beec;p=platform%2Fframework%2Fnative%2Fappfw.git diff --git a/src/base/FBaseByteBuffer.cpp b/src/base/FBaseByteBuffer.cpp index 97eb212..fe78b4b 100644 --- a/src/base/FBaseByteBuffer.cpp +++ b/src/base/FBaseByteBuffer.cpp @@ -18,13 +18,11 @@ * @file FBaseByteBuffer.cpp * @brief This is the implementation for ByteBuffer class. */ - #include #include #include #include - static const byte DOUBLE_SIZE = sizeof(double); static const byte FLOAT_SIZE = sizeof(float); static const byte INT_SIZE = sizeof(int); @@ -76,7 +74,7 @@ ByteBuffer::Construct(int capacity) } result -ByteBuffer::Construct(const byte *pBuffer, int index, int length, int capacity) +ByteBuffer::Construct(const byte* pBuffer, int index, int length, int capacity) { SysTryReturn(NID_BASE, pBuffer != null, E_INVALID_ARG, E_INVALID_ARG, "[%s] The pBuffer is null.", GetErrorMessage(E_INVALID_ARG)); @@ -90,13 +88,13 @@ ByteBuffer::Construct(const byte *pBuffer, int index, int length, int capacity) void* pTemp = null; int sizeofBufferData = sizeof(_BufferData); - __pArrayStart = const_cast (pBuffer + index); + __pArrayStart = const_cast< byte* >(pBuffer + index); pTemp = malloc(sizeofBufferData); SysTryReturn(NID_BASE, pTemp != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s]", GetErrorMessage(E_OUT_OF_MEMORY)); memset(pTemp, 0, sizeofBufferData); - _pData = static_cast <_BufferData*>(pTemp); + _pData = static_cast< _BufferData* >(pTemp); _pData->refCount = 1; _pData->capacityInByte = capacity; @@ -119,7 +117,7 @@ ByteBuffer::operator [](int index) byte ByteBuffer::operator [](int index) const { - return const_cast(*this)[index]; + return const_cast< ByteBuffer& >(*this)[index]; } bool @@ -159,7 +157,7 @@ ByteBuffer::operator !=(const ByteBuffer& buffer) const DoubleBuffer* ByteBuffer::AsDoubleBufferN(void) const { - std::unique_ptr pBuffer(new (std::nothrow) DoubleBuffer()); + std::unique_ptr< DoubleBuffer > pBuffer(new (std::nothrow) DoubleBuffer()); pBuffer->_pData = _pData; AddRef(); pBuffer->_capacity = GetRemaining() / DOUBLE_SIZE; @@ -175,7 +173,7 @@ ByteBuffer::AsDoubleBufferN(void) const FloatBuffer* ByteBuffer::AsFloatBufferN(void) const { - std::unique_ptr pBuffer(new (std::nothrow) FloatBuffer()); + std::unique_ptr< FloatBuffer > pBuffer(new (std::nothrow) FloatBuffer()); pBuffer->_pData = _pData; AddRef(); pBuffer->_capacity = GetRemaining() / FLOAT_SIZE; @@ -191,7 +189,7 @@ ByteBuffer::AsFloatBufferN(void) const IntBuffer* ByteBuffer::AsIntBufferN(void) const { - std::unique_ptr pBuffer(new (std::nothrow) IntBuffer()); + std::unique_ptr< IntBuffer > pBuffer(new (std::nothrow) IntBuffer()); pBuffer->_pData = _pData; AddRef(); pBuffer->_capacity = GetRemaining() / INT_SIZE; @@ -207,7 +205,7 @@ ByteBuffer::AsIntBufferN(void) const LongBuffer* ByteBuffer::AsLongBufferN(void) const { - std::unique_ptr pBuffer(new (std::nothrow) LongBuffer()); + std::unique_ptr< LongBuffer > pBuffer(new (std::nothrow) LongBuffer()); pBuffer->_pData = _pData; AddRef(); pBuffer->_capacity = GetRemaining() / LONG_SIZE; @@ -223,7 +221,7 @@ ByteBuffer::AsLongBufferN(void) const LongLongBuffer* ByteBuffer::AsLongLongBufferN(void) const { - std::unique_ptr pBuffer(new (std::nothrow) LongLongBuffer()); + std::unique_ptr< LongLongBuffer > pBuffer(new (std::nothrow) LongLongBuffer()); pBuffer->_pData = _pData; AddRef(); pBuffer->_capacity = GetRemaining() / LONGLONG_SIZE; @@ -239,7 +237,7 @@ ByteBuffer::AsLongLongBufferN(void) const McharBuffer* ByteBuffer::AsMcharBufferN(void) const { - std::unique_ptr pBuffer(new (std::nothrow) McharBuffer()); + std::unique_ptr< McharBuffer > pBuffer(new (std::nothrow) McharBuffer()); pBuffer->_pData = _pData; AddRef(); pBuffer->_capacity = GetRemaining() / MCHAR_SIZE; @@ -255,7 +253,7 @@ ByteBuffer::AsMcharBufferN(void) const WcharBuffer* ByteBuffer::AsWcharBufferN(void) const { - std::unique_ptr pBuffer(new (std::nothrow) WcharBuffer()); + std::unique_ptr< WcharBuffer > pBuffer(new (std::nothrow) WcharBuffer()); pBuffer->_pData = _pData; AddRef(); pBuffer->_capacity = GetRemaining() / MCHAR_SIZE; @@ -271,7 +269,7 @@ ByteBuffer::AsWcharBufferN(void) const ShortBuffer* ByteBuffer::AsShortBufferN(void) const { - std::unique_ptr pBuffer(new (std::nothrow) ShortBuffer()); + std::unique_ptr< ShortBuffer > pBuffer(new (std::nothrow) ShortBuffer()); pBuffer->_pData = _pData; AddRef(); pBuffer->_capacity = GetRemaining() / SHORT_SIZE; @@ -287,7 +285,7 @@ ByteBuffer::AsShortBufferN(void) const result ByteBuffer::CopyFrom(ByteBuffer& buffer) { - SysTryReturn(NID_BASE, this != static_cast (&buffer), E_INVALID_ARG, E_INVALID_ARG, + SysTryReturn(NID_BASE, this != static_cast< void* >(&buffer), E_INVALID_ARG, E_INVALID_ARG, "[%s] The source and target buffers are identical.", GetErrorMessage(E_INVALID_ARG)); int copyLength = buffer.GetRemaining(); SysTryReturn(NID_BASE, @@ -347,7 +345,7 @@ ByteBuffer::GetDouble(double& value) GetRemaining() >= DOUBLE_SIZE, E_UNDERFLOW, E_UNDERFLOW, "[%s] The remaining bytes of this buffer are smaller than the size of double", GetErrorMessage(E_UNDERFLOW)); - value = *reinterpret_cast (&__pArrayStart[_position]); + value = *reinterpret_cast< double* >(&__pArrayStart[_position]); _position += DOUBLE_SIZE; return E_SUCCESS; @@ -361,7 +359,7 @@ ByteBuffer::GetDouble(int index, double& value) const "[%s] The index(%d) MUST be greater than or equal to 0, and less then the 'current limit(%d) - size of double(%d)'.", GetErrorMessage(E_OUT_OF_RANGE), index, _limit, DOUBLE_SIZE); - value = *reinterpret_cast (&__pArrayStart[index]); + value = *reinterpret_cast< double* >(&__pArrayStart[index]); return E_SUCCESS; } @@ -373,7 +371,7 @@ ByteBuffer::GetFloat(float& value) GetRemaining() >= FLOAT_SIZE, E_UNDERFLOW, E_UNDERFLOW, "[%s] The remaining bytes of this buffer are smaller than the size of float.", GetErrorMessage(E_UNDERFLOW)); - value = *reinterpret_cast (&__pArrayStart[_position]); + value = *reinterpret_cast< float* >(&__pArrayStart[_position]); _position += FLOAT_SIZE; return E_SUCCESS; @@ -387,7 +385,7 @@ ByteBuffer::GetFloat(int index, float& value) const "[%s] The index(%d) MUST be greater than or equal to 0, and less then the 'current limit(%d) - size of float(%d)'.", GetErrorMessage(E_OUT_OF_RANGE), index, _limit, FLOAT_SIZE); - value = *reinterpret_cast (&__pArrayStart[index]); + value = *reinterpret_cast< float* >(&__pArrayStart[index]); return E_SUCCESS; } @@ -399,7 +397,7 @@ ByteBuffer::GetInt(int& value) GetRemaining() >= INT_SIZE, E_UNDERFLOW, E_UNDERFLOW, "[%s] The remaining bytes of this buffer are smaller than the size of int.", GetErrorMessage(E_UNDERFLOW)); - value = *reinterpret_cast (&__pArrayStart[_position]); + value = *reinterpret_cast< int* >(&__pArrayStart[_position]); _position += INT_SIZE; return E_SUCCESS; @@ -413,7 +411,7 @@ ByteBuffer::GetInt(int index, int& value) const "[%s] The index(%d) MUST be greater than or equal to 0, and less then the 'current limit(%d) - size of int(%d)'.", GetErrorMessage(E_OUT_OF_RANGE), index, _limit, INT_SIZE); - value = *reinterpret_cast (&__pArrayStart[index]); + value = *reinterpret_cast< int* >(&__pArrayStart[index]); return E_SUCCESS; } @@ -425,7 +423,7 @@ ByteBuffer::GetLong(long& value) GetRemaining() >= LONG_SIZE, E_UNDERFLOW, E_UNDERFLOW, "[%s] The remaining bytes of this buffer are smaller than the size of long.", GetErrorMessage(E_UNDERFLOW)); - value = *reinterpret_cast (&__pArrayStart[_position]); + value = *reinterpret_cast< long* >(&__pArrayStart[_position]); _position += LONG_SIZE; return E_SUCCESS; @@ -439,7 +437,7 @@ ByteBuffer::GetLong(int index, long& value) const "[%s] The index(%d) MUST be greater than or equal to 0, and less then the 'current limit(%d) - size of long(%d)'.", GetErrorMessage(E_OUT_OF_RANGE), index, _limit, LONG_SIZE); - value = *reinterpret_cast (&__pArrayStart[index]); + value = *reinterpret_cast< long* >(&__pArrayStart[index]); return E_SUCCESS; } @@ -451,7 +449,7 @@ ByteBuffer::GetLongLong(long long& value) GetRemaining() >= LONGLONG_SIZE, E_UNDERFLOW, E_UNDERFLOW, "[%s] The remaining bytes of this buffer are smaller than the size of long long.", GetErrorMessage(E_UNDERFLOW)); - value = *reinterpret_cast (&__pArrayStart[_position]); + value = *reinterpret_cast< long long* >(&__pArrayStart[_position]); _position += LONGLONG_SIZE; return E_SUCCESS; @@ -465,7 +463,7 @@ ByteBuffer::GetLongLong(int index, long long& value) const "[%s] The index(%d) MUST be greater than or equal to 0, and less then the 'current limit(%d) - size of long long(%d)'.", GetErrorMessage(E_OUT_OF_RANGE), index, _limit, LONGLONG_SIZE); - value = *reinterpret_cast (&__pArrayStart[index]); + value = *reinterpret_cast< long long* >(&__pArrayStart[index]); return E_SUCCESS; } @@ -477,7 +475,7 @@ ByteBuffer::GetMchar(wchar_t& value) GetRemaining() >= MCHAR_SIZE, E_UNDERFLOW, E_UNDERFLOW, "[%s] The remaining bytes of this buffer are smaller than the size of wchar_t.", GetErrorMessage(E_UNDERFLOW)); - value = *reinterpret_cast (&__pArrayStart[_position]); + value = *reinterpret_cast< wchar_t* >(&__pArrayStart[_position]); _position += MCHAR_SIZE; return E_SUCCESS; @@ -490,7 +488,7 @@ ByteBuffer::GetWchar(wchar_t& value) GetRemaining() >= MCHAR_SIZE, E_UNDERFLOW, E_UNDERFLOW, "[%s] The remaining bytes of this buffer are smaller than the size of wchar_t.", GetErrorMessage(E_UNDERFLOW)); - value = *reinterpret_cast (&__pArrayStart[_position]); + value = *reinterpret_cast< wchar_t* >(&__pArrayStart[_position]); _position += MCHAR_SIZE; return E_SUCCESS; @@ -504,7 +502,7 @@ ByteBuffer::GetMchar(int index, wchar_t& value) const "[%s] The index(%d) MUST be greater than or equal to 0, and less then the 'current limit(%d) - size of wchar_t(%d)'.", GetErrorMessage(E_OUT_OF_RANGE), index, _limit, MCHAR_SIZE); - value = *reinterpret_cast (&__pArrayStart[index]); + value = *reinterpret_cast< wchar_t* >(&__pArrayStart[index]); return E_SUCCESS; } @@ -517,7 +515,7 @@ ByteBuffer::GetWchar(int index, wchar_t& value) const "[%s] The index(%d) MUST be greater than or equal to 0, and less then the 'current limit(%d) - size of wchar_t(%d)'.", GetErrorMessage(E_OUT_OF_RANGE), index, _limit, MCHAR_SIZE); - value = *reinterpret_cast (&__pArrayStart[index]); + value = *reinterpret_cast< wchar_t* >(&__pArrayStart[index]); return E_SUCCESS; } @@ -529,7 +527,7 @@ ByteBuffer::GetShort(short& value) GetRemaining() >= SHORT_SIZE, E_UNDERFLOW, E_UNDERFLOW, "[%s] The remaining bytes of this buffer are smaller than the size of short.", GetErrorMessage(E_UNDERFLOW)); - value = *reinterpret_cast (&__pArrayStart[_position]); + value = *reinterpret_cast< short* >(&__pArrayStart[_position]); _position += SHORT_SIZE; return E_SUCCESS; @@ -543,7 +541,7 @@ ByteBuffer::GetShort(int index, short& value) const "[%s] The index(%d) MUST be greater than or equal to 0, and less then the 'current limit(%d) - size of short(%d)'.", GetErrorMessage(E_OUT_OF_RANGE), index, _limit, SHORT_SIZE); - value = *reinterpret_cast (&__pArrayStart[index]); + value = *reinterpret_cast< short* >(&__pArrayStart[index]); return E_SUCCESS; } @@ -551,7 +549,7 @@ ByteBuffer::GetShort(int index, short& value) const result ByteBuffer::ReadFrom(ByteBuffer& buffer) { - SysTryReturn(NID_BASE, this != static_cast (&buffer), E_INVALID_ARG, E_INVALID_ARG, + SysTryReturn(NID_BASE, this != static_cast< void* >(&buffer), E_INVALID_ARG, E_INVALID_ARG, "[%s] The source and target buffers are identical.", GetErrorMessage(E_INVALID_ARG)); int copyLength = (GetRemaining() < buffer.GetRemaining()) ? GetRemaining() : buffer.GetRemaining(); @@ -606,7 +604,7 @@ ByteBuffer::SetDouble(double value) GetRemaining() >= DOUBLE_SIZE, E_OVERFLOW, E_OVERFLOW, "[%s] The remaining bytes of this buffer are smaller than size of double.", GetErrorMessage(E_OVERFLOW)); - *reinterpret_cast (&__pArrayStart[_position]) = value; + *reinterpret_cast< double* >(&__pArrayStart[_position]) = value; _position += DOUBLE_SIZE; return E_SUCCESS; @@ -620,7 +618,7 @@ ByteBuffer::SetDouble(int index, double value) "[%s] The index(%d) MUST be greater than or equal to 0, and less then the 'current limit(%d) - size of double(%d)'.", GetErrorMessage(E_OUT_OF_RANGE), index, _limit, DOUBLE_SIZE); - *reinterpret_cast (&__pArrayStart[index]) = value; + *reinterpret_cast< double* >(&__pArrayStart[index]) = value; return E_SUCCESS; } @@ -632,7 +630,7 @@ ByteBuffer::SetFloat(float value) GetRemaining() >= FLOAT_SIZE, E_OVERFLOW, E_OVERFLOW, "[%s] The remaining bytes of this buffer are smaller than size of float.", GetErrorMessage(E_OVERFLOW)); - *reinterpret_cast (&__pArrayStart[_position]) = value; + *reinterpret_cast< float* >(&__pArrayStart[_position]) = value; _position += FLOAT_SIZE; return E_SUCCESS; @@ -646,7 +644,7 @@ ByteBuffer::SetFloat(int index, float value) "[%s] The index(%d) MUST be greater than or equal to 0, and less then the 'current limit(%d) - size of float(%d)'.", GetErrorMessage(E_OUT_OF_RANGE), index, _limit, FLOAT_SIZE); - *reinterpret_cast (&__pArrayStart[index]) = value; + *reinterpret_cast< float* >(&__pArrayStart[index]) = value; return E_SUCCESS; } @@ -658,7 +656,7 @@ ByteBuffer::SetInt(int value) GetRemaining() >= INT_SIZE, E_OVERFLOW, E_OVERFLOW, "[%s] The remaining bytes of this buffer are smaller than size of int.", GetErrorMessage(E_OVERFLOW)); - *reinterpret_cast (&__pArrayStart[_position]) = value; + *reinterpret_cast< int* >(&__pArrayStart[_position]) = value; _position += INT_SIZE; return E_SUCCESS; @@ -672,7 +670,7 @@ ByteBuffer::SetInt(int index, int value) "[%s] The index(%d) MUST be greater than or equal to 0, and less then the 'current limit(%d) - size of int(%d)'.", GetErrorMessage(E_OUT_OF_RANGE), index, _limit, INT_SIZE); - *reinterpret_cast (&__pArrayStart[index]) = value; + *reinterpret_cast< int* >(&__pArrayStart[index]) = value; return E_SUCCESS; } @@ -684,7 +682,7 @@ ByteBuffer::SetLong(long value) GetRemaining() >= LONG_SIZE, E_OVERFLOW, E_OVERFLOW, "[%s] The remaining bytes of this buffer are smaller than size of long.", GetErrorMessage(E_OVERFLOW)); - *reinterpret_cast (&__pArrayStart[_position]) = value; + *reinterpret_cast< long* >(&__pArrayStart[_position]) = value; _position += LONG_SIZE; return E_SUCCESS; @@ -698,7 +696,7 @@ ByteBuffer::SetLong(int index, long value) "[%s] The index(%d) MUST be greater than or equal to 0, and less then the 'current limit(%d) - size of long(%d)'.", GetErrorMessage(E_OUT_OF_RANGE), index, _limit, LONG_SIZE); - *reinterpret_cast (&__pArrayStart[index]) = value; + *reinterpret_cast< long* >(&__pArrayStart[index]) = value; return E_SUCCESS; } @@ -710,7 +708,7 @@ ByteBuffer::SetLongLong(long long value) GetRemaining() >= LONGLONG_SIZE, E_OVERFLOW, E_OVERFLOW, "[%s] The remaining bytes of this buffer are smaller than size of long long.", GetErrorMessage(E_OVERFLOW)); - *reinterpret_cast (&__pArrayStart[_position]) = value; + *reinterpret_cast< long long* >(&__pArrayStart[_position]) = value; _position += LONGLONG_SIZE; return E_SUCCESS; @@ -724,7 +722,7 @@ ByteBuffer::SetLongLong(int index, long long value) "[%s] The index(%d) MUST be greater than or equal to 0, and less then the 'current limit(%d) - size of long long(%d)'.", GetErrorMessage(E_OUT_OF_RANGE), index, _limit, LONGLONG_SIZE); - *reinterpret_cast (&__pArrayStart[index]) = value; + *reinterpret_cast< long long* >(&__pArrayStart[index]) = value; return E_SUCCESS; } @@ -736,7 +734,7 @@ ByteBuffer::SetMchar(wchar_t value) GetRemaining() >= MCHAR_SIZE, E_OVERFLOW, E_OVERFLOW, "[%s] The remaining bytes of this buffer are smaller than size of wchar_t.", GetErrorMessage(E_OVERFLOW)); - *reinterpret_cast (&__pArrayStart[_position]) = value; + *reinterpret_cast< wchar_t* >(&__pArrayStart[_position]) = value; _position += MCHAR_SIZE; return E_SUCCESS; @@ -749,7 +747,7 @@ ByteBuffer::SetWchar(wchar_t value) GetRemaining() >= MCHAR_SIZE, E_OVERFLOW, E_OVERFLOW, "[%s] The remaining bytes of this buffer are smaller than size of wchar_t.", GetErrorMessage(E_OVERFLOW)); - *reinterpret_cast (&__pArrayStart[_position]) = value; + *reinterpret_cast< wchar_t* >(&__pArrayStart[_position]) = value; _position += MCHAR_SIZE; return E_SUCCESS; @@ -763,7 +761,7 @@ ByteBuffer::SetMchar(int index, wchar_t value) "[%s] The index(%d) MUST be greater than or equal to 0, and less then the 'current limit(%d) - size of wchar_t(%d)'.", GetErrorMessage(E_OUT_OF_RANGE), index, _limit, MCHAR_SIZE); - *reinterpret_cast (&__pArrayStart[index]) = value; + *reinterpret_cast< wchar_t* >(&__pArrayStart[index]) = value; return E_SUCCESS; } @@ -776,7 +774,7 @@ ByteBuffer::SetWchar(int index, wchar_t value) "[%s] The index(%d) MUST be greater than or equal to 0, and less then the 'current limit(%d) - size of wchar_t(%d)'.", GetErrorMessage(E_OUT_OF_RANGE), index, _limit, MCHAR_SIZE); - *reinterpret_cast (&__pArrayStart[index]) = value; + *reinterpret_cast< wchar_t* >(&__pArrayStart[index]) = value; return E_SUCCESS; } @@ -788,7 +786,7 @@ ByteBuffer::SetShort(short value) GetRemaining() >= SHORT_SIZE, E_OVERFLOW, E_OVERFLOW, "[%s] The remaining bytes of this buffer are smaller than size of short.", GetErrorMessage(E_OVERFLOW)); - *reinterpret_cast (&__pArrayStart[_position]) = value; + *reinterpret_cast< short* >(&__pArrayStart[_position]) = value; _position += SHORT_SIZE; return E_SUCCESS; @@ -802,7 +800,7 @@ ByteBuffer::SetShort(int index, short value) "[%s] The index(%d) MUST be greater than or equal to 0, and less then the 'current limit(%d) - size of short(%d)'.", GetErrorMessage(E_OUT_OF_RANGE), index, _limit, SHORT_SIZE); - *reinterpret_cast (&__pArrayStart[index]) = value; + *reinterpret_cast< short* >(&__pArrayStart[index]) = value; return E_SUCCESS; } @@ -810,7 +808,7 @@ ByteBuffer::SetShort(int index, short value) ByteBuffer* ByteBuffer::SliceN(void) const { - std::unique_ptr pBuffer(new (std::nothrow) ByteBuffer()); + std::unique_ptr< ByteBuffer > pBuffer(new (std::nothrow) ByteBuffer()); pBuffer->_pData = _pData; AddRef(); pBuffer->_capacity = GetRemaining(); @@ -839,7 +837,7 @@ bool ByteBuffer::Equals(const Tizen::Base::Object& obj) const { bool out = false; - const ByteBuffer* pOther = dynamic_cast (&obj); + const ByteBuffer* pOther = dynamic_cast< const ByteBuffer* >(&obj); if (pOther == null) { out = false; @@ -861,7 +859,7 @@ ByteBuffer::GetHashCode(void) const int offset = _position; for (int i = 0; i < len; ++i) { - hash = (hash << 5) - hash + static_cast (__pArrayStart[offset + (i * sizeof(hash))]); + hash = (hash << 5) - hash + static_cast< int >(__pArrayStart[offset + (i * sizeof(hash))]); } return hash;