+ int group = (i->second)->GetGroup();
+
+ if (yetOutsideMetaElements==false && group == 0x0002)
+ insideMetaElements = true;
+
+ if (insideMetaElements == true && group != 0x0002)
+ {
+ yetOutsideMetaElements = true;
+ insideMetaElements = false;
+ }
+
+ // depending on the gdcm::Document type
+ // (gdcm::File; gdcm::DicomDir, (more to come ?)
+ // some groups *cannot* be present.
+ // We hereby protect gdcm for writting stupid things
+ // if they were found in the original document.
+ if ( !MayIWrite( group ) )
+ continue;
+
+ // Skip 'Group Length' element, since it may be wrong.
+ // except for Group 0x0002
+ // ( keep it as well for Group 0x0008 of ACR Files,
+ // since some ACR readers *need* it )
+
+ if ( (i->second)->GetElement() != 0x0000
+ ||
+ ( (i->second)->GetGroup() == 0x0002
+ ||( (filetype == ACR || filetype == ACR_LIBIDO ) && (i->second)->GetGroup() == 0x0008 ) )
+ )
+ {
+ // There are DocEntries, written recursively
+ // false : we are outside any Sequence
+ i->second->WriteContent(fp, filetype, insideMetaElements, false );
+ }
+ }
+}
+
+/**
+ * \brief add a new Dicom Element pointer to the H Table
+ * @param newEntry entry to add
+ */
+bool ElementSet::AddEntry(DocEntry *newEntry)
+{
+ const TagKey &key = newEntry->GetKey();
+
+ if ( TagHT.count(key) == 1 )
+ {
+ gdcmWarningMacro( "Key already present: " << key );
+ return false;
+ }
+ else
+ {
+ TagHT.insert(TagDocEntryHT::value_type(newEntry->GetKey(), newEntry));
+ newEntry->Register();
+ return true;
+ }
+}
+
+/**
+ * \brief Clear the hash table from given entry AND delete the entry.
+ * @param entryToRemove Entry to remove AND delete.
+ */
+bool ElementSet::RemoveEntry( DocEntry *entryToRemove)
+{
+ const TagKey &key = entryToRemove->GetKey();
+ if ( TagHT.count(key) == 1 )
+ {
+ TagHT.erase(key);
+ entryToRemove->Unregister();
+ return true;
+ }
+
+ gdcmWarningMacro( "Key not present : " << key);
+ return false ;
+}
+
+/**
+ * \brief delete all entries in the ElementSet
+ */
+void ElementSet::ClearEntry()
+{
+ for(TagDocEntryHT::iterator cc = TagHT.begin();cc != TagHT.end(); ++cc)
+ {
+ if ( cc->second )