summaryrefslogtreecommitdiff
path: root/Runtime/Serialize/SwapEndianArray.h
blob: 2fbf30f2b1554a5b172bce1a99b9b2fea5f28f49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef SWAPENDIANARRAY_H
#define SWAPENDIANARRAY_H

#include "SwapEndianBytes.h"

inline void SwapEndianArray (void* data, int bytesPerComponent, int count)
{
	
	if (bytesPerComponent == 2)
	{
		UInt16* p = (UInt16*)data;
		for (int i=0;i<count;i++)
			SwapEndianBytes (*p++);
	}	
	else if (bytesPerComponent == 4)
	{
		UInt32* p = (UInt32*)data;
		for (int i=0;i<count;i++)
			SwapEndianBytes (*p++);
	}
	else
	{
		AssertIf (bytesPerComponent != 1);
	}
}

#endif