- return GetDocEntryByNumber(dictEntry->GetGroup(),dictEntry->GetElement());
-}
-
-/**
- * \brief retrieves a Dicom Element (the first one) using (group, element)
- * \warning (group, element) IS NOT an identifier inside the Dicom Header
- * if you think it's NOT UNIQUE, check the count number
- * and use iterators to retrieve ALL the Dicoms Elements within
- * a given couple (group, element)
- * @param group Group number of the searched Dicom Element
- * @param element Element number of the searched Dicom Element
- * @return
- */
-DocEntry* Document::GetDocEntryByNumber(uint16_t group, uint16_t element)
-{
- TagKey key = DictEntry::TranslateToKey(group, element);
- if ( !TagHT.count(key))
- {
- return NULL;
- }
- return TagHT.find(key)->second;
-}
-
-/**
- * \brief Same as \ref Document::GetDocEntryByNumber except it only
- * returns a result when the corresponding entry is of type
- * ValEntry.
- * @return When present, the corresponding ValEntry.
- */
-ValEntry* Document::GetValEntryByNumber(uint16_t group, uint16_t element)
-{
- DocEntry* currentEntry = GetDocEntryByNumber(group, element);
- if ( !currentEntry )
- {
- return 0;
- }
- if ( ValEntry* entry = dynamic_cast<ValEntry*>(currentEntry) )
- {
- return entry;
- }
- dbg.Verbose(0, "Document::GetValEntryByNumber: unfound ValEntry.");
-
- return 0;
-}
-
-/**
- * \brief Same as \ref Document::GetDocEntryByNumber except it only
- * returns a result when the corresponding entry is of type
- * BinEntry.
- * @return When present, the corresponding BinEntry.
- */
-BinEntry* Document::GetBinEntryByNumber(uint16_t group, uint16_t element)
-{
- DocEntry* currentEntry = GetDocEntryByNumber(group, element);
- if ( !currentEntry )
- {
- return 0;
- }
- if ( BinEntry* entry = dynamic_cast<BinEntry*>(currentEntry) )
- {
- return entry;
- }
- dbg.Verbose(0, "Document::GetBinEntryByNumber: unfound BinEntry.");
-
- return 0;
-}
-
-/**
- * \brief Loads the element while preserving the current
- * underlying file position indicator as opposed to
- * to LoadDocEntry that modifies it.
- * @param entry Header Entry whose value shall be loaded.
- * @return
- */
-void Document::LoadDocEntrySafe(DocEntry * entry)
-{
- if(Fp)
- {
- long PositionOnEntry = Fp->tellg();
- LoadDocEntry(entry);
- Fp->seekg(PositionOnEntry, std::ios::beg);
- }
-}
-
-/**
- * \brief Swaps back the bytes of 4-byte long integer accordingly to
- * processor order.
- * @return The properly swaped 32 bits integer.
- */
-uint32_t Document::SwapLong(uint32_t a)
-{
- switch (SwapCode)
- {
- case 0 :
- break;
- case 4321 :
- a=( ((a<<24) & 0xff000000) | ((a<<8) & 0x00ff0000) |
- ((a>>8) & 0x0000ff00) | ((a>>24) & 0x000000ff) );
- break;
-
- case 3412 :
- a=( ((a<<16) & 0xffff0000) | ((a>>16) & 0x0000ffff) );
- break;
-
- case 2143 :
- a=( ((a<< 8) & 0xff00ff00) | ((a>>8) & 0x00ff00ff) );
- break;
- default :
- //std::cout << "swapCode= " << SwapCode << std::endl;
- dbg.Error(" Document::SwapLong : unset swap code");
- a = 0;
- }
- return a;
-}
-
-/**
- * \brief Unswaps back the bytes of 4-byte long integer accordingly to
- * processor order.
- * @return The properly unswaped 32 bits integer.
- */
-uint32_t Document::UnswapLong(uint32_t a)
-{
- return SwapLong(a);
-}
-
-/**
- * \brief Swaps the bytes so they agree with the processor order
- * @return The properly swaped 16 bits integer.
- */
-uint16_t Document::SwapShort(uint16_t a)
-{
- if ( SwapCode == 4321 || SwapCode == 2143 )
- {
- a = ((( a << 8 ) & 0x0ff00 ) | (( a >> 8 ) & 0x00ff ) );
- }
- return a;
-}
-
-/**
- * \brief Unswaps the bytes so they agree with the processor order
- * @return The properly unswaped 16 bits integer.
- */
-uint16_t Document::UnswapShort(uint16_t a)
-{
- return SwapShort(a);
-}
-
-//-----------------------------------------------------------------------------
-// Private
-
-/**
- * \brief Parses a DocEntrySet (Zero-level DocEntries or SQ Item DocEntries)
- * @return length of the parsed set.
- */
-void Document::ParseDES(DocEntrySet *set, long offset,
- long l_max, bool delim_mode)
-{
- DocEntry *newDocEntry = 0;
- ValEntry* newValEntry;
- BinEntry* newBinEntry;
- SeqEntry* newSeqEntry;
- VRKey vr;
- bool used=false;
- long offsetEntry,readEntry;
-
- while (true)
- {
- if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max)