Go to the documentation of this file.
27 #ifndef _AK_BANKREADHELPERS_H_
28 #define _AK_BANKREADHELPERS_H_
32 #include <type_traits>
38 typename std::enable_if<std::is_fundamental<T>::value || std::is_enum<T>::value,
bool>::type =
true
43 typedef T __attribute__((aligned(1))) UnalignedT;
44 return *
reinterpret_cast<const UnalignedT *
>(in_pVal);
45 #elif defined(_MSC_VER) && !defined(AK_CPU_X86)
46 return *
reinterpret_cast<const T __unaligned *
>(in_pVal);
48 return *
reinterpret_cast<const T *
>(in_pVal);
54 typename std::enable_if<std::is_class<T>::value,
bool>::type =
true
58 static_assert(std::is_trivially_copyable<T>::value,
"Unaligned operations require being trivially copiable");
67 typename std::enable_if<std::is_fundamental<T>::value || std::is_enum<T>::value,
bool>::type =
true
72 #if defined(__has_warning)
73 #if __has_warning("-Walign-mismatch")
74 #define __IGNORE_RECENT_CLANG_WARNINGS
75 #pragma clang diagnostic push
76 #pragma clang diagnostic ignored "-Walign-mismatch"
80 typedef T __attribute__((aligned(1))) UnalignedT;
81 *
reinterpret_cast<UnalignedT *
>(out_pVal) = in_val;
83 #ifdef __IGNORE_RECENT_CLANG_WARNINGS
84 #undef __IGNORE_RECENT_CLANG_WARNINGS
85 #pragma clang diagnostic pop
87 #elif defined(_MSC_VER) && !defined(AK_CPU_X86)
88 *
reinterpret_cast<T __unaligned *
>(out_pVal) = in_val;
90 *
reinterpret_cast<T *
>(out_pVal) = in_val;
96 typename std::enable_if<std::is_class<T>::value,
bool>::type =
true
100 static_assert(std::is_trivially_copyable<T>::value,
"Unaligned operations require being trivially copiable");
105 template<
typename T >
113 T l_Value = ReadUnaligned<T>(in_rptr);
115 in_rptr +=
sizeof(T);
117 in_rSize -=
sizeof(T);
122 template<
typename T >
132 AkUInt8 currentByte = *in_rptr;
137 l_Value = (currentByte & 0x7F);
138 while (0x80 & currentByte)
140 currentByte = *in_rptr;
145 l_Value = l_Value << 7;
146 l_Value |= (currentByte & 0x7F);
159 char* pString = (
char *)in_rptr;
162 while (*in_rptr != 0)
184 #define READBANKDATA( _Type, _Ptr, _Size ) \
185 AK::ReadBankData<_Type>( _Ptr, _Size )
187 #define READVARIABLESIZEBANKDATA( _Type, _Ptr, _Size ) \
188 AK::ReadVariableSizeBankData<_Type>( _Ptr, _Size )
193 #define READBANKSTRING( _Ptr, _Size, _out_StringSize ) \
194 AK::ReadBankStringUtf8( _Ptr, _Size, _out_StringSize )
197 #define SKIPBANKDATA( _Type, _Ptr, _Size ) \
198 ( _Ptr ) += sizeof( _Type ); \
199 ( _Size ) -= sizeof( _Type )
202 #define SKIPBANKBYTES( _NumBytes, _Ptr, _Size ) \
203 ( _Size ) -= _NumBytes; \
204 ( _Ptr ) += _NumBytes
207 #define COPYBANKSTRING_CHAR( _Ptr, _Size, _OutPtr, _MaxOutPtrSize ) \
208 AKPLATFORM::SafeStrCpy( _OutPtr, ((const char*)_Ptr), (_MaxOutPtrSize) ); \
209 SKIPBANKBYTES( (AkUInt32)strlen((const char*)_Ptr) + 1, _Ptr, _Size )
212 #define COPYBANKSTRING_OSCHAR( _Ptr, _Size, _OutPtr, _MaxOutPtrSize ) \
213 AK_UTF8_TO_OSCHAR( _OutPtr, ((const char*)_Ptr), (_MaxOutPtrSize) ); \
214 SKIPBANKBYTES( (AkUInt32)strlen((const char*)_Ptr) + 1, _Ptr, _Size )
217 #define COPYBANKSTRING_WCHAR( _Ptr, _Size, OutPtr, _MaxOutPtrSize ) \
218 AK_CHAR_TO_UTF16( _OutPtr, ((const char*)_Ptr), (_MaxOutPtrSize) ); \
219 SKIPBANKBYTES( (AkUInt32)strlen((const char*)_Ptr) + 1, _Ptr, _Size )
225 #define READBANKDATA( _Type, _Ptr, _Size ) \
226 AK::ReadBankData<_Type>( _Ptr )
228 #define READVARIABLESIZEBANKDATA( _Type, _Ptr, _Size ) \
229 AK::ReadVariableSizeBankData<_Type>( _Ptr )
231 #define READBANKSTRING( _Ptr, _Size, _out_StringSize ) \
232 AK::ReadBankStringUtf8( _Ptr, _out_StringSize )
235 #define SKIPBANKDATA( _Type, _Ptr, _Size ) \
236 ( _Ptr ) += sizeof( _Type )
239 #define SKIPBANKBYTES( _NumBytes, _Ptr, _Size ) \
240 ( _Ptr ) += _NumBytes;
243 #define COPYBANKSTRING_CHAR( _Ptr, _Size, _OutPtr, _MaxPtrSize ) \
244 AKPLATFORM::SafeStrCpy( _OutPtr, (const char*)_Ptr, _MaxPtrSize ); \
245 SKIPBANKBYTES( (AkUInt32)strlen((const char*)_Ptr)+1, _Ptr, _Size )
248 #define COPYBANKSTRING_OSCHAR( _Ptr, _Size, _OutPtr, _MaxPtrSize ) \
249 AK_UTF8_TO_OSCHAR( _OutPtr, (const char*)_Ptr, _MaxPtrSize ); \
250 SKIPBANKBYTES( (AkUInt32)strlen((const char*)_Ptr)+1, _Ptr, _Size )
253 #define COPYBANKSTRING_WCHAR( _Ptr, _Size, OutPtr, _MaxPtrSize ) \
254 AK_CHAR_TO_UTF16( _OutPtr, (const char*)_Ptr, _MaxPtrSize ); \
255 SKIPBANKBYTES( (AkUInt32)strlen((const char*)_Ptr)+1, _Ptr, _Size )
259 #define GETBANKDATABIT( _Data, _Shift ) \
260 (((_Data) >> (_Shift)) & 0x1)
264 #define CHECKBANKDATASIZE( _DATASIZE_, _ERESULT_ ) AKASSERT( _DATASIZE_ == 0 || _ERESULT_ != AK_Success );
266 #define CHECKBANKDATASIZE(_DATASIZE_, _ERESULT_ )
269 #endif //_AK_BANKREADHELPERS_H_
void WriteUnaligned(AkUInt8 *out_pVal, const T in_val)
Definition of data structures for AkAudioObject.
uint8_t AkUInt8
Unsigned 8-bit integer.
T ReadBankData(AkUInt8 *&in_rptr)
Read data from bank and advance pointer.
T ReadVariableSizeBankData(AkUInt8 *&in_rptr)
T ReadUnaligned(const AkUInt8 *in_pVal)
AkForceInline void AkMemCpy(void *pDest, const void *pSrc, AkUInt32 uSize)
Platform Independent Helper for memcpy/memmove/memset.
uint32_t AkUInt32
Unsigned 32-bit integer.
char * ReadBankStringUtf8(AkUInt8 *&in_rptr, AkUInt32 &out_uStringSize)
Tell us about your project. We're here to help.
Register your project and we'll help you get started with no strings attached!
Get started with Wwise