1 #include <creaImageIOTreeAttributeDescriptor.h>
2 #include <creaImageIOSystem.h>
4 #include <gdcmGlobal.h>
5 #include <gdcmDictSet.h>
7 #include <boost/algorithm/string/replace.hpp>
15 //========================================================================
16 void AttributeDescriptor::CleanName(std::string& str) const
18 // quote must be doubled for SQL
19 // crea::Utils::Replace( str, "'", "''" );
20 boost::algorithm::replace_all(str,"'","''");
21 // Found strange strings which contained NULL char INSIDE string
22 int i,size=str.size();
27 str = str.substr(0,i);
32 //========================================================================
34 //=====================================================================
35 // Ctor with key, name and flags
36 AttributeDescriptor::AttributeDescriptor(const std::string& key,
37 const std::string& name,
39 : mKey(key), mName(name), mGroup(0), mElement(0), mFlags(flags)
43 GimmickDebugMessage(3,"AttributeDescriptor : '"<<key
44 <<"' ["<<flags<<"]"<<std::endl);
45 GimmickDebugMessage(3,"='"<<mName<<"'"<<std::endl);
48 //=====================================================================
50 //=====================================================================
51 // Ctor with dicom group, elem and flags
52 // The key is built as 'Dgroup_elem'
53 // The user name is retreived from dicom dictionnary
54 AttributeDescriptor::AttributeDescriptor(unsigned short group,
55 unsigned short element,
57 : mGroup(group), mElement(element), mFlags(flags)
60 //GDCM_NAME_SPACE::TagKey tag(group,element);
62 sprintf(ctag,"D%04x_%04x",group,element);
63 std::string tag(ctag);
65 GimmickDebugMessage(3,"AttributeDescriptor : '"<<tag
66 <<"' ["<<flags<<"]"<<std::endl);
70 // Retrieve the name from gdcm dict
71 GDCM_NAME_SPACE::DictEntry* entry =
72 GDCM_NAME_SPACE::Global::GetDicts()
73 ->GetDefaultPubDict()->GetEntry(mGroup,mElement);
77 mName = entry->GetName();
79 GimmickDebugMessage(3,"='"<<mName<<"'"<<std::endl);
83 GimmickMessage(1,"!! WARNING : tag '"<<tag
84 <<"' is not in DICOM dictionnary ! "
85 <<"Considering it as a user attribute"
88 mGroup = mElement = 0;
92 //=====================================================================
95 //=====================================================================
96 /// Extracts group and element from a key of the form "Dgroup_elem"
97 void AttributeDescriptor::GetDicomGroupElementFromKey(const std::string& key,
98 unsigned short& group,
102 if ( (key.size()==10) &&
106 sscanf(key.c_str(),"D%04x_%04x",&group,&elem);
110 //=====================================================================
112 } // EO namespace tree
114 } // EO namespace creaImageIO