1 /*=========================================================================
4 Module: $RCSfile: gdcmTagKey.h,v $
6 Date: $Date: 2005/10/26 15:36:19 $
7 Version: $Revision: 1.7 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
22 #include "gdcmCommon.h"
26 #include <iomanip> // for std::ios::left, ...
27 #include <stdio.h> // for ugly sprintf
31 //-----------------------------------------------------------------------------
35 TagKey(const uint16_t &gr, const uint16_t &elt) { tag[0] = gr;tag[1] = elt;}
36 TagKey() { tag[0] = tag[1] = 0x0000;}
38 friend std::ostream& operator<<(std::ostream& _os, const TagKey &_val);
40 std::string str() const
43 sprintf(res,"%04x|%04x",tag[0],tag[1]);
44 return std::string(res);
47 void SetGroup(const uint16_t &group) { tag[0] = group; }
48 uint16_t &GetGroup(void) { return tag[0]; } const
50 void SetElement(const uint16_t &elem) { tag[1] = elem; }
51 uint16_t GetElement(void) { return tag[1]; } const
53 TagKey &operator=(const TagKey &_val)
60 TagKey(const TagKey &_val)
66 const uint16_t &operator[](const unsigned int &_id) const
71 const uint16_t &operator[](const unsigned int &_id)
77 bool operator==(const TagKey &_val) const
79 return tag[0] == _val.tag[0] && tag[1] == _val.tag[1];
82 bool operator!=(const TagKey &_val) const
84 return tag[0] != _val.tag[0] || tag[1] != _val.tag[1];
87 bool operator<(const TagKey &_val) const
89 return tag[0] < _val.tag[0]
90 || (tag[0] == _val.tag[0] && tag[1] < _val.tag[1]);
97 //-----------------------------------------------------------------------------
98 inline std::ostream& operator<<(std::ostream& _os, const TagKey &_val)
100 _os.setf( std::ios::right);
101 _os << std::hex << std::setw( 4 ) << std::setfill( '0' )
102 << _val.tag[0] << '|' << std::setw( 4 ) << std::setfill( '0' )
103 << _val.tag[1] << std::setfill( ' ' ) << std::dec;
107 //-----------------------------------------------------------------------------
109 } // end namespace gdcm
111 //-----------------------------------------------------------------------------