]> Creatis software - gdcm.git/blobdiff - src/gdcmDocEntrySet.cxx
STYLE: Cleanup
[gdcm.git] / src / gdcmDocEntrySet.cxx
index 19b7d39d15e54d2e2a1eb1ebbe551642e6bc37d6..a054d86e7f990360c22b91aa1d123403f9bdb4fc 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntrySet.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/06/24 10:55:59 $
-  Version:   $Revision: 1.57 $
+  Date:      $Date: 2005/09/06 15:28:49 $
+  Version:   $Revision: 1.59 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include "gdcmSeqEntry.h"
 #include "gdcmValEntry.h"
 #include "gdcmBinEntry.h"
+#include "gdcmUtil.h"
 
 namespace gdcm 
 {
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
-
+DocEntrySet::DocEntrySet() 
+{ 
+   PreviousDocEntry = 0;
+}
 //-----------------------------------------------------------------------------
 // Public
 /**
@@ -38,7 +42,7 @@ namespace gdcm
  * @param   group  Group number of the searched tag.
  * @param   elem Element number of the searched tag.
  * @return  Corresponding element value when it exists,
- *          and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
+ *          and the string GDCM_UNFOUND otherwise.
  */
 std::string DocEntrySet::GetEntryValue(uint16_t group, uint16_t elem)
 {
@@ -62,6 +66,34 @@ void *DocEntrySet::GetEntryBinArea(uint16_t group, uint16_t elem)
    return 0;
 }
 
+/**
+ * \brief   Return the value of the BinEntry if it's "std::string representable"
+ * @param   group  Group number of the searched tag.
+ * @param   elem Element number of the searched tag.
+ * @return  Corresponding element value when it's "std::string representable"
+ *          and the string GDCM_NOTASCII otherwise.
+ */
+std::string DocEntrySet::GetEntryForcedAsciiValue(uint16_t group, uint16_t elem)
+{
+   DocEntry *d = GetDocEntry(group,elem);
+   if ( !d )
+      return GDCM_UNFOUND;
+
+   if (ValEntry *v = dynamic_cast<ValEntry *>(d))
+      return v->GetValue();
+
+   if (BinEntry *b = dynamic_cast<BinEntry *>(d))
+   {
+      uint8_t *a = b->GetBinArea();
+      if (!b)
+         return GDCM_NOTLOADED;
+         // TODO : unify those two methods.
+      if (Util::IsCleanArea(a, b->GetLength()) )
+         return  Util::CreateCleanString(a, b->GetLength());
+   }
+   return GDCM_NOTASCII;
+}
+
 /**
  * \brief   Searches within Header Entries (Dicom Elements) parsed with 
  *          the public and private dictionaries