- * \brief Searches within Header Entries (Dicom Elements) parsed with
- * the public and private dictionaries
- * for the element value representation of a given tag.
- * @param group Group number of the searched tag.
- * @param element Element number of the searched tag.
- * @return Corresponding element value representation when it exists,
- * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string Document::GetEntry(uint16_t group, uint16_t element)
-{
- TagKey key = DictEntry::TranslateToKey(group, element);
- if ( !TagHT.count(key))
- {
- return GDCM_UNFOUND;
- }
-
- return ((ValEntry *)TagHT.find(key)->second)->GetValue();
-}
-
-/**
- * \brief Searches within Header Entries (Dicom Elements) parsed with
- * the public and private dictionaries
- * for the element value representation of a given tag..
- *
- * Obtaining the VR (Value Representation) might be needed by caller
- * to convert the string typed content to caller's native type
- * (think of C++ vs Python). The VR is actually of a higher level
- * of semantics than just the native C++ type.
- * @param group Group number of the searched tag.
- * @param element Element number of the searched tag.
- * @return Corresponding element value representation when it exists,
- * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string Document::GetEntryVR(uint16_t group, uint16_t element)
-{
- DocEntry *elem = GetDocEntry(group, element);
- if ( !elem )
- {
- return GDCM_UNFOUND;
- }
- return elem->GetVR();
-}
-
-/**
- * \brief Searches within Header Entries (Dicom Elements) parsed with
- * the public and private dictionaries
- * for the value length of a given tag..
- * @param group Group number of the searched tag.
- * @param element Element number of the searched tag.
- * @return Corresponding element length; -2 if not found
- */
-int Document::GetEntryLength(uint16_t group, uint16_t element)
-{
- DocEntry *elem = GetDocEntry(group, element);
- if ( !elem )
- {
- return -2; //magic number
- }
- return elem->GetLength();
-}
-
-/**
- * \brief Accesses an existing DocEntry (i.e. a Dicom Element)
- * through it's (group, element) and modifies it's content with
- * the given value.
- * @param content new value (string) to substitute with
- * @param group group number of the Dicom Element to modify
- * @param element element number of the Dicom Element to modify
- */
-bool Document::SetEntry(std::string const& content,
- uint16_t group, uint16_t element)
-{
- ValEntry *entry = GetValEntry(group, element);
- if (!entry )
- {
- gdcmVerboseMacro( "No corresponding ValEntry (try promotion first).");
- return false;
- }
- return SetEntry(content,entry);
-}
-
-/**
- * \brief Accesses an existing DocEntry (i.e. a Dicom Element)
- * through it's (group, element) and modifies it's content with
- * the given value.
- * @param content new value (void* -> uint8_t*) to substitute with
- * @param lgth new value length
- * @param group group number of the Dicom Element to modify
- * @param element element number of the Dicom Element to modify
- */
-bool Document::SetEntry(uint8_t*content, int lgth,
- uint16_t group, uint16_t element)
-{
- BinEntry *entry = GetBinEntry(group, element);
- if (!entry )
- {
- gdcmVerboseMacro( "No corresponding ValEntry (try promotion first).");
- return false;
- }
-
- return SetEntry(content,lgth,entry);
-}
-
-/**
- * \brief Accesses an existing DocEntry (i.e. a Dicom Element)
- * and modifies it's content with the given value.
- * @param content new value (string) to substitute with
- * @param entry Entry to be modified
- */
-bool Document::SetEntry(std::string const &content,ValEntry *entry)
-{
- if(entry)
- {
- entry->SetValue(content);
- return true;
- }
- return false;
-}
-
-/**
- * \brief Accesses an existing BinEntry (i.e. a Dicom Element)
- * and modifies it's content with the given value.
- * @param content new value (void* -> uint8_t*) to substitute with
- * @param entry Entry to be modified
- * @param lgth new value length
- */
-bool Document::SetEntry(uint8_t *content, int lgth, BinEntry *entry)
-{
- if(entry)
- {
- // Hope Binary field length is *never* wrong
- /*if(lgth%2) // Non even length are padded with a space (020H).
- {
- lgth++;
- //content = content + '\0'; // fing a trick to enlarge a binary field?
- }*/
-
- entry->SetBinArea(content);
- entry->SetLength(lgth);
- entry->SetValue(GDCM_BINLOADED);
- return true;
- }
- return false;
-}
-
-/**
- * \brief Gets (from Header) a 'non string' element value
- * (LoadElementValues has already be executed)
- * @param group group number of the Entry
- * @param elem element number of the Entry
- * @return Pointer to the 'non string' area
- */
-void *Document::GetEntryBinArea(uint16_t group, uint16_t elem)
-{
- DocEntry *entry = GetDocEntry(group, elem);
- if (!entry)
- {
- gdcmVerboseMacro( "No entry");
- return 0;
- }
- if ( BinEntry *binEntry = dynamic_cast<BinEntry*>(entry) )
- {
- return binEntry->GetBinArea();
- }
-
- return 0;
-}
-
-/**
- * \brief Loads (from disk) the element content
- * when a string is not suitable
- * @param group group number of the Entry
- * @param elem element number of the Entry
- */
-void Document::LoadEntryBinArea(uint16_t group, uint16_t elem)
-{
- // Search the corresponding DocEntry
- DocEntry *docElement = GetDocEntry(group, elem);
- if ( !docElement )
- return;
-
- BinEntry *binElement = dynamic_cast<BinEntry *>(docElement);
- if( !binElement )
- return;
-
- LoadEntryBinArea(binElement);
-}
-
-/**
- * \brief Loads (from disk) the element content
- * when a string is not suitable
- * @param element Entry whose binArea is going to be loaded