From 1a4c3a039ea7c7fc09419ffe3c28ed7827866788 Mon Sep 17 00:00:00 2001 From: frog Date: Fri, 8 Nov 2002 14:07:05 +0000 Subject: [PATCH] * Adaptation for porting to VC++: - 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 | 31 +++++++++++++++++++------------ src/gdcmDictSet.cxx | 10 +++++++--- src/gdcmHeader.cxx | 4 ++-- src/gdcmUtil.cxx | 13 +++++++++++-- src/gdcmUtil.h | 1 + 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/src/gdcm.h b/src/gdcm.h index 82df4e54..c8806c7c 100644 --- a/src/gdcm.h +++ b/src/gdcm.h @@ -17,21 +17,28 @@ #include #include -#include // For size_t +#include // For size_t #include -#include +#include // CLEANME +#include // 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 -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 diff --git a/src/gdcmDictSet.cxx b/src/gdcmDictSet.cxx index 814ca802..3e0cc036 100644 --- a/src/gdcmDictSet.cxx +++ b/src/gdcmDictSet.cxx @@ -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) { diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index 856e6f45..2f5eac1c 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -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) { diff --git a/src/gdcmUtil.cxx b/src/gdcmUtil.cxx index c6a7576e..ac84c824 100644 --- a/src/gdcmUtil.cxx +++ b/src/gdcmUtil.cxx @@ -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 +#endif } gdcmDebug dbg; diff --git a/src/gdcmUtil.h b/src/gdcmUtil.h index 63025122..4f19b3ae 100644 --- a/src/gdcmUtil.h +++ b/src/gdcmUtil.h @@ -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); -- 2.48.1