ITK  5.2.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  * http://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 
35 namespace itk
36 {
49 template <typename T>
50 class ITK_TEMPLATE_EXPORT ByteSwapper : public Object
51 {
52 public:
53  ITK_DISALLOW_COPY_AND_MOVE(ByteSwapper);
54 
56  using Self = ByteSwapper;
57  using Superclass = Object;
60 
62  using OStreamType = std::ostream;
63 
65  itkTypeMacro(ByteSwapper, Object);
66 
68  static bool
69  SystemIsBigEndian();
70 
71  static bool
73  {
74  return SystemIsBigEndian();
75  }
76  static bool
77  SystemIsLittleEndian();
78 
79  static bool
81  {
82  return SystemIsLittleEndian();
83  }
84 
90  static void
91  SwapFromSystemToBigEndian(T * p);
92 
96 
102  static void
103  SwapRangeFromSystemToBigEndian(T * p, BufferSizeType num);
104 
112  static void
113  SwapWriteRangeFromSystemToBigEndian(T * p, int num, OStreamType * fp);
115 
121  static void
122  SwapFromSystemToLittleEndian(T * p);
123 
129  static void
130  SwapRangeFromSystemToLittleEndian(T * p, BufferSizeType num);
131 
139  static void
140  SwapWriteRangeFromSystemToLittleEndian(T * p, int num, OStreamType * fp);
142 
143 protected:
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(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(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(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
itkObjectFactory.h
itk::SmartPointer< Self >
itk::ByteSwapper::SystemIsBE
static bool SystemIsBE()
Definition: itkByteSwapper.h:72
itk::ByteSwapper::OStreamType
std::ostream OStreamType
Definition: itkByteSwapper.h:62
itk::ByteSwapper
Perform machine dependent byte swapping.
Definition: itkByteSwapper.h:50
itkIntTypes.h
itkObject.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ByteSwapper::SystemIsLE
static bool SystemIsLE()
Definition: itkByteSwapper.h:80
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itk::ByteSwapper::BufferSizeType
SizeValueType BufferSizeType
Definition: itkByteSwapper.h:95
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83