+#include <stdlib.h>
+
+// check *all* the dicom elements (GDCM_NAME_SPACE::DocEntry)
+// of this GDCM_NAME_SPACE::DicomDirObject
+int CompareSQItem(GDCM_NAME_SPACE::SQItem *pa1, GDCM_NAME_SPACE::SQItem *pa2 )
+{
+ GDCM_NAME_SPACE::DocEntry *e1;
+ GDCM_NAME_SPACE::DocEntry *e2;
+
+ e2 = pa2->GetFirstEntry();
+ while (!e2)
+ {
+ // locate the corresponding element in 'source' file
+ e1 = pa1->GetDocEntry( e2->GetGroup(),e2->GetElement() );
+
+ // an element doesn't exist in origin file
+ if (!e1)
+ {
+ std::cout << "DicomDir element " << std::hex
+ << e2->GetGroup() << "," <<e2->GetElement() << std::endl;
+ return 1;
+ }
+ // skip SeqEntries (I don't want to deal with 'recursion pbs' here)
+ if ( !dynamic_cast<GDCM_NAME_SPACE::DataEntry *>(e1) ||
+ !dynamic_cast<GDCM_NAME_SPACE::DataEntry *>(e2) )
+ continue;
+
+ // a value is read as GDCM_UNFOUND
+ if ( ((GDCM_NAME_SPACE::DataEntry *)e1)->GetString() == GDCM_NAME_SPACE::GDCM_UNFOUND )
+ {
+ std::cout << "for gdcm source DicomDir : element (" << std::hex
+ << e1->GetGroup() << "," <<e1->GetElement()
+ << ") has values [" << GDCM_NAME_SPACE::GDCM_UNFOUND << "]"
+ << std::endl;
+ return 1;
+ }
+
+ // values differ in source file and destination file
+ if ( ((GDCM_NAME_SPACE::DataEntry *)e1)->GetString() !=
+ ((GDCM_NAME_SPACE::DataEntry *)e2)->GetString() )
+ {
+
+ /// \todo : check the value *written on disc*, not the value converted as a std::string
+ /// (this comparison doesn't make the difference between Ox(ff) and "255" ...)
+
+ // serious trouble : values differ in source and destination file
+ std::cout << "for gdcm DicomDir element (" << std::hex
+ << e2->GetGroup() << "," <<e2->GetElement()
+ << ") values differ ["
+ << ((GDCM_NAME_SPACE::DataEntry *)e1)->GetString() << "] != ["
+ << ((GDCM_NAME_SPACE::DataEntry *)e2)->GetString() << "]"
+ << std::endl;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int TestDicomDir(int argc, char *argv[])