00001 /* 00002 * 00003 * Copyright (C) 1994-2010, OFFIS e.V. 00004 * All rights reserved. See COPYRIGHT file for details. 00005 * 00006 * This software and supporting documentation were developed by 00007 * 00008 * OFFIS e.V. 00009 * R&D Division Health 00010 * Escherweg 2 00011 * D-26121 Oldenburg, Germany 00012 * 00013 * 00014 * Module: dcmdata 00015 * 00016 * Author: Andreas Barth 00017 * 00018 * Purpose: byte order functions 00019 * 00020 * Last Update: $Author: joergr $ 00021 * Update Date: $Date: 2010-10-14 13:15:42 $ 00022 * CVS/RCS Revision: $Revision: 1.19 $ 00023 * Status: $State: Exp $ 00024 * 00025 * CVS/RCS Log at end of file 00026 * 00027 */ 00028 00029 #ifndef DCSWAP_H 00030 #define DCSWAP_H 00031 00032 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00033 #include "dcmtk/dcmdata/dcerror.h" 00034 #include "dcmtk/dcmdata/dcxfer.h" /* for E_ByteOrder */ 00035 00044 OFCondition swapIfNecessary( 00045 const E_ByteOrder newByteOrder, 00046 const E_ByteOrder oldByteOrder, 00047 void * value, 00048 const Uint32 byteLength, 00049 const size_t valWidth); 00050 00056 void swapBytes( 00057 void * value, 00058 const Uint32 byteLength, 00059 const size_t valWidth); 00060 00065 Uint16 swapShort(const Uint16 toSwap); 00066 00070 inline void swap2Bytes(Uint8 * toSwap) 00071 // swaps [byte0][byte1] to [byte1][byte0] 00072 { 00073 Uint8 tmp = toSwap[0]; 00074 toSwap[0] = toSwap[1]; 00075 toSwap[1] = tmp; 00076 } 00077 00081 inline void swap4Bytes(Uint8 * toSwap) 00082 // swaps [byte0][byte1][byte2][byte3] to [byte3][byte2][byte1][byte0] 00083 { 00084 Uint8 tmp = toSwap[0]; 00085 toSwap[0] = toSwap[3]; 00086 toSwap[3] = tmp; 00087 tmp = toSwap[1]; 00088 toSwap[1] = toSwap[2]; 00089 toSwap[2] = tmp; 00090 } 00091 00092 #endif // DCSWAP_H 00093 00094 /* 00095 * CVS/RCS Log: 00096 * $Log: dcswap.h,v $ 00097 * Revision 1.19 2010-10-14 13:15:42 joergr 00098 * Updated copyright header. Added reference to COPYRIGHT file. 00099 * 00100 * Revision 1.18 2010-03-01 09:08:44 uli 00101 * Removed some unnecessary include directives in the headers. 00102 * 00103 * Revision 1.17 2009-11-04 09:58:07 uli 00104 * Switched to logging mechanism provided by the "new" oflog module 00105 * 00106 * Revision 1.16 2007-11-29 14:30:35 meichel 00107 * Updated doxygen API documentation 00108 * 00109 * Revision 1.15 2005/12/08 16:28:43 meichel 00110 * Changed include path schema for all DCMTK header files 00111 * 00112 * Revision 1.14 2002/11/27 12:07:23 meichel 00113 * Adapted module dcmdata to use of new header file ofstdinc.h 00114 * 00115 * Revision 1.13 2001/11/01 14:41:43 wilkens 00116 * Added lots of comments. 00117 * 00118 * Revision 1.12 2001/09/25 17:19:29 meichel 00119 * Adapted dcmdata to class OFCondition 00120 * 00121 * Revision 1.11 2001/06/01 15:48:44 meichel 00122 * Updated copyright header 00123 * 00124 * Revision 1.10 2000/03/08 16:26:18 meichel 00125 * Updated copyright header. 00126 * 00127 * Revision 1.9 2000/02/23 15:11:39 meichel 00128 * Corrected macro for Borland C++ Builder 4 workaround. 00129 * 00130 * Revision 1.8 2000/02/01 10:12:02 meichel 00131 * Avoiding to include <stdlib.h> as extern "C" on Borland C++ Builder 4, 00132 * workaround for bug in compiler header files. 00133 * 00134 * Revision 1.7 1999/06/10 10:44:50 meichel 00135 * Replaced some #if statements by more robust #ifdef 00136 * 00137 * Revision 1.6 1999/03/31 09:24:48 meichel 00138 * Updated copyright header in module dcmdata 00139 * 00140 * 00141 */