1 /*=========================================================================
4 Module: $RCSfile: gdcmVRKey.h,v $
6 Date: $Date: 2005/10/19 13:17:05 $
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"
28 //-----------------------------------------------------------------------------
32 inline VRKey() { key[0] = key[1] = ' ';}
33 inline VRKey(const char *_key) { key[0] = _key[0]; key[1] = _key[1];}
34 inline VRKey(const std::string &_key) { key[0] = _key[0]; key[1] = _key[1];}
36 inline std::string str() const { return std::string(key,2); }
38 friend std::ostream& operator<<(std::ostream& _os, const VRKey &_val);
39 friend std::istream& operator>>(std::istream& _is, VRKey &_val);
41 inline VRKey &operator=(const VRKey &_val)
47 inline VRKey &operator=(const std::string &_val)
53 inline VRKey &operator=(const char *_val)
60 inline const char &operator[](const unsigned int &_id) const
65 inline char &operator[](const unsigned int &_id)
71 inline bool operator==(const VRKey &_val) const
73 return key[0] == _val.key[0] && key[1] == _val.key[1];
75 inline bool operator==(const std::string &_val) const
77 return key[0] == _val[0] && key[1] == _val[1];
79 inline bool operator==(const char *_val) const
81 return key[0] == _val[0] && key[1] == _val[1];
84 inline bool operator!=(const VRKey &_val) const
86 return key[0] != _val.key[0] || key[1] != _val.key[1];
88 inline bool operator!=(const std::string &_val) const
90 return key[0] != _val[0] || key[1] != _val[1];
92 inline bool operator!=(const char *_val) const
94 return key[0] != _val[0] || key[1] != _val[1];
97 inline bool operator<(const VRKey &_val) const
99 return key[0] < _val[0] || (key[0] == _val[0] && key[1] < _val[1]);
106 //-----------------------------------------------------------------------------
107 inline std::ostream& operator<<(std::ostream& _os, const VRKey &_val)
109 _os << _val.key[0] << _val[1];
113 inline std::istream& operator>>(std::istream& _is, VRKey &_val)
115 _is >> _val.key[0] >> _val[1];
119 //-----------------------------------------------------------------------------
121 } // end namespace gdcm
123 //-----------------------------------------------------------------------------