X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDict.cxx;h=bba44f7983da40b2adbb417ac47fa81b29a11865;hb=fdef18c217469cc507704db6d686ce195e82e4ce;hp=acd88f8931c9cf2664dc7812b7f94139351ca10e;hpb=7589d23967892c94462e22a49ec50fcd225c5c38;p=gdcm.git diff --git a/src/gdcmDict.cxx b/src/gdcmDict.cxx index acd88f89..bba44f79 100644 --- a/src/gdcmDict.cxx +++ b/src/gdcmDict.cxx @@ -1,9 +1,14 @@ // gdcmDict.cxx -#include #include "gdcmDict.h" #include "gdcmUtil.h" -using namespace std; +#include +#ifdef GDCM_NO_ANSI_STRING_STREAM +# include +# define ostringstream ostrstream +# else +# include +#endif /** * \ingroup gdcmDict @@ -21,6 +26,7 @@ gdcmDict::gdcmDict(std::string & FileName) { TagName vr; TagName fourth; TagName name; + while (!from.eof()) { from >> std::hex >> group >> element; eatwhite(from); @@ -32,7 +38,7 @@ gdcmDict::gdcmDict(std::string & FileName) { from.getline(buff, 256, '\n'); name = buff; gdcmDictEntry * newEntry = new gdcmDictEntry(group, element, - vr, fourth, name); + vr, fourth, name); // FIXME: use AddNewEntry NameHt[name] = newEntry; KeyHt[gdcmDictEntry::TranslateToKey(group, element)] = newEntry; @@ -52,7 +58,7 @@ gdcmDict::~gdcmDict() { } KeyHt.clear(); // Since AddNewEntry adds symetrical in both KeyHt and NameHT we can - // assume all the pointed gdcmDictEntries are allready cleaned-up when + // assume all the pointed gdcmDictEntries are already cleaned-up when // we cleaned KeyHt. NameHt.clear(); } @@ -73,14 +79,17 @@ void gdcmDict::Print(std::ostream& os) { * @param os The output stream to be written to. */ void gdcmDict::PrintByKey(std::ostream& os) { + std::ostringstream s; + for (TagKeyHT::iterator tag = KeyHt.begin(); tag != KeyHt.end(); ++tag){ - os << "Tag : "; - os << "(" << hex << tag->second->GetGroup() << ','; - os << hex << tag->second->GetElement() << ") = " << dec; - os << tag->second->GetVR() << ", "; - os << tag->second->GetFourth() << ", "; - os << tag->second->GetName() << "." << endl; + s << "Tag : "; + s << "(" << std::hex << tag->second->GetGroup() << ','; + s << std::hex << tag->second->GetElement() << ") = " << std::dec; + s << tag->second->GetVR() << ", "; + s << tag->second->GetFourth() << ", "; + s << tag->second->GetName() << "." << std::endl; } + os << s.str(); } /** @@ -90,14 +99,17 @@ void gdcmDict::PrintByKey(std::ostream& os) { * @param os The output stream to be written to. */ void gdcmDict::PrintByName(std::ostream& os) { + std::ostringstream s; + for (TagNameHT::iterator tag = NameHt.begin(); tag != NameHt.end(); ++tag){ - os << "Tag : "; - os << tag->second->GetName() << ","; - os << tag->second->GetVR() << ", "; - os << tag->second->GetFourth() << ", "; - os << "(" << std::hex << tag->second->GetGroup() << ','; - os << std::hex << tag->second->GetElement() << ") = " << dec << std::endl; + s << "Tag : "; + s << tag->second->GetName() << ","; + s << tag->second->GetVR() << ", "; + s << tag->second->GetFourth() << ", "; + s << "(" << std::hex << tag->second->GetGroup() << ','; + s << std::hex << tag->second->GetElement() << ") = " << std::dec << std::endl; } + os << s.str(); } /** @@ -151,7 +163,7 @@ int gdcmDict::ReplaceEntry(gdcmDictEntry* NewEntry) { key = NewEntry->GetKey(); if(KeyHt.count(key) == 1) { - dbg.Verbose(1, "gdcmDict::AddNewEntry allready present", key.c_str()); + dbg.Verbose(1, "gdcmDict::AddNewEntry already present", key.c_str()); return(0); } else { KeyHt[NewEntry->GetKey()] = NewEntry;