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 =========================================================================*/
26 #ifndef vtkByteSwap_h
27 #define vtkByteSwap_h
28 
29 #include "vtkCommonCoreModule.h" // For export macro
30 #include "vtkObject.h"
31 
33 {
34 public:
35  static vtkByteSwap *New();
36  vtkTypeMacro(vtkByteSwap,vtkObject);
37 
38  //BTX
40 
43 #define VTK_BYTE_SWAP_DECL(T) \
44  static void SwapLE(T* p); \
45  static void SwapBE(T* p); \
46  static void SwapLERange(T* p, size_t num); \
47  static void SwapBERange(T* p, size_t num); \
48  static bool SwapLERangeWrite(const T* p, size_t num, FILE* file); \
49  static bool SwapBERangeWrite(const T* p, size_t num, FILE* file); \
50  static void SwapLERangeWrite(const T* p, size_t num, ostream* os); \
51  static void SwapBERangeWrite(const T* p, size_t num, ostream* os)
52  VTK_BYTE_SWAP_DECL(float);
53  VTK_BYTE_SWAP_DECL(double);
54  VTK_BYTE_SWAP_DECL(char);
55  VTK_BYTE_SWAP_DECL(short);
56  VTK_BYTE_SWAP_DECL(int);
57  VTK_BYTE_SWAP_DECL(long);
58  VTK_BYTE_SWAP_DECL(long long);
59  VTK_BYTE_SWAP_DECL(signed char);
60  VTK_BYTE_SWAP_DECL(unsigned char);
61  VTK_BYTE_SWAP_DECL(unsigned short);
62  VTK_BYTE_SWAP_DECL(unsigned int);
63  VTK_BYTE_SWAP_DECL(unsigned long);
64  VTK_BYTE_SWAP_DECL(unsigned long long);
65 #undef VTK_BYTE_SWAP_DECL
66  //ETX
68 
70 
71  static void Swap2LE(void* p);
72  static void Swap4LE(void* p);
73  static void Swap8LE(void* p);
75 
77 
79  static void Swap2LERange(void* p, size_t num);
80  static void Swap4LERange(void* p, size_t num);
81  static void Swap8LERange(void* p, size_t num);
83 
85 
88  static bool SwapWrite2LERange(void const* p, size_t num, FILE* f);
89  static bool SwapWrite4LERange(void const* p, size_t num, FILE* f);
90  static bool SwapWrite8LERange(void const* p, size_t num, FILE* f);
91  static void SwapWrite2LERange(void const* p, size_t num, ostream* os);
92  static void SwapWrite4LERange(void const* p, size_t num, ostream* os);
93  static void SwapWrite8LERange(void const* p, size_t num, ostream* os);
95 
97 
98  static void Swap2BE(void* p);
99  static void Swap4BE(void* p);
100  static void Swap8BE(void* p);
102 
104 
105  static void Swap2BERange(void* p, size_t num);
106  static void Swap4BERange(void* p, size_t num);
107  static void Swap8BERange(void* p, size_t num);
109 
111 
114  static bool SwapWrite2BERange(void const* p, size_t num, FILE* f);
115  static bool SwapWrite4BERange(void const* p, size_t num, FILE* f);
116  static bool SwapWrite8BERange(void const* p, size_t num, FILE* f);
117  static void SwapWrite2BERange(void const* p, size_t num, ostream* os);
118  static void SwapWrite4BERange(void const* p, size_t num, ostream* os);
119  static void SwapWrite8BERange(void const* p, size_t num, ostream* os);
121 
124  static void SwapVoidRange(void *buffer, size_t numWords, size_t wordSize);
125 
126 protected:
127  vtkByteSwap();
128  ~vtkByteSwap();
129 
130 private:
131  vtkByteSwap(const vtkByteSwap&); // Not implemented.
132  void operator=(const vtkByteSwap&); // Not implemented.
133 };
134 
135 #endif
136 // VTK-HeaderTest-Exclude: vtkByteSwap.h
abstract base class for most VTK objects
Definition: vtkObject.h:61
#define VTKCOMMONCORE_EXPORT
#define VTK_BYTE_SWAP_DECL(T)
Definition: vtkByteSwap.h:43
perform machine dependent byte swapping
Definition: vtkByteSwap.h:32
static vtkObject * New()