GDCM: gdcm::DataElement Class Reference

GDCM 3.2.8

Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
gdcm::DataElement Class Reference

Class to represent a Data Element either Implicit or Explicit. More...

`#include <gdcmDataElement.h>`

Inheritance diagram for gdcm::DataElement:
[legend]
Collaboration diagram for gdcm::DataElement:
[legend]

## Public Member Functions
| DataElement (const DataElement &_val)
| DataElement (const Tag &t=Tag(0), const VL &vl=0, const VR &vr=VR::INVALID)
void | Clear ()
| Clear Data Element (make Value empty and invalidate Tag + VR).
void | Empty ()
| Make Data Element empty (no Value).
const ByteValue * | GetByteValue () const
template<typename TDE>
VL | GetLength () const
SequenceOfFragments * | GetSequenceOfFragments ()
const SequenceOfFragments * | GetSequenceOfFragments () const
Tag & | GetTag ()
const Tag & | GetTag () const
| Get Tag.
Value & | GetValue ()
Value const & | GetValue () const
| Set/Get Value (bytes array, SQ of items, SQ of fragments):
SmartPointer< SequenceOfItems > | GetValueAsSQ () const
VL & | GetVL ()
const VL & | GetVL () const
| Get VL.
VR const & | GetVR () const
bool | IsEmpty () const
| Check if Data Element is empty.
bool | IsUndefinedLength () const
| return if Value Length if of undefined length
bool | operator< (const DataElement &de) const
DataElement & | operator= (const DataElement &)=default
bool | operator== (const DataElement &de) const
template<typename TDE, typename TSwap>
std::istream & | Read (std::istream &is)
template<typename TDE, typename TSwap>
std::istream & | ReadOrSkip (std::istream &is, std::set< Tag > const &skiptags)
template<typename TDE, typename TSwap>
std::istream & | ReadPreValue (std::istream &is, std::set< Tag > const &skiptags)
template<typename TDE, typename TSwap>
std::istream & | ReadValue (std::istream &is, std::set< Tag > const &skiptags)
template<typename TDE, typename TSwap>
std::istream & | ReadValueWithLength (std::istream &is, VL &length, std::set< Tag > const &skiptags)
template<typename TDE, typename TSwap>
std::istream & | ReadWithLength (std::istream &is, VL &length)
void | SetByteValue (const char *array, VL length)
void | SetTag (const Tag &t)
void | SetValue (Value const &vl)
void | SetVL (const VL &vl)
void | SetVLToUndefined ()
void | SetVR (VR const &vr)
template<typename TDE, typename TSwap>
const std::ostream & | Write (std::ostream &os) const

## Protected Types
typedef SmartPointer< Value > | ValuePtr

## Protected Member Functions
void | SetValueFieldLength (VL vl, bool readvalues)

## Protected Attributes
Tag | TagField
ValuePtr | ValueField
VL | ValueLengthField
VR | VRField

## Friends
std::ostream & | operator<< (std::ostream &_os, const DataElement &_val)

## Detailed Description

Class to represent a Data Element either Implicit or Explicit.

DATA ELEMENT: A unit of information as defined by a single entry in the data dictionary. An encoded Information Object Definition (IOD) Attribute that is composed of, at a minimum, three fields: a Data Element Tag, a Value Length, and a Value Field. For some specific Transfer Syntaxes, a Data Element also contains a VR Field where the Value Representation of that Data Element is specified explicitly.

Design:

- A DataElement in GDCM always store VL (Value Length) on a 32 bits integer even when VL is 16 bits
- A DataElement always store the VR even for Implicit TS, in which case VR is defaulted to VR::INVALID
- For Item start/end (See 0xfffe tags), Value is NULL

See also
  ExplicitDataElement ImplicitDataElement

