]> Creatis software - gdcm.git/commitdiff
ADD : Add the method IsCurrentProcessorBigEndian
authorjpr <jpr>
Wed, 5 Jan 2005 15:19:42 +0000 (15:19 +0000)
committerjpr <jpr>
Wed, 5 Jan 2005 15:19:42 +0000 (15:19 +0000)
      (we'll need it for 'Explicit VR Big Endian' Transfert Syntax)

src/gdcmUtil.cxx
src/gdcmUtil.h

index 05ab21a5d5c91b9944dc927ef16f0f7b944f50a1..948fd2cc461bbe11a73c1807014395adacb339b1 100644 (file)
@@ -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<const void*>(&intVal),
+                    reinterpret_cast<const void*>(bigEndianRepr), 4);
+   if (res == 0)
+      return true;
+   else
+      return false;
+}
+
+
 /**
  * \ingroup Util
  * \brief   Return the IP adress of the machine writting the DICOM image
index 6893f4d231cc7a121eade443f7d7c83538ee925e..85013ce43f7f0cc68831e5923d56b668594d280d 100644 (file)
@@ -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