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(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 #if defined(VTK_TYPE_USE_LONG_LONG)
64  VTK_BYTE_SWAP_DECL(long long);
65  VTK_BYTE_SWAP_DECL(unsigned long long);
66 #endif
67 #if defined(VTK_TYPE_USE___INT64)
68  VTK_BYTE_SWAP_DECL(__int64);
69  VTK_BYTE_SWAP_DECL(unsigned __int64);
70 #endif
71 #undef VTK_BYTE_SWAP_DECL
72  //ETX
74 
76 
77  static void Swap2LE(void* p);
78  static void Swap4LE(void* p);
79  static void Swap8LE(void* p);
81 
83 
85  static void Swap2LERange(void* p, size_t num);
86  static void Swap4LERange(void* p, size_t num);
87  static void Swap8LERange(void* p, size_t num);
89 
91 
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 
104  static void Swap2BE(void* p);
105  static void Swap4BE(void* p);
106  static void Swap8BE(void* p);
108 
110 
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 
120  static bool SwapWrite2BERange(void const* p, size_t num, FILE* f);
121  static bool SwapWrite4BERange(void const* p, size_t num, FILE* f);
122  static bool SwapWrite8BERange(void const* p, size_t num, FILE* f);
123  static void SwapWrite2BERange(void const* p, size_t num, ostream* os);
124  static void SwapWrite4BERange(void const* p, size_t num, ostream* os);
125  static void SwapWrite8BERange(void const* p, size_t num, ostream* os);
127 
130  static void SwapVoidRange(void *buffer, size_t numWords, size_t wordSize);
131 
132 protected:
133  vtkByteSwap();
134  ~vtkByteSwap();
135 
136 private:
137  vtkByteSwap(const vtkByteSwap&); // Not implemented.
138  void operator=(const vtkByteSwap&); // Not implemented.
139 };
140 
141 #endif
142 // 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()