-/**
- * \brief Find the Length till the next sequence delimiter
- * \warning NOT end user intended method !
- * @return
- */
-
-uint32_t gdcmDocument::FindDocEntryLengthOB()
- throw( gdcmFormatUnexpected )
-{
- // See PS 3.5-2001, section A.4 p. 49 on encapsulation of encoded pixel data.
- long positionOnEntry = ftell(Fp);
- bool foundSequenceDelimiter = false;
- uint32_t totalLength = 0;
-
- while ( !foundSequenceDelimiter )
- {
- uint16_t group;
- uint16_t elem;
- try
- {
- group = ReadInt16();
- elem = ReadInt16();
- }
- catch ( gdcmFormatError )
- {
- throw gdcmFormatError("gdcmDocument::FindDocEntryLengthOB()",
- " group or element not present.");
- }
-
- // We have to decount the group and element we just read
- totalLength += 4;
-
- if ( group != 0xfffe || ( ( elem != 0xe0dd ) && ( elem != 0xe000 ) ) )
- {
- dbg.Verbose(1, "gdcmDocument::FindDocEntryLengthOB: neither an Item "
- "tag nor a Sequence delimiter tag.");
- fseek(Fp, positionOnEntry, SEEK_SET);
- throw gdcmFormatUnexpected("gdcmDocument::FindDocEntryLengthOB()",
- "Neither an Item tag nor a Sequence "
- "delimiter tag.");
- }
-
- if ( elem == 0xe0dd )
- {
- foundSequenceDelimiter = true;
- }
-
- uint32_t itemLength = ReadInt32();
- // We add 4 bytes since we just read the ItemLength with ReadInt32
- totalLength += itemLength + 4;
- SkipBytes(itemLength);
-
- if ( foundSequenceDelimiter )
- {
- break;
- }
- }
- fseek(Fp, positionOnEntry, SEEK_SET);
- return totalLength;
-}
-
-/**
- * \brief Reads a supposed to be 16 Bits integer
- * (swaps it depending on processor endianity)
- * @return read value
- */
-uint16_t gdcmDocument::ReadInt16()
- throw( gdcmFormatError )
-{
- uint16_t g;
- size_t item_read = fread (&g, (size_t)2,(size_t)1, Fp);
- if ( item_read != 1 )
- {
- if( ferror(Fp) )
- {
- throw gdcmFormatError( "gdcmDocument::ReadInt16()", " file error." );
- }
- throw gdcmFormatError( "gdcmDocument::ReadInt16()", "EOF." );
- }
- g = SwapShort(g);
- return g;
-}
-
-/**
- * \brief Reads a supposed to be 32 Bits integer
- * (swaps it depending on processor endianity)
- * @return read value
- */
-uint32_t gdcmDocument::ReadInt32()
- throw( gdcmFormatError )
-{
- uint32_t g;
- size_t item_read = fread (&g, (size_t)4,(size_t)1, Fp);
- if ( item_read != 1 )
- {
- if( ferror(Fp) )
- {
- throw gdcmFormatError( "gdcmDocument::ReadInt16()", " file error." );
- }
- throw gdcmFormatError( "gdcmDocument::ReadInt32()", "EOF." );
- }
- g = SwapLong(g);
- return g;
-}
-
-/**
- * \brief skips bytes inside the source file
- * \warning NOT end user intended method !
- * @return
- */
-void gdcmDocument::SkipBytes(uint32_t nBytes)
-{
- //FIXME don't dump the returned value
- (void)fseek(Fp, (long)nBytes, SEEK_CUR);
-}
-
-/**
- * \brief Loads all the needed Dictionaries
- * \warning NOT end user intended method !
- */
-void gdcmDocument::Initialise()
-{
- RefPubDict = gdcmGlobal::GetDicts()->GetDefaultPubDict();
- RefShaDict = NULL;
-}
-