14 #ifndef GDCMFRAGMENT_H
15 #define GDCMFRAGMENT_H
52 assert( !ValueLengthField.IsUndefined() );
53 assert( !ValueField || ValueField->GetLength() == ValueLengthField );
58 template <
typename TSwap>
59 std::istream &
Read(std::istream &is)
61 ReadPreValue<TSwap>(is);
62 return ReadValue<TSwap>(is);
65 template <
typename TSwap>
68 const Tag itemStart(0xfffe, 0xe000);
69 const Tag seqDelItem(0xfffe,0xe0dd);
71 TagField.Read<TSwap>(is);
78 if( !ValueLengthField.Read<TSwap>(is) )
86 #ifdef GDCM_SUPPORT_BROKEN_IMPLEMENTATION
87 if( TagField != itemStart && TagField != seqDelItem )
95 template <
typename TSwap>
99 const Tag itemStart(0xfffe, 0xe000);
100 const Tag seqDelItem(0xfffe,0xe0dd);
103 bv->SetLength(ValueLengthField);
104 if( !bv->Read<TSwap>(is) )
119 template <
typename TSwap>
122 const Tag itemStart(0xfffe, 0xe000);
123 const Tag seqDelItem(0xfffe,0xe0dd);
126 const std::streampos start = is.tellg();
131 TagField.Read<TSwap>(is);
133 if( TagField != itemStart && TagField != seqDelItem )
136 is.seekg( (std::streampos)((
size_t)start - offset) );
137 gdcmWarningMacro(
"Fuzzy Search, backtrack: " << (start - is.tellg()) <<
" Offset: " << is.tellg() );
141 throw "Impossible to backtrack";
150 assert( TagField == itemStart || TagField == seqDelItem );
151 if( !ValueLengthField.Read<TSwap>(is) )
158 bv->SetLength(ValueLengthField);
159 if( !bv->Read<TSwap>(is) )
175 template <
typename TSwap>
176 std::ostream &
Write(std::ostream &os)
const {
177 const Tag itemStart(0xfffe, 0xe000);
178 const Tag seqDelItem(0xfffe,0xe0dd);
179 if( !TagField.Write<TSwap>(os) )
181 assert(0 &&
"Should not happen");
184 assert( TagField == itemStart
185 || TagField == seqDelItem );
194 if( !zero.
Write<TSwap>(os) )
196 assert(0 &&
"Should not happen");
202 assert( ValueLengthField );
203 if( !ValueLengthField.Write<TSwap>(os) )
205 assert(0 &&
"Should not happen");
210 if( ValueLengthField && bv )
214 assert( bv->
GetLength() == ValueLengthField );
215 if( !bv->
Write<TSwap>(os) )
217 assert(0 &&
"Should not happen");
239 #endif //GDCMFRAGMENT_H
VL GetLength() const
Definition: gdcmVL.h:68
std::istream & ReadBacktrack(std::istream &is)
Definition: gdcmFragment.h:120
VL GetLength() const
Definition: gdcmByteValue.h:76
std::ostream const & Write(std::ostream &os) const
Definition: gdcmByteValue.h:186
#define GDCM_EXPORT
Definition: gdcmWin32.h:34
#define gdcmWarningMacro(msg)
Warning.
Definition: gdcmTrace.h:141
void SetLastElement(DataElement &de)
Definition: gdcmParseException.h:60
Value Length.
Definition: gdcmVL.h:29
Class to represent a Fragment.
Definition: gdcmFragment.h:43
ParseException Standard exception handling object.
Definition: gdcmParseException.h:26
std::ostream & operator<<(std::ostream &os, const Directory &d)
Definition: gdcmDirectory.h:92
VL ValueLengthField
Definition: gdcmDataElement.h:259
Class to represent a Data Element either Implicit or Explicit.
Definition: gdcmDataElement.h:58
Class to represent binary value (array of bytes)
Definition: gdcmByteValue.h:33
std::istream & ReadPreValue(std::istream &is)
Definition: gdcmFragment.h:66
const std::ostream & Write(std::ostream &os) const
Definition: gdcmVL.h:99
Class for Smart Pointer.
Definition: gdcmObject.h:26
VL GetLength() const
Definition: gdcmFragment.h:51
std::istream & Read(std::istream &is)
Definition: gdcmFragment.h:59
std::istream & ReadValue(std::istream &is)
Definition: gdcmFragment.h:96
ValuePtr ValueField
Definition: gdcmDataElement.h:264
#define gdcmErrorMacro(msg)
Error this is pretty bad, more than just warning It could mean lost of data, something not handle...
Definition: gdcmTrace.h:163
Class to represent a DICOM Data Element (Attribute) Tag (Group, Element). Basically an uint32_t which...
Definition: gdcmTag.h:38
Tag TagField
Definition: gdcmDataElement.h:257
std::ostream & Write(std::ostream &os) const
Definition: gdcmFragment.h:176
Exception.
Definition: gdcmException.h:33
Fragment()
Definition: gdcmFragment.h:48