14 #ifndef GDCMFRAGMENT_H
15 #define GDCMFRAGMENT_H
53 VL ComputeLength()
const;
55 template <
typename TSwap>
56 std::istream &
Read(std::istream &is)
58 ReadPreValue<TSwap>(is);
59 return ReadValue<TSwap>(is);
62 template <
typename TSwap>
65 const Tag itemStart(0xfffe, 0xe000);
66 const Tag seqDelItem(0xfffe,0xe0dd);
68 TagField.Read<TSwap>(is);
75 if( !ValueLengthField.Read<TSwap>(is) )
83 #ifdef GDCM_SUPPORT_BROKEN_IMPLEMENTATION
84 if( TagField != itemStart && TagField != seqDelItem )
92 template <
typename TSwap>
96 const Tag itemStart(0xfffe, 0xe000);
97 const Tag seqDelItem(0xfffe,0xe0dd);
100 bv->SetLength(ValueLengthField);
101 if( !bv->Read<TSwap>(is) )
116 template <
typename TSwap>
119 const Tag itemStart(0xfffe, 0xe000);
120 const Tag seqDelItem(0xfffe,0xe0dd);
123 const std::streampos start = is.tellg();
128 TagField.Read<TSwap>(is);
130 if( TagField != itemStart && TagField != seqDelItem )
133 is.seekg( (std::streampos)((
size_t)start - offset) );
134 gdcmWarningMacro(
"Fuzzy Search, backtrack: " << (start - is.tellg()) <<
" Offset: " << is.tellg() );
138 throw "Impossible to backtrack";
147 assert( TagField == itemStart || TagField == seqDelItem );
148 if( !ValueLengthField.Read<TSwap>(is) )
155 bv->SetLength(ValueLengthField);
156 if( !bv->Read<TSwap>(is) )
172 template <
typename TSwap>
173 std::ostream &
Write(std::ostream &os)
const {
174 const Tag itemStart(0xfffe, 0xe000);
175 const Tag seqDelItem(0xfffe,0xe0dd);
176 if( !TagField.Write<TSwap>(os) )
178 assert(0 &&
"Should not happen");
181 assert( TagField == itemStart
182 || TagField == seqDelItem );
191 if( !zero.
Write<TSwap>(os) )
193 assert(0 &&
"Should not happen");
199 assert( ValueLengthField );
200 assert( !ValueLengthField.IsUndefined() );
202 assert( actuallen == ValueLengthField || actuallen == ValueLengthField + 1 );
203 if( !actuallen.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
std::istream & ReadBacktrack(std::istream &is)
Definition: gdcmFragment.h:117
std::ostream & operator<<(std::ostream &os, const Fragment &val)
Definition: gdcmFragment.h:225
VL GetLength() const
Definition: gdcmByteValue.h:78
std::ostream const & Write(std::ostream &os) const
Definition: gdcmByteValue.h:159
#define GDCM_EXPORT
Definition: gdcmWin32.h:34
#define gdcmWarningMacro(msg)
Warning.
Definition: gdcmTrace.h:141
void SetLastElement(DataElement &de)
Definition: gdcmParseException.h:70
Value Length.
Definition: gdcmVL.h:29
Class to represent a Fragment.
Definition: gdcmFragment.h:43
ParseException Standard exception handling object.
Definition: gdcmParseException.h:36
VL ValueLengthField
Definition: gdcmDataElement.h:248
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:35
std::istream & ReadPreValue(std::istream &is)
Definition: gdcmFragment.h:63
VL ComputeLength() const
Definition: gdcmByteValue.h:80
const std::ostream & Write(std::ostream &os) const
Definition: gdcmVL.h:99
Class for Smart Pointer.
Definition: gdcmObject.h:26
std::istream & Read(std::istream &is)
Definition: gdcmFragment.h:56
std::istream & ReadValue(std::istream &is)
Definition: gdcmFragment.h:93
ValuePtr ValueField
Definition: gdcmDataElement.h:253
#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:246
std::ostream & Write(std::ostream &os) const
Definition: gdcmFragment.h:173
Exception.
Definition: gdcmException.h:43
Fragment()
Definition: gdcmFragment.h:48