42 Tag(uint16_t group, uint16_t element) {
43 ElementTag.tags[0] = group; ElementTag.tags[1] = element;
47 Tag(uint32_t tag = 0) {
51 friend std::ostream&
operator<<(std::ostream &_os,
const Tag &_val);
52 friend std::istream&
operator>>(std::istream &_is,
Tag &_val);
55 uint16_t
GetGroup()
const {
return ElementTag.tags[0]; }
57 uint16_t
GetElement()
const {
return ElementTag.tags[1]; }
59 void SetGroup(uint16_t group) { ElementTag.tags[0] = group; }
61 void SetElement(uint16_t element) { ElementTag.tags[1] = element; }
64 ElementTag.tags[0] = group; ElementTag.tags[1] = element;
69 #ifndef GDCM_WORDS_BIGENDIAN
70 return (ElementTag.tag<<16) | (ElementTag.tag>>16);
72 return ElementTag.tag;
78 #ifndef GDCM_WORDS_BIGENDIAN
79 tag = ( (tag<<16) | (tag>>16) );
85 const uint16_t &
operator[](
const unsigned int &_id)
const
88 return ElementTag.tags[_id];
94 return ElementTag.tags[_id];
99 ElementTag.
tag = _val.ElementTag.
tag;
105 return ElementTag.tag == _val.ElementTag.
tag;
109 return ElementTag.tag != _val.ElementTag.
tag;
121 #ifndef GDCM_WORDS_BIGENDIAN
122 if( ElementTag.tags[0] < _val.ElementTag.
tags[0] )
124 if( ElementTag.tags[0] == _val.ElementTag.
tags[0]
125 && ElementTag.tags[1] < _val.ElementTag.
tags[1] )
130 return ( ElementTag.tag < _val.ElementTag.
tag );
135 const Tag &t1 = *
this;
136 return t1 == t2 || t1 < t2;
141 ElementTag.tag = _val.ElementTag.
tag;
150 bool IsPublic()
const {
return !(ElementTag.tags[0] % 2); }
159 template <
typename TSwap>
160 std::istream &
Read(std::istream &is)
162 if( is.read(ElementTag.bytes, 4) )
163 TSwap::SwapArray(ElementTag.tags, 2);
168 template <
typename TSwap>
169 const std::ostream &
Write(std::ostream &os)
const
172 copy[0]= ElementTag.tags[0];
173 copy[1]= ElementTag.tags[1];
174 TSwap::SwapArray(copy, 2);
175 return os.write((
char*)(©), 4);
183 if( IsPrivate() && !IsPrivateCreator() )
186 r.
SetElement( (uint16_t)(GetElement() >> 8) );
189 if( IsPrivateCreator() )
return *
this;
198 const uint16_t element = (uint16_t)(t.
GetElement() << 8);
199 const uint16_t base = (uint16_t)(GetElement() << 8);
200 SetElement( (uint16_t)((base >> 8) + element) );
208 return IsPrivate() && (GetElement() <= 0xFF && GetElement() >= 0x10);
215 return GetGroup() == 0x0001 || GetGroup() == 0x0003 || GetGroup() == 0x0005 || GetGroup() == 0x0007
218 || (IsPrivate() && GetElement() > 0x0 && GetElement() < 0x10 );
224 return GetElement() == 0x0;
233 uint16_t group = (uint16_t)((GetGroup() >> 8 ) << 8);
244 bool ReadFromCommaSeparatedString(
const char *str);
248 bool ReadFromPipeSeparatedString(
const char *str);
252 std::string PrintAsPipeSeparatedString()
const;
255 union { uint32_t tag; uint16_t tags[2];
char bytes[4]; } ElementTag;
263 _is >> std::hex >> a;
269 _is >> std::hex >> b;
278 _os.setf( std::ios::right);
279 _os << std::hex <<
'(' << std::setw( 4 ) << std::setfill(
'0' )
280 << _val[0] <<
',' << std::setw( 4 ) << std::setfill(
'0' )
281 << _val[1] <<
')' << std::setfill(
' ' ) << std::dec;
bool operator<=(const Tag &t2) const
Definition: gdcmTag.h:133
uint32_t tag
Definition: gdcmTag.h:255
uint16_t & operator[](const unsigned int &_id)
Returns the Group or Element of the given Tag, depending on id (0/1)
Definition: gdcmTag.h:91
uint32_t GetElementTag() const
Returns the full tag value of the given Tag.
Definition: gdcmTag.h:68
bool IsPrivate() const
Definition: gdcmTag.h:155
#define GDCM_EXPORT
Definition: gdcmWin32.h:34
std::istream & operator>>(std::istream &is, String< TDelimiter, TMaxLength, TPadChar > &ms)
Definition: gdcmString.h:117
uint16_t tags[2]
Definition: gdcmTag.h:255
uint16_t GetElement() const
Returns the 'Element number' of the given Tag.
Definition: gdcmTag.h:57
std::ostream & operator<<(std::ostream &os, const Directory &d)
Definition: gdcmDirectory.h:92
const std::ostream & Write(std::ostream &os) const
Write a tag in binary rep.
Definition: gdcmTag.h:169
bool operator==(const Tag &_val) const
Definition: gdcmTag.h:103
Tag GetPrivateCreator() const
Return the Private Creator Data Element tag of a private data element.
Definition: gdcmTag.h:179
uint32_t GetLength() const
return the length of tag (read: size on disk)
Definition: gdcmTag.h:144
bool IsGroupXX(const Tag &t) const
e.g 6002,3000 belong to groupXX: 6000,3000
Definition: gdcmTag.h:228
bool operator!=(const Tag &_val) const
Definition: gdcmTag.h:107
void SetPrivateCreator(Tag const &t)
Set private creator:
Definition: gdcmTag.h:193
const uint16_t & operator[](const unsigned int &_id) const
Returns the Group or Element of the given Tag, depending on id (0/1)
Definition: gdcmTag.h:85
std::istream & Read(std::istream &is)
Read a tag from binary representation.
Definition: gdcmTag.h:160
bool IsPrivateCreator() const
Definition: gdcmTag.h:206
void SetElement(uint16_t element)
Sets the 'Element number' of the given Tag.
Definition: gdcmTag.h:61
Tag & operator=(const Tag &_val)
Definition: gdcmTag.h:97
Tag(uint32_t tag=0)
Constructor with 1*uint32_t Prefer the cstor that takes two uint16_t.
Definition: gdcmTag.h:47
Tag(uint16_t group, uint16_t element)
Constructor with 2*uint16_t.
Definition: gdcmTag.h:42
bool IsPublic() const
Definition: gdcmTag.h:150
bool IsIllegal() const
return if the tag is considered to be an illegal tag
Definition: gdcmTag.h:212
Class to represent a DICOM Data Element (Attribute) Tag (Group, Element). Basically an uint32_t which...
Definition: gdcmTag.h:38
uint16_t GetGroup() const
Returns the 'Group number' of the given Tag.
Definition: gdcmTag.h:55
void SetElementTag(uint16_t group, uint16_t element)
Sets the 'Group number' & 'Element number' of the given Tag.
Definition: gdcmTag.h:63
bool operator<(const Tag &_val) const
Definition: gdcmTag.h:119
Tag(const Tag &_val)
Definition: gdcmTag.h:139
void SetGroup(uint16_t group)
Sets the 'Group number' of the given Tag.
Definition: gdcmTag.h:59
void SetElementTag(uint32_t tag)
Sets the full tag value of the given Tag.
Definition: gdcmTag.h:77
bool IsGroupLength() const
return whether the tag correspond to a group length tag:
Definition: gdcmTag.h:222