1 /*=========================================================================
4 Module: $RCSfile: gdcmVRKey.h,v $
6 Date: $Date: 2005/10/23 15:01:34 $
7 Version: $Revision: 1.5 $
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"
25 #include <iomanip> // important
29 //-----------------------------------------------------------------------------
33 inline VRKey() { key[0] = key[1] = ' ';}
34 inline VRKey(const char *_key) { key[0] = _key[0]; key[1] = _key[1];}
35 inline VRKey(const std::string &_key) { key[0] = _key[0]; key[1] = _key[1];}
37 inline std::string str() const { return std::string(key,2); }
39 friend std::ostream &operator<<(std::ostream &_os, const VRKey &_val);
40 friend std::istream &operator>>(std::istream &_is, VRKey &_val);
42 inline VRKey &operator=(const VRKey &_val)
49 inline VRKey &operator=(const std::string &_val)
56 inline VRKey &operator=(const char *_val)
63 inline const char &operator[](const unsigned int &_id) const
69 inline char &operator[](const unsigned int &_id)
75 inline bool operator==(const VRKey &_val) const
77 return key[0] == _val.key[0] && key[1] == _val.key[1];
80 inline bool operator==(const std::string &_val) const
82 return key[0] == _val[0] && key[1] == _val[1];
85 inline bool operator==(const char *_val) const
87 return key[0] == _val[0] && key[1] == _val[1];
90 inline bool operator!=(const VRKey &_val) const
92 return key[0] != _val.key[0] || key[1] != _val.key[1];
95 inline bool operator!=(const std::string &_val) const
97 return key[0] != _val[0] || key[1] != _val[1];
99 inline bool operator!=(const char *_val) const
101 return key[0] != _val[0] || key[1] != _val[1];
104 inline bool operator<(const VRKey &_val) const
106 return key[0] < _val[0] || (key[0] == _val[0] && key[1] < _val[1]);
113 //-----------------------------------------------------------------------------
114 inline std::ostream &operator<<(std::ostream &_os, const VRKey &_val)
116 _os << _val.key[0] << _val.key[1];
120 inline std::istream &operator>>(std::istream &_is, VRKey &_val)
122 _is >> _val.key[0] >> _val.key[1];
126 //-----------------------------------------------------------------------------
128 } // end namespace gdcm
130 //-----------------------------------------------------------------------------