- // 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;
- }
-
- valEntry = new ValEntry(currentEntry);
- delete currentEntry;
-
- if ( !AddEntry(valEntry))
- {
- delete valEntry;
- dbg.Verbose(0, "Document::ReplaceOrCreateByNumber: AddEntry"
- " failed allthough this is a creation.");
- return NULL;
- }
- }
- else
- {
- valEntry = dynamic_cast< ValEntry* >(currentEntry);
- if ( !valEntry ) // Euuuuh? It wasn't a ValEntry
- // then we change it to a ValEntry ?
- // Shouldn't it be considered as an error ?
- {
- // We need to promote the DocEntry to a ValEntry:
- valEntry = new ValEntry(currentEntry);
- if (!RemoveEntry(currentEntry))
- {
- delete valEntry;
- dbg.Verbose(0, "Document::ReplaceOrCreateByNumber: removal"
- " of previous DocEntry failed.");
- return NULL;
- }
- if ( !AddEntry(valEntry))
- {
- delete valEntry;
- dbg.Verbose(0, "Document::ReplaceOrCreateByNumber: adding"
- " promoted ValEntry failed.");
- return NULL;
- }
- }
- }
-
- SetEntryByNumber(value, group, elem);
-
- return valEntry;
-}
-
-/*
- * \brief Modifies the value of a given Header Entry (Dicom Element)
- * when it exists. Create it with the given value when unexistant.
- * @param binArea (binary) value to be set
- * @param Group Group number of the Entry
- * @param Elem Element number of the Entry
- * \return pointer to the modified/created Header Entry (NULL when creation
- * failed).
- */
-BinEntry* Document::ReplaceOrCreateByNumber(
- uint8_t* binArea,
- int lgth,
- uint16_t group,
- uint16_t elem,
- TagName 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( uint16_t group, uint16_t elem)
-{
- SeqEntry* b = 0;
- DocEntry* a = GetDocEntryByNumber( group, elem);
- if (!a)
- {
- a = NewSeqEntryByNumber(group, elem);
- if (!a)
- {
- return 0;
- }
-
- b = new SeqEntry(a, 1); // FIXME : 1 (Depth)
- AddEntry(b);
- }
- return b;
-}
-
-/**
- * \brief Set a new value if the invoked element exists
- * Seems to be useless !!!
- * @param value new element value
- * @param group group number of the Entry
- * @param elem element number of the Entry
- * \return boolean
- */
-bool Document::ReplaceIfExistByNumber(std::string const & value,
- uint16_t group, uint16_t elem )
-{
- SetEntryByNumber(value, group, elem);