1 /*=========================================================================
4 Module: $RCSfile: gdcmTagKey.h,v $
6 Date: $Date: 2005/10/20 09:23:24 $
7 Version: $Revision: 1.2 $
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, ...
30 //-----------------------------------------------------------------------------
34 inline TagKey(const uint16_t &gr, const uint16_t &elt) { tag[0] = gr;tag[1] = elt;}
35 inline TagKey() { tag[0] = tag[1] = 0x0000;}
37 friend std::ostream& operator<<(std::ostream& _os, const TagKey &_val);
39 inline std::string str() const
42 sprintf(res,"%04x|%04x",tag[0],tag[1]);
43 return std::string(res);
46 inline void SetGroup(const uint16_t &val) { tag[0] = val; }
47 inline const uint16_t &GetGroup(void) { return tag[0]; }
49 inline void SetElement(const uint16_t &val) { tag[1] = val; }
50 inline const uint16_t &GetElement(void) { return tag[1]; }
52 inline TagKey &operator=(const TagKey &_val)
59 inline const uint16_t &operator[](const unsigned int &_id) const
64 inline const uint16_t &operator[](const unsigned int &_id)
70 inline bool operator==(const TagKey &_val) const
72 return tag[0] == _val.tag[0] && tag[1] == _val.tag[1];
75 inline bool operator!=(const TagKey &_val) const
77 return tag[0] != _val.tag[0] || tag[1] != _val.tag[1];
80 inline bool operator<(const TagKey &_val) const
82 return tag[0] < _val.tag[0] || (tag[0] == _val.tag[0] && tag[1] < _val.tag[1]);
89 //-----------------------------------------------------------------------------
90 inline std::ostream& operator<<(std::ostream& _os, const TagKey &_val)
92 _os.setf( std::ios::right);
93 _os << std::hex << std::setw( 4 ) << std::setfill( '0' )
94 << _val.tag[0] << '|' << std::setw( 4 ) << std::setfill( '0' )
95 << _val.tag[1] << std::setfill( ' ' ) << std::dec;
99 //-----------------------------------------------------------------------------
101 } // end namespace gdcm
103 //-----------------------------------------------------------------------------