Examples
  BasicImageAnonymizer.cs, ChangePrivateTags.cxx, ChangeSequenceUltrasound.cxx, CreateARGBImage.cxx, CreateCMYKImage.cxx, DecompressImage.cs, DecompressImageMultiframe.cs, DecompressJPEGFile.cs, DiffFile.cxx, DumpADAC.cxx, DumpCSA.cs, DumpExamCard.cxx, DumpGEMSMovieGroup.cxx, DumpImageHeaderInfo.cxx, DumpPhilipsECHO.cxx, DumpSiemensBase64.cxx, DumpToshibaDTI.cxx, DumpToshibaDTI2.cxx, DumpVisusChange.cxx, DuplicatePCDE.cxx, ELSCINT1WaveToText.cxx, ExtractEncapsulatedFile.cs, ExtractEncryptedContent.cxx, ExtractIconFromFile.cxx, Extracting_All_Resolution.cxx, Fake_Image_Using_Stream_Image_Writer.cxx, FileChangeTS.cs, FileChangeTSLossy.cs, FixBrokenJ2K.cxx, FixJAIBugJPEGLS.cxx, GenAllVR.cxx, GenFakeIdentifyFile.cxx, GenFakeImage.cxx, GenLongSeqs.cxx, GenSeqs.cxx, GetJPEGSamplePrecision.cxx, GetSequenceUltrasound.cxx, GetSubSequenceData.cxx, LargeVRDSExplicit.cxx, MpegVideoInfo.cs, NewSequence.cs, ReadAndDumpDICOMDIR.cxx, ReadExplicitLengthSQIVR.cxx, ReadGEMSSDO.cxx, SimplePrint.cs, StreamImageReaderTest.cxx, csa2img.cxx, gdcmrtionplan.cxx, gdcmrtplan.cxx, iU22tomultisc.cxx, pmsct_rgb1.cxx, and rle2img.cxx.

## Member Typedef Documentation

## ◆ ValuePtr

typedef SmartPointer<Value> gdcm::DataElement::ValuePtr
| protected

## Constructor & Destructor Documentation

## ◆ DataElement() [1/2]

gdcm::DataElement::DataElement | ( | const Tag & | t = Tag(0),
|  | const VL & | vl = 0,
|  | const VR & | vr = VR::INVALID )
| inline

References gdcm::VR::INVALID, TagField, ValueField, ValueLengthField, and VRField.

Referenced by DataElement(), gdcm::Fragment::Fragment(), gdcm::Item::Item(), gdcm::Item::Item(), gdcm::Item::GetDataElement(), gdcm::Item::InsertDataElement(), operator<(), operator<<, operator=(), and operator==().

## ◆ DataElement() [2/2]

gdcm::DataElement::DataElement | ( | const DataElement & | _val | ) |
| inline

References DataElement().

## Member Function Documentation

## ◆ Clear()

void gdcm::DataElement::Clear | ( |  | ) |
| inline

Clear Data Element (make Value empty and invalidate Tag + VR).

References gdcm::VR::INVALID, TagField, ValueField, ValueLengthField, and VRField.

Referenced by gdcm::Item::Clear().

## ◆ Empty()

void gdcm::DataElement::Empty | ( |  | ) |
| inline

Make Data Element empty (no Value).

References ValueField, and ValueLengthField.

## ◆ GetByteValue()

const ByteValue * gdcm::DataElement::GetByteValue | ( |  | ) | const
| inline

Return the Value of DataElement as a ByteValue (if possible)

Warning
  : You need to check for NULL return value

Examples
  DumpADAC.cxx, DumpExamCard.cxx, DumpGEMSMovieGroup.cxx, DumpImageHeaderInfo.cxx, DumpPhilipsECHO.cxx, DumpToshibaDTI.cxx, DumpToshibaDTI2.cxx, DuplicatePCDE.cxx, ELSCINT1WaveToText.cxx, ExtractEncapsulatedFile.cs, ExtractEncryptedContent.cxx, ExtractIconFromFile.cxx, FixBrokenJ2K.cxx, FixJAIBugJPEGLS.cxx, GetSubSequenceData.cxx, PatchFile.cxx, ReadExplicitLengthSQIVR.cxx, ReadGEMSSDO.cxx, pmsct_rgb1.cxx, and rle2img.cxx.

References ValueField.

