+ }
+
+ // an Item Starter found elsewhere but the first position
+ // of a SeqEntry means previous entry was a Sequence
+ // but we didn't get it (private Sequence + Implicit VR)
+ // we have to backtrack.
+ if ( !first && newDocEntry->IsItemStarter() )
+ {
+ newDocEntry = Backtrack(newDocEntry);
+ }
+ else
+ {
+ PreviousDocEntry = newDocEntry;
+ }
+
+ used = true;
+ newValEntry = dynamic_cast<ValEntry*>(newDocEntry);
+ newBinEntry = dynamic_cast<BinEntry*>(newDocEntry);
+
+ if ( newValEntry || newBinEntry )
+ {
+ //////////////////////////// ContentEntry
+ if ( newBinEntry )
+ {
+ vr = newDocEntry->GetVR();
+ if ( Filetype == ExplicitVR &&
+ !Global::GetVR()->IsVROfBinaryRepresentable(vr) )
+ {
+ ////// Neither ValEntry NOR BinEntry: should mean UNKOWN VR
+ gdcmWarningMacro( std::hex << newDocEntry->GetGroup()
+ << "|" << newDocEntry->GetElement()
+ << " : Neither Valentry, nor BinEntry."
+ "Probably unknown VR.");
+ }
+
+ //////////////////// BinEntry or UNKOWN VR:
+
+ // When "this" is a Document the Key is simply of the
+ // form ( group, elem )...
+ //if ( set == this ) // ( dynamic_cast< Document* > ( set ) )
+ //{
+ // newBinEntry->SetKey( newBinEntry->GetKey() );
+ //}
+ // but when "this" is a SQItem, we are inserting this new
+ // valEntry in a sequence item, and the key has the
+ // generalized form (refer to \ref BaseTagKey):
+
+ // time waste hunting
+ //if (SQItem *parentSQItem = dynamic_cast< SQItem* > ( set ) )
+ //{
+ // newBinEntry->SetKey( parentSQItem->GetBaseTagKey()
+ // + newBinEntry->GetKey() );
+ //}
+
+ if ( !set->AddEntry( newBinEntry ) )
+ {
+ gdcmWarningMacro( "in ParseDES : cannot add a BinEntry "
+ << newBinEntry->GetKey()
+ << " (at offset : "
+ << newBinEntry->GetOffset() << " )" );
+ used=false;
+ }
+ else
+ {
+ // Load only if we can add (not a duplicate key)
+ LoadDocEntry( newBinEntry );
+ }
+ } // end BinEntry
+ else
+ {
+ /////////////////////// ValEntry
+
+ // When "set" is a Document, then we are at the top of the
+ // hierarchy and the Key is simply of the form ( group, elem )...
+ //if ( set == this ) // ( dynamic_cast< Document* > ( set ) )
+ //{
+ // newValEntry->SetKey( newValEntry->GetKey() );
+ //}
+ // ...but when "set" is a SQItem, we are inserting this new
+ // valEntry in a sequence item. Hence the key has the
+ // generalized form (refer to \ref BaseTagKey):
+
+ // time waste hunting
+ //if (SQItem *parentSQItem = dynamic_cast< SQItem* > ( set ) )
+ //{
+ // newValEntry->SetKey( parentSQItem->GetBaseTagKey()
+ // + newValEntry->GetKey() );
+ //}
+
+ if ( !set->AddEntry( newValEntry ) )
+ {
+ gdcmWarningMacro( "in ParseDES : cannot add a ValEntry "
+ << newValEntry->GetKey()
+ << " (at offset : "
+ << newValEntry->GetOffset() << " )" );
+ used=false;
+ }
+ else
+ {
+ // Load only if we can add (not a duplicate key)
+ LoadDocEntry( newValEntry );
+ }
+
+ if ( newValEntry->GetElement() == 0x0000 ) // if on group length
+ {
+ if ( newValEntry->GetGroup()%2 != 0 ) // if Shadow Group
+ {
+ if ( LoadMode & LD_NOSHADOW ) // if user asked to skip shad.gr
+ {
+ std::string strLgrGroup = newValEntry->GetValue();
+ int lgrGroup;
+ if ( strLgrGroup != GDCM_UNFOUND)
+ {
+ lgrGroup = atoi(strLgrGroup.c_str());
+ Fp->seekg(lgrGroup, std::ios::cur);
+ //used = false; // never used
+ RemoveEntry( newDocEntry ); // Remove and delete
+ // bcc 5.5 is right "assigned a value that's never used"
+ // newDocEntry = 0;
+ continue;
+ }
+ }
+ }
+ }
+
+ bool delimitor = newValEntry->IsItemDelimitor();
+
+ if ( (delimitor) ||
+ (!delim_mode && ((long)(Fp->tellg())-offset) >= l_max) )
+ {
+ if ( !used )
+ delete newDocEntry;