From 9e5eb5382be97f7a0d86a93e1cf8aa247477bb29 Mon Sep 17 00:00:00 2001 From: jpr Date: Wed, 5 Jan 2005 15:19:42 +0000 Subject: [PATCH] ADD : Add the method IsCurrentProcessorBigEndian (we'll need it for 'Explicit VR Big Endian' Transfert Syntax) --- src/gdcmUtil.cxx | 23 +++++++++++++++++++++-- src/gdcmUtil.h | 5 +++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/gdcmUtil.cxx b/src/gdcmUtil.cxx index 05ab21a5..948fd2cc 100644 --- a/src/gdcmUtil.cxx +++ b/src/gdcmUtil.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmUtil.cxx,v $ Language: C++ - Date: $Date: 2004/12/13 15:12:33 $ - Version: $Revision: 1.70 $ + Date: $Date: 2005/01/05 15:19:42 $ + Version: $Revision: 1.71 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -290,6 +290,25 @@ bool Util::DicomStringEqual(const std::string& s1, const char *s2) return s1_even == s2_even; } + + +/** + * \ingroup Util + * \brief tells us if the processor we are working with is BigEndian or not + */ +bool Util::IsCurrentProcessorBigEndian() +{ + uint16_t intVal = 1; + uint8_t bigEndianRepr[4] = { 0x00, 0x00, 0x00, 0x01 }; + int res = memcmp(reinterpret_cast(&intVal), + reinterpret_cast(bigEndianRepr), 4); + if (res == 0) + return true; + else + return false; +} + + /** * \ingroup Util * \brief Return the IP adress of the machine writting the DICOM image diff --git a/src/gdcmUtil.h b/src/gdcmUtil.h index 6893f4d2..85013ce4 100644 --- a/src/gdcmUtil.h +++ b/src/gdcmUtil.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmUtil.h,v $ Language: C++ - Date: $Date: 2004/11/16 05:03:35 $ - Version: $Revision: 1.45 $ + Date: $Date: 2005/01/05 15:19:42 $ + Version: $Revision: 1.46 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -55,6 +55,7 @@ public: static std::string DicomString(const char* s); static bool DicomStringEqual(const std::string& s1, const char *s2); static std::string CreateUniqueUID(const std::string& root = ""); + static bool IsCurrentProcessorBigEndian(); private: static std::string GetIPAddress(); //Do not expose this method -- 2.45.1