ITK  6.0.0
Insight Toolkit
itkByteSwapper.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18/*=========================================================================
19 *
20 * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21 *
22 * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23 *
24 * For complete copyright, license and disclaimer of warranty information
25 * please refer to the NOTICE file at the top of the ITK source tree.
26 *
27 *=========================================================================*/
28#ifndef itkByteSwapper_h
29#define itkByteSwapper_h
30
31#include "itkObject.h"
32#include "itkObjectFactory.h"
33#include "itkIntTypes.h"
34
35namespace itk
36{
49template <typename T>
50class ITK_TEMPLATE_EXPORT ByteSwapper : public Object
51{
52public:
53 ITK_DISALLOW_COPY_AND_MOVE(ByteSwapper);
54
60
62 using OStreamType = std::ostream;
63
65 itkOverrideGetNameOfClassMacro(ByteSwapper);
66
69 static constexpr bool
71 {
72 return m_SystemIsBigEndian;
73 }
74
75 static constexpr bool
77 {
78 return SystemIsBigEndian();
79 }
80 static constexpr bool
82 {
83 return !m_SystemIsBigEndian;
84 }
85
86 static constexpr bool
88 {
89 return SystemIsLittleEndian();
90 }
91
97 static void
99
103
109 static void
111
119 static void
128 static void
130
136 static void
138
146 static void
150protected:
151 ByteSwapper() = default;
152 ~ByteSwapper() override = default;
153
155 static void
156 Swap2(void * pin);
157
160 static void
161 Swap2Range(void * ptr, BufferSizeType num);
162
165 static void
166 SwapWrite2Range(const void * ptr, BufferSizeType num, OStreamType * fp);
167
169 static void
170 Swap4(void * ptr);
171
174 static void
175 Swap4Range(void * ptr, BufferSizeType num);
176
179 static void
180 SwapWrite4Range(const void * ptr, BufferSizeType num, OStreamType * fp);
181
183 static void
184 Swap8(void * ptr);
185
188 static void
189 Swap8Range(void * ptr, BufferSizeType num);
190
193 static void
194 SwapWrite8Range(const void * ptr, BufferSizeType num, OStreamType * fp);
195
196private:
199 static void
201
202 static constexpr bool m_SystemIsBigEndian{
203#ifdef CMAKE_WORDS_BIGENDIAN
204 true
205#else
206 false
207#endif
208 };
209};
210} // end namespace itk
211
212#ifndef ITK_MANUAL_INSTANTIATION
213# include "itkByteSwapper.hxx"
214#endif
215
216#endif
Perform machine dependent byte swapping.
static void SwapBytes(T &)
static constexpr bool SystemIsBE()
static void Swap4(void *ptr)
static void Swap8Range(void *ptr, BufferSizeType num)
static void Swap2(void *pin)
static constexpr bool SystemIsBigEndian()
static void SwapWrite8Range(const void *ptr, BufferSizeType num, OStreamType *fp)
std::ostream OStreamType
static constexpr bool SystemIsLE()
static void SwapRangeFromSystemToLittleEndian(T *p, BufferSizeType num)
SizeValueType BufferSizeType
static void SwapWriteRangeFromSystemToLittleEndian(const T *p, int num, OStreamType *fp)
static void Swap4Range(void *ptr, BufferSizeType num)
ByteSwapper()=default
static void SwapWriteRangeFromSystemToBigEndian(const T *p, int num, OStreamType *fp)
static void Swap2Range(void *ptr, BufferSizeType num)
~ByteSwapper() override=default
static void SwapWrite4Range(const void *ptr, BufferSizeType num, OStreamType *fp)
static constexpr bool SystemIsLittleEndian()
static void SwapFromSystemToLittleEndian(T *p)
static void SwapWrite2Range(const void *ptr, BufferSizeType num, OStreamType *fp)
static void SwapRangeFromSystemToBigEndian(T *p, BufferSizeType num)
static void SwapFromSystemToBigEndian(T *p)
static void Swap8(void *ptr)
Base class for most ITK classes.
Definition: itkObject.h:62
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:86