Referenced by IsEmpty(), gdcm::BasicOffsetTable::operator<<, gdcm::Attribute< Group, Element, TVR, TVM >::SetFromDataElement(), gdcm::Attribute< Group, Element, TVR, VM::VM1 >::SetFromDataElement(), gdcm::Attribute< Group, Element, TVR, VM::VM1_n >::SetFromDataElement(), gdcm::Element< TVR, TVM >::SetFromDataElement(), gdcm::Element< TVR, VM::VM1_n >::SetFromDataElement(), and gdcm::Fragment::Write().

## ◆ GetLength()

template<typename TDE>

VL gdcm::DataElement::GetLength | ( |  | ) | const
| inline

References GetLength().

Referenced by GetLength().

## ◆ GetSequenceOfFragments() [1/2]

SequenceOfFragments * gdcm::DataElement::GetSequenceOfFragments | ( |  | ) |

## ◆ GetSequenceOfFragments() [2/2]

const SequenceOfFragments * gdcm::DataElement::GetSequenceOfFragments | ( |  | ) | const

Return the Value of DataElement as a Sequence Of Fragments (if possible)

Warning
  : You need to check for NULL return value

Examples
  DecompressImage.cs, FixBrokenJ2K.cxx, FixJAIBugJPEGLS.cxx, and GetJPEGSamplePrecision.cxx.

## ◆ GetTag() [1/2]

Tag & gdcm::DataElement::GetTag | ( |  | ) |
| inline

References TagField.

## ◆ GetTag() [2/2]

const Tag & gdcm::DataElement::GetTag | ( |  | ) | const
| inline

Get Tag.

Examples
  DumpGEMSMovieGroup.cxx, DumpVisusChange.cxx, DuplicatePCDE.cxx, SimplePrint.cs, and pmsct_rgb1.cxx.

References TagField.

Referenced by gdcm::CommandDataSet::Insert(), gdcm::DataSet::Insert(), gdcm::FileMetaInformation::Insert(), operator<(), gdcm::SequenceOfItems::Read(), gdcm::SequenceOfFragments::ReadValue(), gdcm::CommandDataSet::Replace(), gdcm::FileMetaInformation::Replace(), gdcm::Attribute< Group, Element, TVR, TVM >::SetFromDataElement(), gdcm::Attribute< Group, Element, TVR, VM::VM1 >::SetFromDataElement(), and gdcm::Attribute< Group, Element, TVR, VM::VM1_n >::SetFromDataElement().

## ◆ GetValue() [1/2]

Value & gdcm::DataElement::GetValue | ( |  | ) |
| inline

References gdcmAssertAlwaysMacro, and ValueField.

## ◆ GetValue() [2/2]

Value const & gdcm::DataElement::GetValue | ( |  | ) | const
| inline

Set/Get Value (bytes array, SQ of items, SQ of fragments):

Examples
  ReadAndDumpDICOMDIR.cxx.

References gdcmAssertAlwaysMacro, and ValueField.

Referenced by gdcm::DataSet::InsertDataElement(), gdcm::Element< TVR, TVM >::SetFromDataElement(), and gdcm::Element< TVR, VM::VM1_n >::SetFromDataElement().

## ◆ GetValueAsSQ()

SmartPointer< SequenceOfItems > gdcm::DataElement::GetValueAsSQ | ( |  | ) | const

Interpret the Value stored in the DataElement. This is more robust (but also more expensive) to call this function rather than the simplest form: GetSequenceOfItems() It also return NULL when the Value is NOT of type SequenceOfItems

Warning
  in case GetSequenceOfItems() succeed the function return this value, otherwise it creates a new SequenceOfItems, you should handle that in your case, for instance: SmartPointer<SequenceOfItems> sqi = de.GetValueAsSQ();

Examples
  ChangeSequenceUltrasound.cxx, DumpExamCard.cxx, DumpGEMSMovieGroup.cxx, DumpPhilipsECHO.cxx, DumpToshibaDTI.cxx, DumpToshibaDTI2.cxx, DumpVisusChange.cxx, ExtractEncryptedContent.cxx, GetSequenceUltrasound.cxx, GetSubSequenceData.cxx, LargeVRDSExplicit.cxx, ReadAndDumpDICOMDIR.cxx, SimplePrint.cs, gdcmrtionplan.cxx, and gdcmrtplan.cxx.

