AAX SDK 2.6.1
Avid Audio Extensions Development Kit
Loading...
Searching...
No Matches
AAX_EndianSwap.h
Go to the documentation of this file.
1/*================================================================================================*/
2/*
3 *
4 * Copyright 2013-2015, 2023 Avid Technology, Inc.
5 * All rights reserved.
6 *
7 * CONFIDENTIAL: this document contains confidential information of Avid. Do
8 * not disclose to any third party. Use of the information contained in this
9 * document is subject to an Avid SDK license.
10 *
11 */
12
19/*================================================================================================*/
20
21
22#pragma once
23
24#ifndef ENDIANSWAP_H
25#define ENDIANSWAP_H
26
27// Standard headers
28#include <algorithm>
29
31template<class T> void AAX_EndianSwapInPlace(T* theDataP);
32
34template<class T> T AAX_EndianSwap(T theData);
35
36
38template<class T> void AAX_BigEndianNativeSwapInPlace(T* theDataP);
39
41template<class T> T AAX_BigEndianNativeSwap(T theData);
42
44template<class T> void AAX_LittleEndianNativeSwapInPlace(T* theDataP);
45
47template<class T> T AAX_LittleEndianNativeSwap(T theData);
48
49
50
52template<class Iter> void AAX_EndianSwapSequenceInPlace(Iter beginI, Iter endI);
53
54
56template<class Iter> void AAX_BigEndianNativeSwapSequenceInPlace(Iter beginI, Iter endI);
57
59template<class Iter> void AAX_LittleEndianNativeSwapSequenceInPlace(Iter beginI, Iter endI);
60
61
62//
63// Implementations
64//
65
66template<class T>
67inline
68void
70{
71 char *begin, *end;
72
73 begin = reinterpret_cast<char*>(theDataP);
74 end = begin + sizeof( T );
75 std::reverse( begin, end );
76}
77
78
79template<class T>
80inline
81T AAX_EndianSwap(T theData)
82{
83 AAX_EndianSwapInPlace(&theData);
84 return theData;
85}
86
87
88template<class T>
89inline
91{
92#if (!defined __BIG_ENDIAN__) || (0 == __BIG_ENDIAN__)
93 AAX_EndianSwapInPlace(theDataP);
94#endif
95}
96
97
98template<class T>
99inline
101{
103 return theData;
104}
105
106
107template<class T>
108inline
110{
111#if (defined __BIG_ENDIAN__) && (0 != __BIG_ENDIAN__)
112 AAX_EndianSwapInPlace(theDataP);
113#endif
114}
115
116
117template<class T>
118inline
120{
122 return theData;
123}
124
125
126template<class Iter>
127inline
128void AAX_EndianSwapSequenceInPlace(Iter beginI, Iter endI)
129{
130 for(Iter i = beginI; i != endI; ++i)
131 {
132 // WARNING : Will this give a compile error if a use mistakenly uses it on a const sequence?
134 };
135}
136
137
138template<class Iter>
139inline
140void AAX_BigEndianNativeSwapSequenceInPlace(Iter beginI, Iter endI)
141{
142#if (!defined __BIG_ENDIAN__) || (0 == __BIG_ENDIAN__)
143 AAX_EndianSwapSequenceInPlace(beginI, endI);
144#endif
145}
146
147
148template<class Iter>
149inline
151{
152#if (defined __BIG_ENDIAN__) && (0 != __BIG_ENDIAN__)
153 AAX_EndianSwapSequenceInPlace(beginI, endI);
154#endif
155}
156
157#endif
void AAX_EndianSwapInPlace(T *theDataP)
Byte swap data in-place.
Definition: AAX_EndianSwap.h:69
void AAX_BigEndianNativeSwapInPlace(T *theDataP)
Convert data in-place between Big Endian and native byte ordering.
Definition: AAX_EndianSwap.h:90
T AAX_LittleEndianNativeSwap(T theData)
Copy and convert data from the native byte ordering to Little Endian byte ordering.
Definition: AAX_EndianSwap.h:119
void AAX_LittleEndianNativeSwapSequenceInPlace(Iter beginI, Iter endI)
Convert an sequence of data in-place from the native byte ordering to Little Endian byte ordering.
Definition: AAX_EndianSwap.h:150
T AAX_EndianSwap(T theData)
Make a byte-swapped copy of data.
Definition: AAX_EndianSwap.h:81
T AAX_BigEndianNativeSwap(T theData)
Copy and convert data between Big Endian and native byte ordering.
Definition: AAX_EndianSwap.h:100
void AAX_EndianSwapSequenceInPlace(Iter beginI, Iter endI)
Byte swap a sequence of data in-place.
Definition: AAX_EndianSwap.h:128
void AAX_BigEndianNativeSwapSequenceInPlace(Iter beginI, Iter endI)
Convert an sequence of data in-place between Big Endian and native byte ordering.
Definition: AAX_EndianSwap.h:140
void AAX_LittleEndianNativeSwapInPlace(T *theDataP)
Convert data in-place from the native byte ordering to Little Endian byte ordering.
Definition: AAX_EndianSwap.h:109