# 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]

List of all members.

## Public Member Functions

| DataElement (const Tag &t=Tag(0), const VL &vl=0, const VR &vr=VR::INVALID)
| DataElement (const DataElement &_val)
void | Clear ()
| Clear Data Element (make Value empty and invalidate Tag & VR)
void | Empty ()
| Make Data Element empty (no Value)
const ByteValue * | GetByteValue () const
ByteValue * | GetByteValue ()
template<typename TDE >
VL | GetLength () const
const SequenceOfFragments * | GetSequenceOfFragments () const
SequenceOfItems * | GetSequenceOfItems ()
const SequenceOfItems * | GetSequenceOfItems () const
const Tag & | GetTag () const
| Get Tag.
Tag & | GetTag ()
Value const & | GetValue () const
| Set/Get Value (bytes array, SQ of items, SQ of fragments):
Value & | GetValue ()
SmartPointer< SequenceOfItems > | GetValueAsSQ () const
const VL & | GetVL () const
| Get VL.
VL & | GetVL ()
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 &de)
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 & | 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 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:

  ChangeSequenceUltrasound.cxx, CreateARGBImage.cxx, CreateCMYKImage.cxx, csa2img.cxx, DiffFile.cxx, DuplicatePCDE.cxx, ExtractEncryptedContent.cxx, FixBrokenJ2K.cxx, gdcmrtionplan.cxx, gdcmrtplan.cxx, GenAllVR.cxx, GenFakeIdentifyFile.cxx, GenFakeImage.cxx, GenLongSeqs.cxx, GenSeqs.cxx, GetJPEGSamplePrecision.cxx, GetSequenceUltrasound.cxx, GetSubSequenceData.cxx, LargeVRDSExplicit.cxx, ReadAndDumpDICOMDIR.cxx, ReadAndPrintAttributes.cxx, ReadExplicitLengthSQIVR.cxx, ReadGEMSSDO.cxx, and rle2img.cxx.

## Member Typedef Documentation

typedef SmartPointer<Value> gdcm::DataElement::ValuePtr`[protected]`

## Constructor & Destructor Documentation

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

gdcm::DataElement::DataElement | ( | const DataElement & | _val | ) | `[inline]`

## Member Function Documentation

void gdcm::DataElement::Clear | ( |  | ) | `[inline]`

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

Reimplemented in gdcm::Item.

References gdcm::VR::INVALID.

void gdcm::DataElement::Empty | ( |  | ) | `[inline]`

Make Data Element empty (no Value)

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:
  DuplicatePCDE.cxx, ExtractEncryptedContent.cxx, FixBrokenJ2K.cxx, ReadExplicitLengthSQIVR.cxx, ReadGEMSSDO.cxx, and rle2img.cxx.

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

ByteValue* gdcm::DataElement::GetByteValue | ( |  | ) | `[inline]`

template<typename TDE >

VL gdcm::DataElement::GetLength | ( |  | ) | const`[inline]`

Reimplemented in gdcm::CP246ExplicitDataElement, gdcm::ExplicitDataElement, gdcm::ExplicitImplicitDataElement, gdcm::Fragment, gdcm::ImplicitDataElement, gdcm::Item, gdcm::UNExplicitDataElement, gdcm::UNExplicitImplicitDataElement, and gdcm::VR16ExplicitDataElement.

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:
  FixBrokenJ2K.cxx, and GetJPEGSamplePrecision.cxx.

const SequenceOfItems* gdcm::DataElement::GetSequenceOfItems | ( |  | ) | const

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

Warning:
  : You need to check for NULL return value
  : In some case a Value could not have been recognized as a SequenceOfItems in those case the return of the function will be NULL, while the Value would be a valid SequenceOfItems, in those case prefer GetValueAsSQ. In which case the code internally trigger an assert to warn developper. When in doubt do not use this function and prefer GetValueAsSQ()

Deprecated:
  Replaced by DataElement::GetValueAsSQ() as of GDCM 2.2.

SequenceOfItems* gdcm::DataElement::GetSequenceOfItems | ( |  | ) |

Tag& gdcm::DataElement::GetTag | ( |  | ) | `[inline]`

const Tag& gdcm::DataElement::GetTag | ( |  | ) | const`[inline]`

Get Tag.