## ◆ GetVL() [1/2]

VL & gdcm::DataElement::GetVL | ( |  | ) |
| inline

References ValueLengthField.

## ◆ GetVL() [2/2]

const VL & gdcm::DataElement::GetVL | ( |  | ) | const
| inline

Get VL.

Examples
  SimplePrint.cs.

References ValueLengthField.

Referenced by gdcm::DataSet::InsertDataElement(), gdcm::SequenceOfItems::Read(), and gdcm::SequenceOfFragments::ReadValue().

## ◆ GetVR()

VR const & gdcm::DataElement::GetVR | ( |  | ) | const
| inline

Get VR do not set VR::SQ on bytevalue data element

Examples
  DuplicatePCDE.cxx, and GenFakeIdentifyFile.cxx.

References VRField.

Referenced by gdcm::Attribute< Group, Element, TVR, TVM >::GetAsDataElement(), gdcm::Attribute< Group, Element, TVR, VM::VM1 >::GetAsDataElement(), gdcm::Attribute< Group, Element, TVR, VM::VM1_n >::GetAsDataElement(), gdcm::Element< TVR, TVM >::GetAsDataElement(), gdcm::Element< TVR, VM::VM1_n >::GetAsDataElement(), gdcm::Attribute< Group, Element, TVR, TVM >::SetFromDataElement(), gdcm::Attribute< Group, Element, TVR, VM::VM1 >::SetFromDataElement(), gdcm::Attribute< Group, Element, TVR, VM::VM1_n >::SetFromDataElement(), gdcm::Element< TVR, TVM >::SetFromDataElement(), and gdcm::Element< TVR, VM::VM1_n >::SetFromDataElement().

## ◆ IsEmpty()

bool gdcm::DataElement::IsEmpty | ( |  | ) | const
| inline

Check if Data Element is empty.

Examples
  DumpADAC.cxx, DumpCSA.cs, DumpExamCard.cxx, DumpGEMSMovieGroup.cxx, DumpImageHeaderInfo.cxx, DumpToshibaDTI.cxx, DumpToshibaDTI2.cxx, ELSCINT1WaveToText.cxx, FixJAIBugJPEGLS.cxx, pmsct_rgb1.cxx, and rle2img.cxx.

References GetByteValue(), and ValueField.

Referenced by gdcm::DataSet::InsertDataElement(), gdcm::Attribute< Group, Element, TVR, TVM >::SetFromDataElement(), gdcm::Attribute< Group, Element, TVR, VM::VM1 >::SetFromDataElement(), gdcm::Attribute< Group, Element, TVR, VM::VM1_n >::SetFromDataElement(), and gdcm::Fragment::Write().

## ◆ IsUndefinedLength()

bool gdcm::DataElement::IsUndefinedLength | ( |  | ) | const
| inline

return if Value Length if of undefined length

References ValueLengthField.

Referenced by gdcm::Item::InsertDataElement().

## ◆ operator<()

bool gdcm::DataElement::operator< | ( | const DataElement & | de | ) | const
| inline

References DataElement(), and GetTag().

## ◆ operator=()

DataElement & gdcm::DataElement::operator= | ( | const DataElement & |  | ) |
| default

References DataElement().

## ◆ operator==()

bool gdcm::DataElement::operator== | ( | const DataElement & | de | ) | const
| inline

References DataElement(), TagField, ValueField, ValueLengthField, and VRField.

## ◆ Read()

template<typename TDE, typename TSwap>

std::istream & gdcm::DataElement::Read | ( | std::istream & | is | ) |
| inline

Examples
  DumpSiemensBase64.cxx.

References Read().

Referenced by Read(), and ReadOrSkip().

## ◆ ReadOrSkip()

template<typename TDE, typename TSwap>

std::istream & gdcm::DataElement::ReadOrSkip | ( | std::istream & | is,
|  | std::set< Tag > const & | skiptags )
| inline

References Read().

