]> Creatis software - gdcm.git/blobdiff - src/gdcmDict.cxx
* src/gdcmDict.cxx, gdcmElValSet.cxx : bug fix under windows for prints.
[gdcm.git] / src / gdcmDict.cxx
index 6808a8d0b27778cf83e319aefdab33fc3c875b85..bba44f7983da40b2adbb417ac47fa81b29a11865 100644 (file)
@@ -1,19 +1,14 @@
 // gdcmDict.cxx
 
-//This is needed when compiling in debug mode
-#ifdef _MSC_VER
-// 'identifier' : class 'type' needs to have dll-interface to be used by
-// clients of class 'type2'
-#pragma warning ( disable : 4251 )
-// 'identifier' : identifier was truncated to 'number' characters in the
-// debug information
-#pragma warning ( disable : 4786 )
-#endif //_MSC_VER
-
-#include <fstream>
 #include "gdcmDict.h"
 #include "gdcmUtil.h"
-using namespace std;
+#include <fstream>
+#ifdef GDCM_NO_ANSI_STRING_STREAM
+#  include <strstream>
+#  define  ostringstream ostrstream
+# else
+#  include <sstream>
+#endif
 
 /**
  * \ingroup gdcmDict
@@ -31,6 +26,7 @@ gdcmDict::gdcmDict(std::string & FileName) {
    TagName vr;
    TagName fourth;
    TagName name;
+
    while (!from.eof()) {
       from >> std::hex >> group >> element;
       eatwhite(from);
@@ -42,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;
@@ -83,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();
 }
 
 /**
@@ -100,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();
 }
 
 /**