GDCM 2.2.1

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

gdcmPrivateTag.h
Go to the documentation of this file.
1 /*=========================================================================
2
3 Program: GDCM (Grassroots DICOM). A DICOM library
4
5 Copyright (c) 2006-2011 Mathieu Malaterre
6 All rights reserved.
7 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notice for more information.
12
13 =========================================================================*/
14 #ifndef GDCMPRIVATETAG_H
15 #define GDCMPRIVATETAG_H
16
17 #include "gdcmTag.h"
18 #include "gdcmSystem.h" // FIXME
19
20 #include <iostream>
21 #include <iomanip>
22 #include <string>
23 #include <algorithm>
24
25 #include <string.h> // strlen
26 #include <ctype.h> // tolower
27
28 namespace gdcm
29 {
30
36 class GDCM_EXPORT PrivateTag : public Tag
37 {
38 friend std::ostream& operator<<(std::ostream &_os, const PrivateTag &_val);
39 public:
40 PrivateTag(uint16_t group = 0, uint16_t element = 0, const char *owner = ""):Tag(group,element),Owner(owner) {
41 std::transform(Owner.begin(), Owner.end(), Owner.begin(), ::tolower);
42 // truncate the high bits
43 SetElement( (uint8_t)element );
44
45 // TODO:
46 // by default the cstor create with 0x0,0x0 which is invalid...
47 //assert( GetElement() >= 0x0010 && GetElement() < 0x100 );
48 }
49
50 const char *GetOwner() const { return Owner.c_str(); }
51 void SetOwner(const char *owner) { Owner = owner; }
52
53 bool operator<(const PrivateTag &_val) const
54 {
55 const Tag & t1 = *this;
56 const Tag & t2 = _val;
57 if( t1 == t2 )
58 {
59 const char *s1 = Owner.c_str();
60 const char *s2 = _val.GetOwner();
61 assert( s1[strlen(s1)-1] != ' ' );
62 assert( s2[strlen(s2)-1] != ' ' );
63 bool res = strcmp(s1, s2) < 0;
64 #ifndef NDEBUG
65 if( *s1 && *s2 && gdcm::System::StrCaseCmp(s1,s2) == 0 && strcmp(s1,s2) != 0 )
66 {
67 // FIXME:
68 // Typically this should only happen with the "Philips MR Imaging DD 001" vs "PHILIPS MR IMAGING DD 001"
69 // or "Philips Imaging DD 001" vr "PHILIPS IMAGING DD 001"
70 //assert( strcmp(Owner.c_str(), _val.GetOwner()) == 0 );
71 //return true;
72 res = gdcm::System::StrCaseCmp(s1,s2) < 0;
73 assert(0);
74 }
75 #endif
76 return res;
77 }
78 else return t1 < t2;
79 }
80
81 bool ReadFromCommaSeparatedString(const char *str);
82
83 private:
84 // SIEMENS MED, GEMS_PETD_01 ...
85 std::string Owner;
86 };
87
88 inline std::ostream& operator<<(std::ostream &os, const PrivateTag &val)
89 {
90 //assert( !val.Owner.empty() );
91 os.setf( std::ios::right );
92 os << std::hex << '(' << std::setw( 4 ) << std::setfill( '0' )
93 << val[0] << ',' << std::setw( 2 ) << std::setfill( '0' )
94 << val[1] << ',';
95 os << val.Owner;
96 os << ')' << std::setfill( ' ' ) << std::dec;
97 return os;
98 }
99
100 } // end namespace gdcm
101
102 #endif //GDCMPRIVATETAG_H