## ◆ ReadPreValue()

template<typename TDE, typename TSwap>

std::istream & gdcm::DataElement::ReadPreValue | ( | std::istream & | is,
|  | std::set< Tag > const & | skiptags )
| inline

References ReadPreValue().

Referenced by ReadPreValue().

## ◆ ReadValue()

template<typename TDE, typename TSwap>

std::istream & gdcm::DataElement::ReadValue | ( | std::istream & | is,
|  | std::set< Tag > const & | skiptags )
| inline

References ReadValue().

Referenced by ReadValue().

## ◆ ReadValueWithLength()

template<typename TDE, typename TSwap>

std::istream & gdcm::DataElement::ReadValueWithLength | ( | std::istream & | is,
|  | VL & | length,
|  | std::set< Tag > const & | skiptags )
| inline

References ReadValueWithLength().

Referenced by ReadValueWithLength().

## ◆ ReadWithLength()

template<typename TDE, typename TSwap>

std::istream & gdcm::DataElement::ReadWithLength | ( | std::istream & | is,
|  | VL & | length )
| inline

References ReadWithLength().

Referenced by gdcm::Item::Read(), and ReadWithLength().

## ◆ SetByteValue()

void gdcm::DataElement::SetByteValue | ( | const char * | array,
|  | VL | length )
| inline

Set the byte value

Warning
  user need to read DICOM standard for an understanding of:
  - even padding
  - \0 vs space padding By default even padding is achieved using \0 regardless of the of VR

Examples
  BasicImageAnonymizer.cs, ChangePrivateTags.cxx, ChangeSequenceUltrasound.cxx, CreateARGBImage.cxx, CreateCMYKImage.cxx, DecompressImage.cs, DecompressImageMultiframe.cs, DecompressJPEGFile.cs, Fake_Image_Using_Stream_Image_Writer.cxx, FileChangeTS.cs, FileChangeTSLossy.cs, FixBrokenJ2K.cxx, FixJAIBugJPEGLS.cxx, GenFakeIdentifyFile.cxx, GenFakeImage.cxx, GenLongSeqs.cxx, GenSeqs.cxx, GetSubSequenceData.cxx, MpegVideoInfo.cs, NewSequence.cs, StreamImageReaderTest.cxx, iU22tomultisc.cxx, and rle2img.cxx.

References SetValue().

Referenced by gdcm::Attribute< Group, Element, TVR, TVM >::GetAsDataElement(), gdcm::Attribute< Group, Element, TVR, VM::VM1 >::GetAsDataElement(), gdcm::Attribute< Group, Element, TVR, VM::VM1_n >::GetAsDataElement(), gdcm::Element< TVR, TVM >::GetAsDataElement(), and gdcm::Element< TVR, VM::VM1_n >::GetAsDataElement().

## ◆ SetTag()

void gdcm::DataElement::SetTag | ( | const Tag & | t | ) |
| inline

Set Tag Use with cautious (need to match Part 6)

Examples
  Extracting_All_Resolution.cxx, Fake_Image_Using_Stream_Image_Writer.cxx, GenFakeIdentifyFile.cxx, and GetSubSequenceData.cxx.

References TagField.

## ◆ SetValue()

void gdcm::DataElement::SetValue | ( | Value const & | vl | ) |
| inline

Warning
  you need to set the ValueLengthField explicitly

Examples
  DecompressImageMultiframe.cs, DecompressJPEGFile.cs, DuplicatePCDE.cxx, Fake_Image_Using_Stream_Image_Writer.cxx, FixBrokenJ2K.cxx, GenFakeIdentifyFile.cxx, GenLongSeqs.cxx, GenSeqs.cxx, MpegVideoInfo.cs, and NewSequence.cs.

References gdcm::Value::GetLength(), ValueField, and ValueLengthField.

Referenced by SetByteValue().

## ◆ SetValueFieldLength()

void gdcm::DataElement::SetValueFieldLength | ( | VL | vl,
|  | bool | readvalues )
| protected

## ◆ SetVL()

void gdcm::DataElement::SetVL | ( | const VL & | vl | ) |
| inline

