dcswap.h

00001 /*
00002  *
00003  *  Copyright (C) 1994-2005, OFFIS
00004  *
00005  *  This software and supporting documentation were developed by
00006  *
00007  *    Kuratorium OFFIS e.V.
00008  *    Healthcare Information and Communication Systems
00009  *    Escherweg 2
00010  *    D-26121 Oldenburg, Germany
00011  *
00012  *  THIS SOFTWARE IS MADE AVAILABLE,  AS IS,  AND OFFIS MAKES NO  WARRANTY
00013  *  REGARDING  THE  SOFTWARE,  ITS  PERFORMANCE,  ITS  MERCHANTABILITY  OR
00014  *  FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES  OR
00015  *  ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND
00016  *  PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
00017  *
00018  *  Module:  dcmdata
00019  *
00020  *  Author:  Andreas Barth
00021  *
00022  *  Purpose: byte order functions
00023  *
00024  *  Last Update:      $Author: meichel $
00025  *  Update Date:      $Date: 2005/12/08 16:28:43 $
00026  *  Source File:      $Source: /share/dicom/cvs-depot/dcmtk/dcmdata/include/dcmtk/dcmdata/dcswap.h,v $
00027  *  CVS/RCS Revision: $Revision: 1.15 $
00028  *  Status:           $State: Exp $
00029  *
00030  *  CVS/RCS Log at end of file
00031  *
00032  */
00033 
00034 #ifndef DCSWAP_H
00035 #define DCSWAP_H
00036 
00037 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
00038 #include "dcmtk/dcmdata/dctypes.h"
00039 #include "dcmtk/dcmdata/dcerror.h"
00040 #include "dcmtk/dcmdata/dcxfer.h"
00041 
00042 #define INCLUDE_CSTDLIB
00043 #include "dcmtk/ofstd/ofstdinc.h"
00044 
00045 
00046 // Swap byteLength bytes, if newByteOrder != oldByteOrder. The bytes are
00047 // parted in valWidth bytes, each swapped separately
00048 OFCondition swapIfNecessary(const E_ByteOrder newByteOrder, 
00049                 const E_ByteOrder oldByteOrder,
00050                 void * value, const Uint32 byteLength,
00051                 const size_t valWidth);
00052 
00053 
00054 void swapBytes(void * value, const Uint32 byteLength, 
00055                const size_t valWidth);
00056 
00057 Uint16 swapShort(const Uint16 toSwap);
00058 
00059 inline void swap2Bytes(Uint8 * toSwap)
00060 // swaps [byte0][byte1] to [byte1][byte0]
00061 {
00062     Uint8 tmp = toSwap[0];
00063     toSwap[0] = toSwap[1];
00064     toSwap[1] = tmp;
00065 }
00066 
00067 inline void swap4Bytes(Uint8 * toSwap)
00068 // swaps [byte0][byte1][byte2][byte3] to [byte3][byte2][byte1][byte0]
00069 {
00070     Uint8 tmp = toSwap[0];
00071     toSwap[0] = toSwap[3];
00072     toSwap[3] = tmp;
00073     tmp = toSwap[1];
00074     toSwap[1] = toSwap[2];
00075     toSwap[2] = tmp;
00076 }
00077 
00078 #endif // DCSWAP_H
00079 
00080 /*
00081  * CVS/RCS Log:
00082  * $Log: dcswap.h,v $
00083  * Revision 1.15  2005/12/08 16:28:43  meichel
00084  * Changed include path schema for all DCMTK header files
00085  *
00086  * Revision 1.14  2002/11/27 12:07:23  meichel
00087  * Adapted module dcmdata to use of new header file ofstdinc.h
00088  *
00089  * Revision 1.13  2001/11/01 14:41:43  wilkens
00090  * Added lots of comments.
00091  *
00092  * Revision 1.12  2001/09/25 17:19:29  meichel
00093  * Adapted dcmdata to class OFCondition
00094  *
00095  * Revision 1.11  2001/06/01 15:48:44  meichel
00096  * Updated copyright header
00097  *
00098  * Revision 1.10  2000/03/08 16:26:18  meichel
00099  * Updated copyright header.
00100  *
00101  * Revision 1.9  2000/02/23 15:11:39  meichel
00102  * Corrected macro for Borland C++ Builder 4 workaround.
00103  *
00104  * Revision 1.8  2000/02/01 10:12:02  meichel
00105  * Avoiding to include <stdlib.h> as extern "C" on Borland C++ Builder 4,
00106  *   workaround for bug in compiler header files.
00107  *
00108  * Revision 1.7  1999/06/10 10:44:50  meichel
00109  * Replaced some #if statements by more robust #ifdef
00110  *
00111  * Revision 1.6  1999/03/31 09:24:48  meichel
00112  * Updated copyright header in module dcmdata
00113  *
00114  *
00115  */


Generated on 20 Dec 2005 for OFFIS DCMTK Version 3.5.4 by Doxygen 1.4.5