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 "vtkObject.h"
30 
32 {
33 public:
34  static vtkByteSwap *New();
35  vtkTypeMacro(vtkByteSwap,vtkObject);
36 
37  //BTX
39 
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, vtkIdType num); \
46  static void SwapBERange(T* p, vtkIdType num); \
47  static bool SwapLERangeWrite(const T* p, vtkIdType num, FILE* file); \
48  static bool SwapBERangeWrite(const T* p, vtkIdType num, FILE* file); \
49  static void SwapLERangeWrite(const T* p, vtkIdType num, ostream* os); \
50  static void SwapBERangeWrite(const T* p, vtkIdType 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(signed char);
58  VTK_BYTE_SWAP_DECL(unsigned char);
59  VTK_BYTE_SWAP_DECL(unsigned short);
60  VTK_BYTE_SWAP_DECL(unsigned int);
61  VTK_BYTE_SWAP_DECL(unsigned long);
62 #if defined(VTK_DECL_USE_LONG_LONG)
63  VTK_BYTE_SWAP_DECL(long long);
64  VTK_BYTE_SWAP_DECL(unsigned long long);
65 #endif
66 #if defined(VTK_DECL_USE___INT64)
67  VTK_BYTE_SWAP_DECL(__int64);
68  VTK_BYTE_SWAP_DECL(unsigned __int64);
69 #endif
70 #undef VTK_BYTE_SWAP_DECL
71  //ETX
73 
75 
76  static void Swap2LE(void* p);
77  static void Swap4LE(void* p);
78  static void Swap8LE(void* p);
80 
82 
84  static void Swap2LERange(void* p, int num);
85  static void Swap4LERange(void* p, int num);
86  static void Swap8LERange(void* p, int num);
88 
90 
93  static bool SwapWrite2LERange(const void* p, int num, FILE* f);
94  static bool SwapWrite4LERange(const void* p, int num, FILE* f);
95  static bool SwapWrite8LERange(const void* p, int num, FILE* f);
96  static void SwapWrite2LERange(const void* p, int num, ostream* os);
97  static void SwapWrite4LERange(const void* p, int num, ostream* os);
98  static void SwapWrite8LERange(const void* p, int num, ostream* os);
100 
102 
103  static void Swap2BE(void* p);
104  static void Swap4BE(void* p);
105  static void Swap8BE(void* p);
107 
109 
110  static void Swap2BERange(void* p, int num);
111  static void Swap4BERange(void* p, int num);
112  static void Swap8BERange(void* p, int num);
114 
116 
119  static bool SwapWrite2BERange(const void* p, int num, FILE* f);
120  static bool SwapWrite4BERange(const void* p, int num, FILE* f);
121  static bool SwapWrite8BERange(const void* p, int num, FILE* f);
122  static void SwapWrite2BERange(const void* p, int num, ostream* os);
123  static void SwapWrite4BERange(const void* p, int num, ostream* os);
124  static void SwapWrite8BERange(const void* p, int num, ostream* os);
126 
129  static void SwapVoidRange(void *buffer, int numWords, int wordSize);
130 
131 protected:
132  vtkByteSwap();
133  ~vtkByteSwap();
134 
135 private:
136  vtkByteSwap(const vtkByteSwap&); // Not implemented.
137  void operator=(const vtkByteSwap&); // Not implemented.
138 };
139 
140 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:60
#define VTK_BYTE_SWAP_DECL(T)
Definition: vtkByteSwap.h:42
perform machine dependent byte swapping
Definition: vtkByteSwap.h:31
#define VTK_COMMON_EXPORT
static vtkObject * New()