ITK  5.4.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
68 static bool
70
71 static bool
73 {
74 return SystemIsBigEndian();
75 }
76 static bool
78
79 static bool
81 {
82 return SystemIsLittleEndian();
83 }
84
90 static void
92
96
102 static void
104
112 static void
121 static void
123
129 static void
131
139 static void
143protected:
144 ByteSwapper() = default;
145 ~ByteSwapper() override = default;
146
148 static void
149 Swap2(void * pin);
150
153 static void
154 Swap2Range(void * ptr, BufferSizeType num);
155
158 static void
159 SwapWrite2Range(const void * ptr, BufferSizeType num, OStreamType * fp);
160
162 static void
163 Swap4(void * ptr);
164
167 static void
168 Swap4Range(void * ptr, BufferSizeType num);
169
172 static void
173 SwapWrite4Range(const void * ptr, BufferSizeType num, OStreamType * fp);
174
176 static void
177 Swap8(void * ptr);
178
181 static void
182 Swap8Range(void * ptr, BufferSizeType num);
183
186 static void
187 SwapWrite8Range(const void * ptr, BufferSizeType num, OStreamType * fp);
188};
189} // end namespace itk
190
191#ifndef ITK_MANUAL_INSTANTIATION
192# include "itkByteSwapper.hxx"
193#endif
194
195#endif
Perform machine dependent byte swapping.
static void Swap4(void *ptr)
static void Swap8Range(void *ptr, BufferSizeType num)
static bool SystemIsLE()
static void Swap2(void *pin)
static bool SystemIsBE()
static void SwapWrite8Range(const void *ptr, BufferSizeType num, OStreamType *fp)
std::ostream OStreamType
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 void SwapFromSystemToLittleEndian(T *p)
static bool SystemIsLittleEndian()
static void SwapWrite2Range(const void *ptr, BufferSizeType num, OStreamType *fp)
static void SwapRangeFromSystemToBigEndian(T *p, BufferSizeType num)
static bool SystemIsBigEndian()
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:83