+ uint16_t group,
+ uint16_t elem,
+ std::string const& VR )
+{
+ BinEntry* binEntry = 0;
+ DocEntry* currentEntry = GetDocEntryByNumber( group, elem);
+ if (!currentEntry)
+ {
+
+ // check if (group,element) DictEntry exists
+ // if it doesn't, create an entry in DictSet::VirtualEntry
+ // and use it
+
+ // Find out if the tag we received is in the dictionaries:
+ Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
+ DictEntry *dictEntry = pubDict->GetDictEntryByNumber(group, elem);
+
+ if (!dictEntry)
+ {
+ currentEntry = NewDocEntryByNumber(group, elem, VR);
+ }
+ else
+ {
+ currentEntry = NewDocEntryByNumber(group, elem);
+ }
+ if (!currentEntry)
+ {
+ dbg.Verbose(0, "Document::ReplaceOrCreateByNumber: call to"
+ " NewDocEntryByNumber failed.");
+ return NULL;
+ }
+ binEntry = new BinEntry(currentEntry);
+ if ( !AddEntry(binEntry))
+ {
+ dbg.Verbose(0, "Document::ReplaceOrCreateByNumber: AddEntry"
+ " failed allthough this is a creation.");
+ }
+ }
+ else
+ {
+ binEntry = dynamic_cast< BinEntry* >(currentEntry);
+ if ( !binEntry ) // Euuuuh? It wasn't a BinEntry
+ // then we change it to a BinEntry ?
+ // Shouldn't it be considered as an error ?
+ {
+ // We need to promote the DocEntry to a BinEntry:
+ binEntry = new BinEntry(currentEntry);
+ if (!RemoveEntry(currentEntry))
+ {
+ dbg.Verbose(0, "Document::ReplaceOrCreateByNumber: removal"
+ " of previous DocEntry failed.");
+ return NULL;
+ }
+ if ( !AddEntry(binEntry))
+ {
+ dbg.Verbose(0, "Document::ReplaceOrCreateByNumber: adding"
+ " promoted BinEntry failed.");
+ return NULL;
+ }
+ }
+ }
+
+ SetEntryByNumber(binArea, lgth, group, elem);
+
+ return binEntry;
+}
+
+
+/*
+ * \brief Modifies the value of a given Header Entry (Dicom Element)
+ * when it exists. Create it when unexistant.
+ * @param Group Group number of the Entry
+ * @param Elem Element number of the Entry
+ * \return pointer to the modified/created SeqEntry (NULL when creation
+ * failed).
+ */
+SeqEntry* Document::ReplaceOrCreateByNumber(