OFFIS DCMTK  Version 3.6.0
dcswap.h
1 /*
2  *
3  * Copyright (C) 1994-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: dcmdata
15  *
16  * Author: Andreas Barth
17  *
18  * Purpose: byte order functions
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-14 13:15:42 $
22  * CVS/RCS Revision: $Revision: 1.19 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 #ifndef DCSWAP_H
30 #define DCSWAP_H
31 
32 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
33 #include "dcmtk/dcmdata/dcerror.h"
34 #include "dcmtk/dcmdata/dcxfer.h" /* for E_ByteOrder */
35 
44 OFCondition swapIfNecessary(
45  const E_ByteOrder newByteOrder,
46  const E_ByteOrder oldByteOrder,
47  void * value,
48  const Uint32 byteLength,
49  const size_t valWidth);
50 
56 void swapBytes(
57  void * value,
58  const Uint32 byteLength,
59  const size_t valWidth);
60 
65 Uint16 swapShort(const Uint16 toSwap);
66 
70 inline void swap2Bytes(Uint8 * toSwap)
71 // swaps [byte0][byte1] to [byte1][byte0]
72 {
73  Uint8 tmp = toSwap[0];
74  toSwap[0] = toSwap[1];
75  toSwap[1] = tmp;
76 }
77 
81 inline void swap4Bytes(Uint8 * toSwap)
82 // swaps [byte0][byte1][byte2][byte3] to [byte3][byte2][byte1][byte0]
83 {
84  Uint8 tmp = toSwap[0];
85  toSwap[0] = toSwap[3];
86  toSwap[3] = tmp;
87  tmp = toSwap[1];
88  toSwap[1] = toSwap[2];
89  toSwap[2] = tmp;
90 }
91 
92 #endif // DCSWAP_H
93 
94 /*
95  * CVS/RCS Log:
96  * $Log: dcswap.h,v $
97  * Revision 1.19 2010-10-14 13:15:42 joergr
98  * Updated copyright header. Added reference to COPYRIGHT file.
99  *
100  * Revision 1.18 2010-03-01 09:08:44 uli
101  * Removed some unnecessary include directives in the headers.
102  *
103  * Revision 1.17 2009-11-04 09:58:07 uli
104  * Switched to logging mechanism provided by the "new" oflog module
105  *
106  * Revision 1.16 2007-11-29 14:30:35 meichel
107  * Updated doxygen API documentation
108  *
109  * Revision 1.15 2005/12/08 16:28:43 meichel
110  * Changed include path schema for all DCMTK header files
111  *
112  * Revision 1.14 2002/11/27 12:07:23 meichel
113  * Adapted module dcmdata to use of new header file ofstdinc.h
114  *
115  * Revision 1.13 2001/11/01 14:41:43 wilkens
116  * Added lots of comments.
117  *
118  * Revision 1.12 2001/09/25 17:19:29 meichel
119  * Adapted dcmdata to class OFCondition
120  *
121  * Revision 1.11 2001/06/01 15:48:44 meichel
122  * Updated copyright header
123  *
124  * Revision 1.10 2000/03/08 16:26:18 meichel
125  * Updated copyright header.
126  *
127  * Revision 1.9 2000/02/23 15:11:39 meichel
128  * Corrected macro for Borland C++ Builder 4 workaround.
129  *
130  * Revision 1.8 2000/02/01 10:12:02 meichel
131  * Avoiding to include <stdlib.h> as extern "C" on Borland C++ Builder 4,
132  * workaround for bug in compiler header files.
133  *
134  * Revision 1.7 1999/06/10 10:44:50 meichel
135  * Replaced some #if statements by more robust #ifdef
136  *
137  * Revision 1.6 1999/03/31 09:24:48 meichel
138  * Updated copyright header in module dcmdata
139  *
140  *
141  */


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2