VTK
vtkByteSwap.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkByteSwap.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
24 #ifndef vtkByteSwap_h
25 #define vtkByteSwap_h
26 
27 #include "vtkCommonCoreModule.h" // For export macro
28 #include "vtkObject.h"
29 
30 class VTKCOMMONCORE_EXPORT vtkByteSwap : public vtkObject
31 {
32 public:
33  static vtkByteSwap *New();
34  vtkTypeMacro(vtkByteSwap,vtkObject);
35 
37 
42 #define VTK_BYTE_SWAP_DECL(T) \
43  static void SwapLE(T* p); \
44  static void SwapBE(T* p); \
45  static void SwapLERange(T* p, size_t num); \
46  static void SwapBERange(T* p, size_t num); \
47  static bool SwapLERangeWrite(const T* p, size_t num, FILE* file); \
48  static bool SwapBERangeWrite(const T* p, size_t num, FILE* file); \
49  static void SwapLERangeWrite(const T* p, size_t num, ostream* os); \
50  static void SwapBERangeWrite(const T* p, size_t num, ostream* os)
51  VTK_BYTE_SWAP_DECL(float);
52  VTK_BYTE_SWAP_DECL(double);
53  VTK_BYTE_SWAP_DECL(char);
54  VTK_BYTE_SWAP_DECL(short);
55  VTK_BYTE_SWAP_DECL(int);
56  VTK_BYTE_SWAP_DECL(long);
57  VTK_BYTE_SWAP_DECL(long long);
58  VTK_BYTE_SWAP_DECL(signed char);
59  VTK_BYTE_SWAP_DECL(unsigned char);
60  VTK_BYTE_SWAP_DECL(unsigned short);
61  VTK_BYTE_SWAP_DECL(unsigned int);
62  VTK_BYTE_SWAP_DECL(unsigned long);
63  VTK_BYTE_SWAP_DECL(unsigned long long);
64 #undef VTK_BYTE_SWAP_DECL
65 
66 
68 
71  static void Swap2LE(void* p);
72  static void Swap4LE(void* p);
73  static void Swap8LE(void* p);
75 
77 
80  static void Swap2LERange(void* p, size_t num);
81  static void Swap4LERange(void* p, size_t num);
82  static void Swap8LERange(void* p, size_t num);
84 
86 
90  static bool SwapWrite2LERange(void const* p, size_t num, FILE* f);
91  static bool SwapWrite4LERange(void const* p, size_t num, FILE* f);
92  static bool SwapWrite8LERange(void const* p, size_t num, FILE* f);
93  static void SwapWrite2LERange(void const* p, size_t num, ostream* os);
94  static void SwapWrite4LERange(void const* p, size_t num, ostream* os);
95  static void SwapWrite8LERange(void const* p, size_t num, ostream* os);
97 
99 
102  static void Swap2BE(void* p);
103  static void Swap4BE(void* p);
104  static void Swap8BE(void* p);
106 
108 
111  static void Swap2BERange(void* p, size_t num);
112  static void Swap4BERange(void* p, size_t num);
113  static void Swap8BERange(void* p, size_t num);
115 
117 
121  static bool SwapWrite2BERange(void const* p, size_t num, FILE* f);
122  static bool SwapWrite4BERange(void const* p, size_t num, FILE* f);
123  static bool SwapWrite8BERange(void const* p, size_t num, FILE* f);
124  static void SwapWrite2BERange(void const* p, size_t num, ostream* os);
125  static void SwapWrite4BERange(void const* p, size_t num, ostream* os);
126  static void SwapWrite8BERange(void const* p, size_t num, ostream* os);
128 
133  static void SwapVoidRange(void *buffer, size_t numWords, size_t wordSize);
134 
135 protected:
136  vtkByteSwap();
137  ~vtkByteSwap() override;
138 
139 private:
140  vtkByteSwap(const vtkByteSwap&) = delete;
141  void operator=(const vtkByteSwap&) = delete;
142 };
143 
144 #endif
145 // VTK-HeaderTest-Exclude: vtkByteSwap.h
VTK_BYTE_SWAP_DECL
#define VTK_BYTE_SWAP_DECL(T)
Type-safe swap signatures to swap for storage in either Little Endian or Big Endian format.
Definition: vtkByteSwap.h:42
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkObject.h
vtkByteSwap
perform machine dependent byte swapping
Definition: vtkByteSwap.h:30