]> Creatis software - gdcm.git/blobdiff - src/gdcmVRKey.h
#include <stdio.h> // for sprintf
[gdcm.git] / src / gdcmVRKey.h
index 2ef89e2aee6aae351d97048ef824fb22d78cc983..c895781bd6be3dce470a3af1b69cc73fc2dcf631 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmVRKey.h,v $
   Language:  C++
-  Date:      $Date: 2007/08/22 16:14:05 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2009/06/23 09:01:43 $
+  Version:   $Revision: 1.11 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -23,7 +23,9 @@
 
 #include <assert.h>
 #include <iomanip> // important
+#include <iostream> // important
 #include <string>
+#include <stdio.h> // for sprintf
 
 namespace GDCM_NAME_SPACE 
 {
@@ -107,6 +109,23 @@ public :
       return key[0] < _val[0] || (key[0] == _val[0] && key[1] < _val[1]);
    }
 
+   inline std::string GetHexaRepresentation()
+   {
+     // We could probabelly write something much more complicated using C++ features !
+     // (I really want HexaRepresentation as xx|xx, not ffffffxx|ffffffxx !)
+      char vr_char[6];
+      char buf[5];
+      sprintf(buf, "%04x",( unsigned short int)key[0]);
+      vr_char[0] = buf[2];
+      vr_char[1] = buf[3];      
+      sprintf(buf, "%04x",( unsigned short int)key[1]);
+      vr_char[2] = '|';
+      vr_char[3] = buf[2];            
+      vr_char[4] = buf[3];
+      vr_char[5] = '\0';
+      return(vr_char);
+   }
+   
 private :
    char key[2];
 };