X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmElValSet.cxx;h=a2781df6249b882a6e15610bb07a321f66b37cf5;hb=8025df97287221b537f940925f3f87730b0d1e48;hp=58302b3d37979d44641b114cb86b393bbbbc85a6;hpb=b158878c883def8179e3eccc27fcea5bb6035a4c;p=gdcm.git diff --git a/src/gdcmElValSet.cxx b/src/gdcmElValSet.cxx index 58302b3d..a2781df6 100644 --- a/src/gdcmElValSet.cxx +++ b/src/gdcmElValSet.cxx @@ -1,10 +1,9 @@ // gdcmElValSet.cxx -#include #include "gdcmUtil.h" #include "gdcmElValSet.h" #include "gdcmTS.h" -using namespace std; +#include gdcmElValSet::~gdcmElValSet() { for (TagElValueHT::iterator tag = tagHt.begin(); tag != tagHt.end(); ++tag) { @@ -43,7 +42,7 @@ void gdcmElValSet::Add(gdcmElValue * newElValue) { * @return */ int gdcmElValSet::CheckIfExistByNumber(guint16 Group, guint16 Elem ) { - string key = TranslateToKey(Group, Elem ); + std::string key = TranslateToKey(Group, Elem ); return (tagHt.count(key)); } @@ -51,13 +50,12 @@ int gdcmElValSet::CheckIfExistByNumber(guint16 Group, guint16 Elem ) { * \ingroup gdcmElValSet * \brief */ -void gdcmElValSet::Print(ostream & os) { +void gdcmElValSet::Print(std::ostream & os) { size_t o; short int g, e; TSKey v; - char * d; - string d2; + std::string d2; gdcmTS * ts = gdcmGlobal::GetTS(); for (TagElValueHT::iterator tag = tagHt.begin(); @@ -67,13 +65,12 @@ void gdcmElValSet::Print(ostream & os) { e = tag->second->GetElement(); v = tag->second->GetValue(); o = tag->second->GetOffset(); - d = _CreateCleanString(v); // replace non printable characters by '.' - d2=d; + d2 = _CreateCleanString(v); // replace non printable characters by '.' os << tag->first << ": "; os << " lgr : " << tag->second->GetLength(); os << ", Offset : " << o; - os << " x(" << hex << o << dec << ") "; + os << " x(" << std::hex << o << std::dec << ") "; os << "\t[" << tag->second->GetVR() << "]"; os << "\t[" << tag->second->GetName() << "]"; os << "\t[" << d2 << "]"; @@ -88,8 +85,7 @@ void gdcmElValSet::Print(ostream & os) { os << " ==>\t[" << ts->GetValue(v) << "]"; } } - free(d); - os << endl; + os << std::endl; } } @@ -97,14 +93,14 @@ void gdcmElValSet::Print(ostream & os) { * \ingroup gdcmElValSet * \brief */ -void gdcmElValSet::PrintByName(ostream & os) { +void gdcmElValSet::PrintByName(std::ostream & os) { for (TagElValueNameHT::iterator tag = NameHt.begin(); tag != NameHt.end(); ++tag){ os << tag->first << ": "; os << "[" << tag->second->GetValue() << "]"; os << "[" << tag->second->GetKey() << "]"; - os << "[" << tag->second->GetVR() << "]" << endl; + os << "[" << tag->second->GetVR() << "]" << std::endl; } } @@ -127,7 +123,7 @@ gdcmElValue* gdcmElValSet::GetElementByNumber(guint16 group, guint16 element) { * \brief * @return */ -gdcmElValue* gdcmElValSet::GetElementByName(string TagName) { +gdcmElValue* gdcmElValSet::GetElementByName(std::string TagName) { if ( ! NameHt.count(TagName)) return (gdcmElValue*)0; return NameHt.find(TagName)->second; @@ -140,10 +136,10 @@ gdcmElValue* gdcmElValSet::GetElementByName(string TagName) { * @param element * @return */ -string gdcmElValSet::GetElValueByNumber(guint16 group, guint16 element) { +std::string gdcmElValSet::GetElValueByNumber(guint16 group, guint16 element) { TagKey key = gdcmDictEntry::TranslateToKey(group, element); if ( ! tagHt.count(key)) - return "gdcm::Unfound"; + return GDCM_UNFOUND; return tagHt.find(key)->second->GetValue(); } @@ -152,9 +148,9 @@ string gdcmElValSet::GetElValueByNumber(guint16 group, guint16 element) { * \brief * @return */ -string gdcmElValSet::GetElValueByName(string TagName) { +std::string gdcmElValSet::GetElValueByName(std::string TagName) { if ( ! NameHt.count(TagName)) - return "gdcm::Unfound"; + return GDCM_UNFOUND; return NameHt.find(TagName)->second->GetValue(); } @@ -166,13 +162,13 @@ string gdcmElValSet::GetElValueByName(string TagName) { * @param element * @return */ -int gdcmElValSet::SetElValueByNumber(string content, +int gdcmElValSet::SetElValueByNumber(std::string content, guint16 group, guint16 element) { TagKey key = gdcmDictEntry::TranslateToKey(group, element); if ( ! tagHt.count(key)) return 0; tagHt[key]->SetValue(content); - string vr = tagHt[key]->GetVR(); + std::string vr = tagHt[key]->GetVR(); guint32 lgr; if( (vr == "US") || (vr == "SS") ) @@ -192,11 +188,11 @@ int gdcmElValSet::SetElValueByNumber(string content, * @param TagName * @return */ -int gdcmElValSet::SetElValueByName(string content, string TagName) { +int gdcmElValSet::SetElValueByName(std::string content, std::string TagName) { if ( ! NameHt.count(TagName)) return 0; NameHt[TagName]->SetValue(content); - string vr = NameHt[TagName]->GetVR(); + std::string vr = NameHt[TagName]->GetVR(); guint32 lgr; if( (vr == "US") || (vr == "SS") ) @@ -270,7 +266,7 @@ int gdcmElValSet::SetElValueLengthByNumber(guint32 length, * @param TagName * @return */ -int gdcmElValSet::SetElValueLengthByName(guint32 length, string TagName) { +int gdcmElValSet::SetElValueLengthByName(guint32 length, std::string TagName) { if ( ! NameHt.count(TagName)) return 0; NameHt.find(TagName)->second->SetLength(length); @@ -285,11 +281,11 @@ int gdcmElValSet::SetElValueLengthByName(guint32 length, string TagName) { */ void gdcmElValSet::UpdateGroupLength(bool SkipSequence, FileType type) { guint16 gr, el; - string vr; + std::string vr; gdcmElValue *elem; char trash[10]; - string str_trash; + std::string str_trash; GroupKey key; GroupHT groupHt; // to hold the length of each group @@ -379,16 +375,16 @@ void gdcmElValSet::WriteElements(FileType type, FILE * _fp) { guint16 gr, el; guint32 lgr; const char * val; - string vr; + std::string vr; guint32 val_uint32; guint16 val_uint16; - vector tokens; + std::vector tokens; void *ptr; // Tout ceci ne marche QUE parce qu'on est sur un proc Little Endian - // restent à tester les echecs en écriture (apres chaque fwrite) + // restent à tester les echecs en écriture (apres chaque fwrite) for (TagElValueHT::iterator tag2=tagHt.begin(); tag2 != tagHt.end(); @@ -400,7 +396,7 @@ void gdcmElValSet::WriteElements(FileType type, FILE * _fp) { val = tag2->second->GetValue().c_str(); vr = tag2->second->GetVR(); - // cout << "Tag "<< hex << gr << " " << el << "\n"; + // std::cout << "Tag "<< std::hex << gr << " " << el << std::endl; if ( type == ACR ) { if (gr < 0x0008) continue; // ignore pure DICOM V3 groups @@ -468,7 +464,7 @@ void gdcmElValSet::WriteElements(FileType type, FILE * _fp) { int gdcmElValSet::Write(FILE * _fp, FileType type) { if (type == ImplicitVR) { - string implicitVRTransfertSyntax = "1.2.840.10008.1.2"; + std::string implicitVRTransfertSyntax = "1.2.840.10008.1.2"; SetElValueByNumber(implicitVRTransfertSyntax, 0x0002, 0x0010); //FIXME Refer to standards on page 21, chapter 6.2 "Value representation": @@ -484,7 +480,7 @@ int gdcmElValSet::Write(FILE * _fp, FileType type) { // no way if (type == ExplicitVR) { - string explicitVRTransfertSyntax = "1.2.840.10008.1.2.1"; + std::string explicitVRTransfertSyntax = "1.2.840.10008.1.2.1"; SetElValueByNumber(explicitVRTransfertSyntax, 0x0002, 0x0010); // See above comment SetElValueLengthByNumber(20, 0x0002, 0x0010);