-/**
- * \brief Get the value of a Dicom Element inside a SQ Item Entry, by name
- * @param name : name of the searched element.
- * @return
- */
+ // Verify the currentEntry
+ if (currentEntry)
+ {
+ binEntry = dynamic_cast<BinEntry *>(currentEntry);
+
+ // Verify the VR
+ if( binEntry )
+ if( binEntry->GetVR()!=vr )
+ binEntry = NULL;
+
+ // if currentEntry doesn't correspond to the requested valEntry
+ if( !binEntry)
+ {
+ if( !RemoveEntry(currentEntry) )
+ {
+ gdcmVerboseMacro( "Removal of previous DocEntry failed.");
+
+ return NULL;
+ }
+ }
+ }
+
+ // Create a new binEntry if necessary
+ if( !binEntry)
+ {
+ binEntry = NewBinEntry(group, elem, vr);
+
+ if ( !AddEntry(binEntry) )
+ {
+ gdcmVerboseMacro( "AddEntry failed allthough this is a creation.");
+
+ delete binEntry;
+ return NULL;
+ }
+ }
+
+ // Set the binEntry value
+ uint8_t *tmpArea;
+ if( lgth>0 && binArea )
+ {
+ tmpArea = new uint8_t[lgth];
+ memcpy(tmpArea,binArea,lgth);
+ }
+ else
+ {
+ tmpArea = 0;
+ }
+ if( !SetBinEntry(tmpArea,lgth,binEntry) )
+ {
+ if( tmpArea )
+ {
+ delete[] tmpArea;
+ }
+ }
+
+ return binEntry;
+}