Examples:
  DuplicatePCDE.cxx, and rle2img.cxx.

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

Value const& gdcm::DataElement::GetValue | ( |  | ) | const`[inline]`

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

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

Value& gdcm::DataElement::GetValue | ( |  | ) | `[inline]`

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 simpliest 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, ExtractEncryptedContent.cxx, gdcmrtionplan.cxx, gdcmrtplan.cxx, GetSequenceUltrasound.cxx, LargeVRDSExplicit.cxx, and ReadAndDumpDICOMDIR.cxx.

const VL& gdcm::DataElement::GetVL | ( |  | ) | const`[inline]`

Get VL.

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

VL& gdcm::DataElement::GetVL | ( |  | ) | `[inline]`

VR const& gdcm::DataElement::GetVR | ( |  | ) | const`[inline]`

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

Examples:
  DuplicatePCDE.cxx, and GenFakeIdentifyFile.cxx.

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

bool gdcm::DataElement::IsEmpty | ( |  | ) | const`[inline]`

Check if Data Element is empty.

Examples:
  rle2img.cxx.

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

bool gdcm::DataElement::IsUndefinedLength | ( |  | ) | const`[inline]`

return if Value Length if of undefined length

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

References GetTag().

DataElement& gdcm::DataElement::operator= | ( | const DataElement & | de | ) | `[inline]`

References TagField, ValueField, ValueLengthField, and VRField.

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

References TagField, ValueField, ValueLengthField, and VRField.

template<typename TDE , typename TSwap >

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

Reimplemented in gdcm::BasicOffsetTable, gdcm::CP246ExplicitDataElement, gdcm::ExplicitDataElement, gdcm::ExplicitImplicitDataElement, gdcm::Fragment, gdcm::ImplicitDataElement, gdcm::Item, gdcm::UNExplicitDataElement, gdcm::UNExplicitImplicitDataElement, and gdcm::VR16ExplicitDataElement.

template<typename TDE , typename TSwap >

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

template<typename TDE , typename TSwap >

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

template<typename TDE , typename TSwap >

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

template<typename TDE , typename TSwap >

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

Reimplemented in gdcm::CP246ExplicitDataElement, gdcm::ExplicitDataElement, gdcm::ExplicitImplicitDataElement, gdcm::ImplicitDataElement, gdcm::UNExplicitDataElement, and gdcm::VR16ExplicitDataElement.

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:
  ChangeSequenceUltrasound.cxx, CreateARGBImage.cxx, CreateCMYKImage.cxx, DuplicatePCDE.cxx, FixBrokenJ2K.cxx, GenFakeIdentifyFile.cxx, GenFakeImage.cxx, GenLongSeqs.cxx, GenSeqs.cxx, and GetSubSequenceData.cxx.

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

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

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

Examples:
  GenFakeIdentifyFile.cxx, and GetSubSequenceData.cxx.

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

Warning:
  you need to set the ValueLengthField explicitely

Examples:
  FixBrokenJ2K.cxx, GenFakeIdentifyFile.cxx, GenLongSeqs.cxx, and GenSeqs.cxx.

References gdcm::Value::GetLength().

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

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

See also:
  SetByteValue

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

Examples:
  GenAllVR.cxx, GenFakeIdentifyFile.cxx, GenLongSeqs.cxx, and GenSeqs.cxx.

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:
  FixBrokenJ2K.cxx, GenFakeIdentifyFile.cxx, GenLongSeqs.cxx, GenSeqs.cxx, and GetSubSequenceData.cxx.

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

template<typename TDE , typename TSwap >

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

Reimplemented in gdcm::ExplicitDataElement, gdcm::Fragment, gdcm::ImplicitDataElement, and gdcm::Item.

## Friends And Related Function Documentation

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

## Member Data Documentation

Tag gdcm::DataElement::TagField`[protected]`

Referenced by gdcm::operator<<(), operator=(), and operator==().

ValuePtr gdcm::DataElement::ValueField`[protected]`

Referenced by gdcm::operator<<(), operator=(), and operator==().

VL gdcm::DataElement::ValueLengthField`[protected]`

Referenced by gdcm::operator<<(), operator=(), and operator==().

VR gdcm::DataElement::VRField`[protected]`

Referenced by gdcm::operator<<(), operator=(), and operator==().

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

- gdcmDataElement.h