]> Creatis software - gdcm.git/commitdiff
* Adaptation for porting to VC++:
authorfrog <frog>
Fri, 8 Nov 2002 14:07:05 +0000 (14:07 +0000)
committerfrog <frog>
Fri, 8 Nov 2002 14:07:05 +0000 (14:07 +0000)
        - src/gdcm.h
          o forced to use std namespace (for string to be known)
          o all class use __declspec export style on WIN32
        - src/gdcmUtil.cxx new Exit method that wraps the exit call
          (in stdlib.h on Win32 but in std:: for gcc)
      * src/gdcmDictSet::SetDictPath adds a trailing / to environement
        variable GDCM_DICT_PATH.
      * src/gdcmHeader.cxx verbose comments made discrete. --- Frog

src/gdcm.h
src/gdcmDictSet.cxx
src/gdcmHeader.cxx
src/gdcmUtil.cxx
src/gdcmUtil.h

index 82df4e543333a60a0015cdfbf0a4f48f6c35df53..c8806c7ccbe1919399167625a06dbf68074495fb 100644 (file)
 
 #include <string>
 #include <iostream>
-#include <stddef.h>    // For size_t
+#include <stddef.h>   // For size_t
 #include <glib.h>
-#include <stdio.h>
+#include <stdio.h>    // CLEANME
+#include <map>        // The requirement for the hash table (or map) that
+                      // we shall use:
+                      // 1/ First, next, last (iterators)
+                      // 2/ should be sortable (i.e. sorted by TagKey). This
+                      //    condition shall be droped since the Win32/VC++
+                      //    implementation doesn't look a sorted one. Pffff....
+                      // 3/ Make sure we can setup some default size value,
+                      //    which should be around 4500 entries which is the
+                      //    average dictionary size (said JPR)
 
-
-// The requirement for the hash table (or map) that we shall use:
-// 1/ First, next, last (iterators)
-// 2/ should be sortable (i.e. sorted by TagKey). This condition
-//    shall be droped since the Win32/VC++ implementation doesn't look
-//    a sorted one. Pffff....
-// 3/ Make sure we can setup some default size value, which should be
-//    around 4500 entries which is the average dictionary size (said JPR)
-#include <map>
-using namespace std;
+#ifdef _MSC_VR
+       using namespace std;  // string type lives in the std namespace on VC++
+#endif
+#ifdef _MSC_VR
 #define GDCM_EXPORT __declspec( dllexport )
+#else
+#define GDCM_EXPORT
+#endif
+
 // Tag based hash tables.
 // We shall use as keys the strings (as the C++ type) obtained by
 // concatenating the group value and the element value (both of type
index 814ca802e223811cb31c608db41defeedf6d7bda..3e0cc03678c6a58a993b25629a54cd2752d4d899 100644 (file)
@@ -16,9 +16,13 @@ gdcmDictSet::gdcmDictSet(void) {
 void gdcmDictSet::SetDictPath(void) {
        const char* EnvPath = (char*)0;
        EnvPath = getenv("GDCM_DICT_PATH");
-       if (EnvPath && (strlen(EnvPath) != 0))
+       if (EnvPath && (strlen(EnvPath) != 0)) {
                DictPath = EnvPath;
-       else
+               if (DictPath[DictPath.length() -1] != '/' )
+                       DictPath += '/';
+               dbg.Verbose(1, "gdcmDictSet::SetDictPath:",
+                     "Dictionary path set from environnement");
+       } else
                DictPath = PUB_DICT_PATH;
 }
 
@@ -31,7 +35,7 @@ int gdcmDictSet::LoadDicomV3Dict(void) {
 int gdcmDictSet::LoadDictFromFile(string FileName, DictKey Name) {
        gdcmDict *NewDict = new gdcmDict(FileName.c_str());
        dicts[Name] = NewDict;
-       return 0;
+       return 0;   //FIXME if this is a dummy return make the method void
 }
 
 void gdcmDictSet::Print(ostream& os) {
index 856e6f4504812369a343cc3e094e4969057ca2a1..2f5eac1c50b597a99987316e556c332413bf6613 100644 (file)
@@ -129,10 +129,10 @@ void gdcmHeader::CheckSwap()
        entCur = deb + 128;
        if(memcmp(entCur, "DICM", (size_t)4) == 0) {
                filetype = TrueDicom;
-               dbg.Verbose(0, "gdcmHeader::CheckSwap:", "looks like DICOM Version3");
+               dbg.Verbose(1, "gdcmHeader::CheckSwap:", "looks like DICOM Version3");
        } else {
                filetype = Unknown;
-               dbg.Verbose(0, "gdcmHeader::CheckSwap:", "not a DICOM Version3 file");
+               dbg.Verbose(1, "gdcmHeader::CheckSwap:", "not a DICOM Version3 file");
        }
 
        if(filetype == TrueDicom) {
index c6a7576e6485b7d8e92841610b75daba9df99877..ac84c824094136e5c5f733b037b7ad402bb3d418 100644 (file)
@@ -23,13 +23,22 @@ void gdcmDebug::Error( bool Test, const char * Msg1, const char * Msg2) {
        if (!Test)
                return;
        std::cerr << Msg1 << ' ' << Msg2 << '\n';
-       exit(1);
+       Exit(1);
 }
 
 void gdcmDebug::Error(const char* Msg1, const char* Msg2,
                       const char* Msg3) {
        std::cerr << Msg1 << ' ' << Msg2 << ' ' << Msg3 << '\n';
-       exit(1);
+       Exit(1);
+}
+
+void gdcmDebug::Exit(int a) {
+#ifdef __GNUC__
+       std::exit(a);
+#endif
+#ifdef _MSC_VER
+       exit(a);    // Found in #include <stdlib.h>
+#endif
 }
 
 gdcmDebug dbg;
index 63025122aaedc860df3181073a49fb2a6bedd409..4f19b3ae23966d62b26d944794c4fdef200105ce 100644 (file)
@@ -10,6 +10,7 @@ public:
        void Error(bool, const char*,  const char* ="");
        void Error(const char*, const char* ="", const char* ="");
        void Assert(int, bool, const char*, const char*);
+       void Exit(int);
 };
 
 istream & eatwhite(istream & is);