VTK  9.2.6
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 =========================================================================*/
27 #ifndef vtkByteSwap_h
28 #define vtkByteSwap_h
29 
30 #include "vtkCommonCoreModule.h" // For export macro
31 #include "vtkObject.h"
32 
33 class VTKCOMMONCORE_EXPORT vtkByteSwap : public vtkObject
34 {
35 public:
36  static vtkByteSwap* New();
37  vtkTypeMacro(vtkByteSwap, vtkObject);
38  void PrintSelf(ostream& os, vtkIndent indent) override;
39 
41 
46 #define VTK_BYTE_SWAP_DECL(T) \
47  static void SwapLE(T* p); \
48  static void SwapBE(T* p); \
49  static void SwapLERange(T* p, size_t num); \
50  static void SwapBERange(T* p, size_t num); \
51  static bool SwapLERangeWrite(const T* p, size_t num, FILE* file); \
52  static bool SwapBERangeWrite(const T* p, size_t num, FILE* file); \
53  static void SwapLERangeWrite(const T* p, size_t num, ostream* os); \
54  static void SwapBERangeWrite(const T* p, size_t num, ostream* os)
55  VTK_BYTE_SWAP_DECL(float);
56  VTK_BYTE_SWAP_DECL(double);
57  VTK_BYTE_SWAP_DECL(char);
58  VTK_BYTE_SWAP_DECL(short);
59  VTK_BYTE_SWAP_DECL(int);
60  VTK_BYTE_SWAP_DECL(long);
61  VTK_BYTE_SWAP_DECL(long long);
62  VTK_BYTE_SWAP_DECL(signed char);
63  VTK_BYTE_SWAP_DECL(unsigned char);
64  VTK_BYTE_SWAP_DECL(unsigned short);
65  VTK_BYTE_SWAP_DECL(unsigned int);
66  VTK_BYTE_SWAP_DECL(unsigned long);
67  VTK_BYTE_SWAP_DECL(unsigned long long);
68 #undef VTK_BYTE_SWAP_DECL
69 
72 
75  static void Swap2LE(void* p);
76  static void Swap4LE(void* p);
77  static void Swap8LE(void* p);
79 
81 
84  static void Swap2LERange(void* p, size_t num);
85  static void Swap4LERange(void* p, size_t num);
86  static void Swap8LERange(void* p, size_t num);
88 
90 
94  static bool SwapWrite2LERange(void const* p, size_t num, FILE* f);
95  static bool SwapWrite4LERange(void const* p, size_t num, FILE* f);
96  static bool SwapWrite8LERange(void const* p, size_t num, FILE* f);
97  static void SwapWrite2LERange(void const* p, size_t num, ostream* os);
98  static void SwapWrite4LERange(void const* p, size_t num, ostream* os);
99  static void SwapWrite8LERange(void const* p, size_t num, ostream* os);
101 
103 
106  static void Swap2BE(void* p);
107  static void Swap4BE(void* p);
108  static void Swap8BE(void* p);
110 
112 
115  static void Swap2BERange(void* p, size_t num);
116  static void Swap4BERange(void* p, size_t num);
117  static void Swap8BERange(void* p, size_t num);
119 
121 
125  static bool SwapWrite2BERange(void const* p, size_t num, FILE* f);
126  static bool SwapWrite4BERange(void const* p, size_t num, FILE* f);
127  static bool SwapWrite8BERange(void const* p, size_t num, FILE* f);
128  static void SwapWrite2BERange(void const* p, size_t num, ostream* os);
129  static void SwapWrite4BERange(void const* p, size_t num, ostream* os);
130  static void SwapWrite8BERange(void const* p, size_t num, ostream* os);
132 
137  static void SwapVoidRange(void* buffer, size_t numWords, size_t wordSize);
138 
139 protected:
140  vtkByteSwap();
141  ~vtkByteSwap() override;
142 
143 private:
144  vtkByteSwap(const vtkByteSwap&) = delete;
145  void operator=(const vtkByteSwap&) = delete;
146 };
147 
148 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:62
#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:46
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition: vtkIndent.h:39
perform machine dependent byte swapping
Definition: vtkByteSwap.h:33
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...