| AAX SDK 2.6.1 Avid Audio Extensions Development Kit

- Welcome
- Manual
- Classes
- Files
- Lists
- Support

- File List
- File Members

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
31 template<class T> void AAX_EndianSwapInPlace(T* theDataP);
32
34 template<class T> T AAX_EndianSwap(T theData);
35
36
38 template<class T> void AAX_BigEndianNativeSwapInPlace(T* theDataP);
39
41 template<class T> T AAX_BigEndianNativeSwap(T theData);
42
44 template<class T> void AAX_LittleEndianNativeSwapInPlace(T* theDataP);
45
47 template<class T> T AAX_LittleEndianNativeSwap(T theData);
48
49
50
52 template<class Iter> void AAX_EndianSwapSequenceInPlace(Iter beginI, Iter endI);
53
54
56 template<class Iter> void AAX_BigEndianNativeSwapSequenceInPlace(Iter beginI, Iter endI);
57
59 template<class Iter> void AAX_LittleEndianNativeSwapSequenceInPlace(Iter beginI, Iter endI);
60
61
62//
63// Implementations
64//
65
66 template<class T>
67 inline
68 void
69 AAX_EndianSwapInPlace(T* theDataP)
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
79 template<class T>
80 inline
81T AAX_EndianSwap(T theData)
82{
83 AAX_EndianSwapInPlace(&theData);
84 return theData;
85}
86
87
88 template<class T>
89 inline
90 void AAX_BigEndianNativeSwapInPlace(T* theDataP)
91{
92#if (!defined __BIG_ENDIAN__) || (0 == __BIG_ENDIAN__)
93 AAX_EndianSwapInPlace(theDataP);
94#endif
95}
96
97
98 template<class T>
99 inline
100T AAX_BigEndianNativeSwap(T theData)
101{
102 AAX_BigEndianNativeSwapInPlace(&theData);
103 return theData;
104}
105
106
107 template<class T>
108 inline
109 void AAX_LittleEndianNativeSwapInPlace(T* theDataP)
110{
111#if (defined __BIG_ENDIAN__) && (0 != __BIG_ENDIAN__)
112 AAX_EndianSwapInPlace(theDataP);
113#endif
114}
115
116
117 template<class T>
118 inline
119T AAX_LittleEndianNativeSwap(T theData)
120{
121 AAX_LittleEndianNativeSwapInPlace(&theData);
122 return theData;
123}
124
125
126 template<class Iter>
127 inline
128 void 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?
133 AAX_EndianSwapInPlace(&(*i));
134 };
135}
136
137
138 template<class Iter>
139 inline
140 void 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
148 template<class Iter>
149 inline
150 void AAX_LittleEndianNativeSwapSequenceInPlace(Iter beginI, Iter endI)
151{
152#if (defined __BIG_ENDIAN__) && (0 != __BIG_ENDIAN__)
153 AAX_EndianSwapSequenceInPlace(beginI, endI);
154#endif
155}
156
157#endif
AAX_EndianSwapInPlace
void AAX_EndianSwapInPlace(T *theDataP)
Byte swap data in-place.
Definition: AAX_EndianSwap.h:69
AAX_BigEndianNativeSwapInPlace
void AAX_BigEndianNativeSwapInPlace(T *theDataP)
Convert data in-place between Big Endian and native byte ordering.
Definition: AAX_EndianSwap.h:90
AAX_LittleEndianNativeSwap
T AAX_LittleEndianNativeSwap(T theData)
Copy and convert data from the native byte ordering to Little Endian byte ordering.
Definition: AAX_EndianSwap.h:119
AAX_LittleEndianNativeSwapSequenceInPlace
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
AAX_EndianSwap
T AAX_EndianSwap(T theData)
Make a byte-swapped copy of data.
Definition: AAX_EndianSwap.h:81
AAX_BigEndianNativeSwap
T AAX_BigEndianNativeSwap(T theData)
Copy and convert data between Big Endian and native byte ordering.
Definition: AAX_EndianSwap.h:100
AAX_EndianSwapSequenceInPlace
void AAX_EndianSwapSequenceInPlace(Iter beginI, Iter endI)
Byte swap a sequence of data in-place.
Definition: AAX_EndianSwap.h:128
AAX_BigEndianNativeSwapSequenceInPlace
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
AAX_LittleEndianNativeSwapInPlace
void AAX_LittleEndianNativeSwapInPlace(T *theDataP)
Convert data in-place from the native byte ordering to Little Endian byte ordering.
Definition: AAX_EndianSwap.h:109