Set VL Use with cautious (need to match Part 6), advanced user only

See also
  SetByteValue

References ValueLengthField.

## ◆ SetVLToUndefined()

void gdcm::DataElement::SetVLToUndefined | ( |  | ) |

Examples
  Fake_Image_Using_Stream_Image_Writer.cxx, GenAllVR.cxx, GenFakeIdentifyFile.cxx, GenLongSeqs.cxx, GenSeqs.cxx, and NewSequence.cs.

## ◆ SetVR()

void gdcm::DataElement::SetVR | ( | VR const & | vr | ) |
| inline

Set VR Use with cautious (need to match Part 6), advanced user only

Precondition
  vr is a VR::VRALL (not a dual one such as OB_OW)

Examples
  Fake_Image_Using_Stream_Image_Writer.cxx, FixBrokenJ2K.cxx, FixJAIBugJPEGLS.cxx, GenFakeIdentifyFile.cxx, GenLongSeqs.cxx, GenSeqs.cxx, GetSubSequenceData.cxx, NewSequence.cs, StreamImageReaderTest.cxx, iU22tomultisc.cxx, and rle2img.cxx.

References gdcm::VR::IsVRFile(), and VRField.

Referenced by gdcm::Attribute< Group, Element, TVR, TVM >::GetAsDataElement(), gdcm::Attribute< Group, Element, TVR, VM::VM1 >::GetAsDataElement(), gdcm::Attribute< Group, Element, TVR, VM::VM1_n >::GetAsDataElement(), gdcm::Element< TVR, TVM >::GetAsDataElement(), and gdcm::Element< TVR, VM::VM1_n >::GetAsDataElement().

## ◆ Write()

template<typename TDE, typename TSwap>

const std::ostream & gdcm::DataElement::Write | ( | std::ostream & | os | ) | const
| inline

References Write().

Referenced by Write().

## Friends And Related Symbol Documentation

## ◆ operator<<

std::ostream & operator<< | ( | std::ostream & | _os,
|  | const DataElement & | _val )
| friend

References DataElement(), operator<<, gdcm::Object::Print(), TagField, ValueField, ValueLengthField, and VRField.

Referenced by operator<<.

## Member Data Documentation

## ◆ TagField

Tag gdcm::DataElement::TagField
| protected

Referenced by DataElement(), Clear(), GetTag(), GetTag(), operator<<, gdcm::Fragment::operator<<, gdcm::Item::operator<<, operator==(), gdcm::BasicOffsetTable::Read(), gdcm::Item::Read(), gdcm::Fragment::ReadBacktrack(), gdcm::Fragment::ReadPreValue(), SetTag(), gdcm::Fragment::Write(), and gdcm::Item::Write().

## ◆ ValueField

ValuePtr gdcm::DataElement::ValueField
| protected

Referenced by DataElement(), Clear(), Empty(), GetByteValue(), GetValue(), GetValue(), IsEmpty(), gdcm::BasicOffsetTable::operator<<, operator<<, gdcm::Fragment::operator<<, operator==(), gdcm::BasicOffsetTable::Read(), gdcm::Fragment::ReadBacktrack(), gdcm::Fragment::ReadValue(), and SetValue().

## ◆ ValueLengthField

VL gdcm::DataElement::ValueLengthField
| protected

Referenced by DataElement(), Clear(), Empty(), GetVL(), GetVL(), IsUndefinedLength(), gdcm::BasicOffsetTable::operator<<, operator<<, gdcm::Fragment::operator<<, gdcm::Item::operator<<, operator==(), gdcm::BasicOffsetTable::Read(), gdcm::Item::Read(), gdcm::Fragment::ReadBacktrack(), gdcm::Fragment::ReadPreValue(), gdcm::Fragment::ReadValue(), SetValue(), SetVL(), gdcm::Fragment::Write(), and gdcm::Item::Write().

## ◆ VRField

VR gdcm::DataElement::VRField
| protected

Referenced by DataElement(), Clear(), GetVR(), operator<<, operator==(), and SetVR().

The documentation for this class was generated from the following file:

- gdcmDataElement.h