From 0e82725d64f17545e782c18039ced7ea898f8cad Mon Sep 17 00:00:00 2001 From: frog Date: Fri, 26 Mar 2004 13:33:52 +0000 Subject: [PATCH] * src/gdcmUtil.[cxx|h] split in two. Additional file gdcmDebug.[cxx|h] now contains all the Debug related code. * minor clean-up of includes in src/*.cxx --- ChangeLog | 11 ++- src/Makefile.am | 48 +++++------ src/gdcm.h | 4 +- src/gdcmCommon.h | 8 +- src/gdcmDebug.cxx | 96 ++++++++++++++++++++++ src/gdcmDebug.h | 38 +++++++++ src/gdcmDicomDir.cxx | 16 ++-- src/gdcmDicomDirElement.cxx | 15 ++-- src/gdcmDicomDirPatient.cxx | 1 + src/gdcmDicomDirSerie.cxx | 1 + src/gdcmDict.cxx | 1 + src/gdcmDictEntry.cxx | 4 +- src/gdcmDictSet.cxx | 2 +- src/gdcmFile.cxx | 3 +- src/gdcmHeader.cxx | 6 +- src/gdcmHeaderHelper.cxx | 6 +- src/gdcmObject.cxx | 2 +- src/gdcmParsePixels.cxx | 14 +--- src/gdcmParser.cxx | 8 +- src/gdcmTS.cxx | 17 ++-- src/gdcmUtil.cxx | 153 +++++++++++------------------------- src/gdcmUtil.h | 56 ++----------- src/gdcmVR.cxx | 18 +++-- src/win32/gdcmdll.dsp | 8 ++ 24 files changed, 288 insertions(+), 248 deletions(-) create mode 100644 src/gdcmDebug.cxx create mode 100644 src/gdcmDebug.h diff --git a/ChangeLog b/ChangeLog index 270348ae..ebcadc3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,13 +1,18 @@ +2004-03-26 Eric Boix + * src/gdcmUtil.[cxx|h] split in two. Additional file gdcmDebug.[cxx|h] + now contains all the Debug related code. + * minor clean-up of includes in src/*.cxx + 2004-03-24 Jean-Pierre Roux * FIX a lot of little surface modifications to be doxygen 1.3.6 compliant - + 2004-03-23 Jean-Pierre Roux * FIX Now gdcmFile::SwapZone doesn't seg faults any longer for big endian made volumes * ENH Now gdcmParser constructor and destructor are protected to forbid end user to instanciate class gdcmParser - (only gdcmHeader and gdcmDicomDir are meaningfull) - + (only gdcmHeader and gdcmDicomDir are meaningfull) + 2004-03-22 Benoit Regrain * FIX : src/gdcmDicomDir.cxx : make windows compilable * FIX : gdcmPython/gdcm.i : change gdcmStudy to gdcmDicomDirStudy and diff --git a/src/Makefile.am b/src/Makefile.am index 26911da7..3a0be1cb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,6 +13,7 @@ libgdcm_la_LIBADD = \ $(top_builddir)/src/jpeg/ljpg/libgdcmjpg.la libgdcm_la_SOURCES= \ + gdcmDebug.cxx \ gdcmDicomDir.cxx \ gdcmDicomDirElement.cxx \ gdcmDicomDirImage.cxx \ @@ -42,29 +43,30 @@ libgdcm_la_SOURCES= \ libgdcmincludedir = $(includedir) -libgdcminclude_HEADERS = \ - gdcmCommon.h \ - gdcmDicomDir.h \ - gdcmDicomDirElement.h \ - gdcmDicomDirImage.h \ - gdcmDicomDirMeta.h \ - gdcmDicomDirPatient.h \ - gdcmDicomDirSerie.h \ - gdcmDicomDirStudy.h \ - gdcmDictEntry.h \ - gdcmDict.h \ - gdcmDictSet.h \ - gdcmDirList.h \ - gdcmException.h \ - gdcmFile.h \ - gdcm.h \ - gdcmHeaderEntry.h \ - gdcmHeader.h \ - gdcmHeaderHelper.h \ - gdcmObject.h \ - gdcmParser.h \ - gdcmVR.h \ - gdcmTS.h +libgdcminclude_HEADERS = \ + gdcmCommon.h \ + gdcmDebug.h \ + gdcmDicomDir.h \ + gdcmDicomDirElement.h \ + gdcmDicomDirImage.h \ + gdcmDicomDirMeta.h \ + gdcmDicomDirPatient.h \ + gdcmDicomDirSerie.h \ + gdcmDicomDirStudy.h \ + gdcmDictEntry.h \ + gdcmDict.h \ + gdcmDictSet.h \ + gdcmDirList.h \ + gdcmException.h \ + gdcmFile.h \ + gdcm.h \ + gdcmHeaderEntry.h \ + gdcmHeader.h \ + gdcmHeaderHelper.h \ + gdcmObject.h \ + gdcmParser.h \ + gdcmVR.h \ + gdcmTS.h EXTRA_DIST = \ gdcmUtil.h diff --git a/src/gdcm.h b/src/gdcm.h index 997001a0..bae51665 100644 --- a/src/gdcm.h +++ b/src/gdcm.h @@ -3,7 +3,7 @@ #ifndef GDCM_H #define GDCM_H -//////////////////////////////////////////////////////////////////////////// +//----------------------------------------------------------------------------- // 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 @@ -31,4 +31,4 @@ #include "gdcmUtil.h" //----------------------------------------------------------------------------- -#endif // #ifndef GDCM_H +#endif diff --git a/src/gdcmCommon.h b/src/gdcmCommon.h index ea48792d..97a3ea99 100644 --- a/src/gdcmCommon.h +++ b/src/gdcmCommon.h @@ -3,9 +3,6 @@ #ifndef GDCMCOMMON_H #define GDCMCOMMON_H -//----------------------------------------------------------------------------- -#define GDCM_DEBUG -1 - //----------------------------------------------------------------------------- //This is needed when compiling in debug mode #ifdef _MSC_VER @@ -25,11 +22,10 @@ // return type for 'identifier' is '' (ie; not a UDT or reference to UDT. Will // produce errors if applied using infix notation #pragma warning ( disable : 4284 ) +// 'type' : forcing value to bool 'true' or 'false' (performance warning) +// //#pragma warning ( disable : 4800 ) #endif //_MSC_VER -// Mmmmmm ! -// It reminds me the formerly well known LibIDO's idproto.h - //----------------------------------------------------------------------------- #ifdef __GNUC__ #ifndef HAVE_NO_STDINT_H diff --git a/src/gdcmDebug.cxx b/src/gdcmDebug.cxx new file mode 100644 index 00000000..9963df5a --- /dev/null +++ b/src/gdcmDebug.cxx @@ -0,0 +1,96 @@ +#include +#include "gdcmDebug.h" + +/** + * \ingroup Globals + * \brief Instance of debugging utility. + */ +gdcmDebug dbg; + +/** + * \ingroup gdcmDebug + * \brief constructor + * @param level debug level + */ +gdcmDebug::gdcmDebug(int level) { + DebugLevel = level; +} + +/** + * \ingroup gdcmDebug + * \brief Accessor + * @param level Set the debug level + */ +void gdcmDebug::SetDebug(int level) { + DebugLevel = level; +} + +/** + * \ingroup gdcmDebug + * \brief Verbose + * @param Level level + * @param Msg1 first message part + * @param Msg2 second message part + */ +void gdcmDebug::Verbose(int Level, const char * Msg1, const char * Msg2) { + if (Level > DebugLevel) + return ; + std::cerr << Msg1 << ' ' << Msg2 << std::endl; +} + +/** + * \ingroup gdcmDebug + * \brief Error + * @param Test test + * @param Msg1 first message part + * @param Msg2 second message part + */ +void gdcmDebug::Error( bool Test, const char * Msg1, const char * Msg2) { + if (!Test) + return; + std::cerr << Msg1 << ' ' << Msg2 << std::endl; + Exit(1); +} + +/** + * \ingroup gdcmDebug + * \brief Error + * @param Msg1 first message part + * @param Msg2 second message part + * @param Msg3 Third message part + */ +void gdcmDebug::Error(const char* Msg1, const char* Msg2, + const char* Msg3) { + std::cerr << Msg1 << ' ' << Msg2 << ' ' << Msg3 << std::endl; + Exit(1); +} + +/** + * \ingroup gdcmDebug + * \brief Assert + * @param Level level + * @param Test test + * @param Msg1 first message part + * @param Msg2 second message part + */ + void gdcmDebug::Assert(int Level, bool Test, + const char * Msg1, const char * Msg2) { + if (Level > DebugLevel) + return ; + if (!Test) + std::cerr << Msg1 << ' ' << Msg2 << std::endl; +} + +/** + * \ingroup gdcmDebug + * \brief Exit + * @param a return code + */ +void gdcmDebug::Exit(int a) { +#ifdef __GNUC__ + std::exit(a); +#endif +#ifdef _MSC_VER + exit(a); // Found in #include +#endif +} diff --git a/src/gdcmDebug.h b/src/gdcmDebug.h new file mode 100644 index 00000000..886e2ec4 --- /dev/null +++ b/src/gdcmDebug.h @@ -0,0 +1,38 @@ +// gdcmDebug.h +//----------------------------------------------------------------------------- +#ifndef GDCMDEBUG_H +#define GDCMDEBUG_H + +#define GDCM_DEBUG -1 + +/** + * \ingroup gdcmDebug + * \brief gdcmDebug is an object for debugging in program. + * It has 2 debugging modes : + * - error : for bad library use + * - debug : for debugging messages + * + * A debugging message has a level of priority and is + * Shown only when the debug level is higher than the + * message level. + */ +class gdcmDebug { +public: + gdcmDebug(int level = GDCM_DEBUG); + + void SetDebug (int level); + void Verbose(int, const char*, const char* =""); + 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); + +private: +/// warning message level to be displayed + int DebugLevel; +}; + +extern gdcmDebug dbg; + +#endif diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index b5fba687..c24e2198 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -1,15 +1,7 @@ // gdcmDicomDir.cxx //----------------------------------------------------------------------------- -#include "gdcmDicomDir.h" -#include "gdcmDicomDirStudy.h" -#include "gdcmDicomDirSerie.h" -#include "gdcmDicomDirImage.h" -#include "gdcmDirList.h" -#include "gdcmUtil.h" - #include #include - #include #include @@ -19,6 +11,14 @@ #include #endif +#include "gdcmDicomDir.h" +#include "gdcmDicomDirStudy.h" +#include "gdcmDicomDirSerie.h" +#include "gdcmDicomDirImage.h" +#include "gdcmDirList.h" +#include "gdcmUtil.h" +#include "gdcmDebug.h" + //----------------------------------------------------------------------------- // For full DICOMDIR description, see: // PS 3.3-2003, pages 731-750 diff --git a/src/gdcmDicomDirElement.cxx b/src/gdcmDicomDirElement.cxx index c26b9d32..be6ce165 100644 --- a/src/gdcmDicomDirElement.cxx +++ b/src/gdcmDicomDirElement.cxx @@ -2,22 +2,23 @@ //----------------------------------------------------------------------------- #include #include // For sprintf +#include +#ifdef GDCM_NO_ANSI_STRING_STREAM +# include +# define ostringstream ostrstream +# else +# include +#endif #include "gdcmDicomDirElement.h" #include "gdcmUtil.h" +#include "gdcmDebug.h" #ifndef PUB_DICT_PATH # define PUB_DICT_PATH "../Dicts/" #endif #define DICT_ELEM "DicomDir.dic" -#include -#ifdef GDCM_NO_ANSI_STRING_STREAM -# include -# define ostringstream ostrstream -# else -# include -#endif //----------------------------------------------------------------------------- // Constructor / Destructor diff --git a/src/gdcmDicomDirPatient.cxx b/src/gdcmDicomDirPatient.cxx index 2ab6f894..57358bbf 100644 --- a/src/gdcmDicomDirPatient.cxx +++ b/src/gdcmDicomDirPatient.cxx @@ -3,6 +3,7 @@ #include "gdcmDicomDirPatient.h" #include "gdcmDicomDirElement.h" #include "gdcmUtil.h" + //----------------------------------------------------------------------------- // Constructor / Destructor /** diff --git a/src/gdcmDicomDirSerie.cxx b/src/gdcmDicomDirSerie.cxx index 7324e059..e805e27e 100644 --- a/src/gdcmDicomDirSerie.cxx +++ b/src/gdcmDicomDirSerie.cxx @@ -3,6 +3,7 @@ #include "gdcmDicomDirSerie.h" #include "gdcmDicomDirElement.h" #include "gdcmUtil.h" + //----------------------------------------------------------------------------- // Constructor / Destructor /** diff --git a/src/gdcmDict.cxx b/src/gdcmDict.cxx index 75834e1f..b5bdea34 100644 --- a/src/gdcmDict.cxx +++ b/src/gdcmDict.cxx @@ -2,6 +2,7 @@ //----------------------------------------------------------------------------- #include "gdcmDict.h" #include "gdcmUtil.h" +#include "gdcmDebug.h" #include #include diff --git a/src/gdcmDictEntry.cxx b/src/gdcmDictEntry.cxx index bdabafbe..da623a2e 100644 --- a/src/gdcmDictEntry.cxx +++ b/src/gdcmDictEntry.cxx @@ -1,9 +1,9 @@ // gdcmDictEntry.cxx //----------------------------------------------------------------------------- #include "gdcmDictEntry.h" +#include "gdcmDebug.h" #include // FIXME For sprintf -#include "gdcmUtil.h" //----------------------------------------------------------------------------- // Constructor / Destructor @@ -46,7 +46,7 @@ gdcmDictEntry::gdcmDictEntry(guint16 InGroup, guint16 InElement, TagKey gdcmDictEntry::TranslateToKey(guint16 group, guint16 element) { char trash[10]; TagKey key; - // CLEAN ME: better call the iostream<< with the hex manipulator on. + // CLEANME: better call the iostream<< with the hex manipulator on. // This requires some reading of the stdlibC++ sources to make the // proper call (or copy). sprintf(trash, "%04x|%04x", group , element); diff --git a/src/gdcmDictSet.cxx b/src/gdcmDictSet.cxx index d1e21100..e2c12ef4 100644 --- a/src/gdcmDictSet.cxx +++ b/src/gdcmDictSet.cxx @@ -1,7 +1,7 @@ // gdcmDictEntry //----------------------------------------------------------------------------- #include "gdcmDictSet.h" -#include "gdcmUtil.h" +#include "gdcmDebug.h" #include #include // For getenv diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 8e84268d..633d4d2f 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -1,7 +1,7 @@ // gdcmFile.cxx //----------------------------------------------------------------------------- #include "gdcmFile.h" -#include "gdcmUtil.h" +#include "gdcmDebug.h" #include "jpeg/ljpg/jpegless.h" typedef std::pair IterHT; @@ -22,7 +22,6 @@ typedef std::pair IterHT; * @param header file to be opened for reading datas * @return */ - gdcmFile::gdcmFile(gdcmHeader *header) { Header=header; SelfHeader=false; diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index f230f4de..f0fdcf33 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -1,15 +1,15 @@ // gdcmHeader.cxx //----------------------------------------------------------------------------- -#include "gdcmHeader.h" - #include #include #include // for isalpha +#include +#include "gdcmHeader.h" #include "gdcmUtil.h" +#include "gdcmDebug.h" #include "gdcmTS.h" - //----------------------------------------------------------------------------- // Constructor / Destructor /** diff --git a/src/gdcmHeaderHelper.cxx b/src/gdcmHeaderHelper.cxx index a9af79bc..3410c65b 100644 --- a/src/gdcmHeaderHelper.cxx +++ b/src/gdcmHeaderHelper.cxx @@ -3,14 +3,12 @@ #include "gdcmHeaderHelper.h" #include "gdcmDirList.h" -#include "gdcmUtil.h" //for debug +#include "gdcmDebug.h" #include #include +#include //----------------------------------------------------------------------------- -// gdcmHeaderHelper -//----------------------------------------------------------------------------- -// Constructor / Destructor /** * \ingroup gdcmHeaderHelper * \brief constructor diff --git a/src/gdcmObject.cxx b/src/gdcmObject.cxx index 1d39f1e3..cef90977 100644 --- a/src/gdcmObject.cxx +++ b/src/gdcmObject.cxx @@ -2,9 +2,9 @@ //----------------------------------------------------------------------------- #include "gdcmObject.h" #include "gdcmUtil.h" +#include "gdcmDebug.h" //----------------------------------------------------------------------------- -// Constructor / Destructor /** * \ingroup gdcmObject * \brief Constructor diff --git a/src/gdcmParsePixels.cxx b/src/gdcmParsePixels.cxx index 40311776..c95b825f 100644 --- a/src/gdcmParsePixels.cxx +++ b/src/gdcmParsePixels.cxx @@ -1,19 +1,7 @@ // gdcmParse.cxx //----------------------------------------------------------------------------- -//This is needed when compiling in debug mode -#ifdef _MSC_VER -// 'type' : forcing value to bool 'true' or 'false' (performance warning) -//#pragma warning ( disable : 4800 ) -// '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 "gdcmCommon.h" #include "gdcmFile.h" -#include "gdcmUtil.h" #define str2num(str, typeNum) *((typeNum *)(str)) diff --git a/src/gdcmParser.cxx b/src/gdcmParser.cxx index b78abc29..871c8086 100644 --- a/src/gdcmParser.cxx +++ b/src/gdcmParser.cxx @@ -1,9 +1,7 @@ // gdcmParser.cxx //----------------------------------------------------------------------------- -#include "gdcmParser.h" -#include "gdcmUtil.h" - #include +#include // For nthos: #ifdef _MSC_VER @@ -20,6 +18,10 @@ #endif # include +#include "gdcmParser.h" +#include "gdcmUtil.h" +#include "gdcmDebug.h" + #define UI1_2_840_10008_1_2 "1.2.840.10008.1.2" #define UI1_2_840_10008_1_2_1 "1.2.840.10008.1.2.1" #define UI1_2_840_10008_1_2_2 "1.2.840.10008.1.2.2" diff --git a/src/gdcmTS.cxx b/src/gdcmTS.cxx index b648b26b..8946c61a 100644 --- a/src/gdcmTS.cxx +++ b/src/gdcmTS.cxx @@ -1,22 +1,25 @@ // gdcmTS.cxx //----------------------------------------------------------------------------- #include +#include +#include +#ifdef GDCM_NO_ANSI_STRING_STREAM +# include +# define ostringstream ostrstream +# else +# include +#endif #include "gdcmTS.h" +#include "gdcmDebug.h" #include "gdcmUtil.h" +#include "gdcmDictSet.h" #ifndef PUB_DICT_PATH # define PUB_DICT_PATH "../Dicts/" #endif #define DICT_TS "dicomTS.dic" -#include -#ifdef GDCM_NO_ANSI_STRING_STREAM -# include -# define ostringstream ostrstream -# else -# include -#endif //----------------------------------------------------------------------------- // Constructor / Destructor diff --git a/src/gdcmUtil.cxx b/src/gdcmUtil.cxx index 0760f383..ae7f0675 100644 --- a/src/gdcmUtil.cxx +++ b/src/gdcmUtil.cxx @@ -1,109 +1,43 @@ // gdcmUtil.cxx //----------------------------------------------------------------------------- #include "gdcmUtil.h" - +#include "gdcmDebug.h" #include #include // For isspace -#include - -//----------------------------------------------------------------------------- -// Library globals. -gdcmDebug dbg; +#include // CLEANME: could this be only string ? Related to Win32 ? -//----------------------------------------------------------------------------- /** - * \ingroup gdcmDebug - * \brief constructor - * @param level debug level - */ - -gdcmDebug::gdcmDebug(int level) { - DebugLevel = level; -} - -/** - * \ingroup gdcmDebug - * \brief Verbose - * @param Level level - * @param Msg1 first message part - * @param Msg2 second message part + * \ingroup Globals + * \brief Pointer to a container, holding _all_ the Dicom Dictionaries. */ -void gdcmDebug::Verbose(int Level, const char * Msg1, const char * Msg2) { - if (Level > DebugLevel) - return ; - std::cerr << Msg1 << ' ' << Msg2 << std::endl; -} +gdcmDictSet *gdcmGlobal::Dicts = (gdcmDictSet *)0; /** - * \ingroup gdcmDebug - * \brief Error - * @param Test test - * @param Msg1 first message part - * @param Msg2 second message part + * \ingroup Globals + * \brief Pointer to a hash table containing the 'Value Representations'. */ -void gdcmDebug::Error( bool Test, const char * Msg1, const char * Msg2) { - if (!Test) - return; - std::cerr << Msg1 << ' ' << Msg2 << std::endl; - Exit(1); -} +gdcmVR *gdcmGlobal::VR = (gdcmVR *)0; /** - * \ingroup gdcmDebug - * \brief Error - * @param Msg1 first message part - * @param Msg2 second message part - * @param Msg3 Third message part + * \ingroup Globals + * \brief Pointer to a hash table containing the Transfer Syntax codes + * and their english description */ -void gdcmDebug::Error(const char* Msg1, const char* Msg2, - const char* Msg3) { - std::cerr << Msg1 << ' ' << Msg2 << ' ' << Msg3 << std::endl; - Exit(1); -} +gdcmTS *gdcmGlobal::TS = (gdcmTS *)0; /** - * \ingroup gdcmDebug - * \brief Assert - * @param Level level - * @param Test test - * @param Msg1 first message part - * @param Msg2 second message part + * \ingroup Globals + * \brief Pointer to the hash table containing the Dicom Elements + * necessary to describe each part of a DICOMDIR */ - void gdcmDebug::Assert(int Level, bool Test, - const char * Msg1, const char * Msg2) { - if (Level > DebugLevel) - return ; - if (!Test) - std::cerr << Msg1 << ' ' << Msg2 << std::endl; -} +gdcmDicomDirElement *gdcmGlobal::ddElem = (gdcmDicomDirElement *)0; /** - * \ingroup gdcmDebug - * \brief Exit - * @param a return code + * \ingroup Globals + * \brief Global container */ -void gdcmDebug::Exit(int a) { -#ifdef __GNUC__ - std::exit(a); -#endif -#ifdef _MSC_VER - exit(a); // Found in #include -#endif -} - -//----------------------------------------------------------------------------- -/// Pointer to a container, holding *all* the Dicom Dictionaries -gdcmDictSet *gdcmGlobal::Dicts = (gdcmDictSet *)0; -/// Pointer to a H table containing the 'Value Representations' -gdcmVR *gdcmGlobal::VR = (gdcmVR *)0; -/// Pointer to a H table containing the Transfer Syntax codes and their english description -gdcmTS *gdcmGlobal::TS = (gdcmTS *)0; -/// Pointer to a H table containing the Dicom Elements necessary to describe each part of a DICOMDIR -gdcmDicomDirElement *gdcmGlobal::ddElem = (gdcmDicomDirElement *)0; -/// gdcm Glob gdcmGlobal gdcmGlob; - /** * \ingroup gdcmGlobal * \brief constructor : populates the @@ -144,14 +78,17 @@ gdcmDicomDirElement *gdcmGlobal::GetDicomDirElements(void) { return ddElem; } -//----------------------------------------------------------------------------- -// Here are some usefull functions, belonging to NO class, -// dealing with strings, file names, etc -// that can be called from anywhere -// by whomsoever they can help. -//----------------------------------------------------------------------------- +/** + * \defgroup Globals Utility functions + * \brief Here are some utility functions, belonging to NO class, + * dealing with strings, file names... that can be called + * from anywhere by whomsoever they can help. + */ -// Because is not yet available in g++2.96 +/** + * \ingroup Globals + * \brief Because is not yet available in g++2.96 + */ std::istream& eatwhite(std::istream& is) { char c; while (is.get(c)) { @@ -163,8 +100,10 @@ std::istream& eatwhite(std::istream& is) { return is; } -/////////////////////////////////////////////////////////////////////////// -// Because is not available in C++ (?) +/** + * \ingroup Globals + * \brief Because not available in C++ (?) + */ void Tokenize (const std::string& str, std::vector& tokens, const std::string& delimiters) { @@ -177,10 +116,10 @@ void Tokenize (const std::string& str, } } - -/////////////////////////////////////////////////////////////////////////// /** - * \brief to prevent a flashing screen when non-printable character + * \ingroup Globals + * \brief Weed out a string from the non-printable characters (in order + * to avoid corrupting the terminal of invocation when printing) * @param v characters array to remove non printable characters from */ char *_cleanString(char *v) { @@ -192,12 +131,12 @@ char *_cleanString(char *v) { i++,d++) { if (!isprint(*d)) *d = '.'; - } + } return v; } -/////////////////////////////////////////////////////////////////////////// /** + * \ingroup Globals * \brief to prevent a flashing screen when non-printable character * @param s string to remove non printable characters from */ @@ -210,7 +149,6 @@ std::string _CreateCleanString(std::string s) { str[i]='.'; } - if(str.size()>0) if(!isprint(s[str.size()-1])) if(s[str.size()-1]==0) @@ -219,27 +157,28 @@ std::string _CreateCleanString(std::string s) { return(str); } -/////////////////////////////////////////////////////////////////////////// /** + * \ingroup Globals * \brief Add a SEPARATOR to the end of the name is necessary * @param name file/directory name to normalize */ void NormalizePath(std::string &name) { -const char SEPARATOR_X = '/'; -const char SEPARATOR_WIN = '\\'; -const std::string SEPARATOR = "/"; + const char SEPARATOR_X = '/'; + const char SEPARATOR_WIN = '\\'; + const std::string SEPARATOR = "/"; int size=name.size(); + if((name[size-1]!=SEPARATOR_X)&&(name[size-1]!=SEPARATOR_WIN)) { name+=SEPARATOR; } } -/////////////////////////////////////////////////////////////////////////// /** + * \ingroup Globals * \brief Get the (directory) path from a full path file name - * @param fullName file/directory name to extract Path from + * @param fullName file/directory name to extract Path from */ std::string GetPath(std::string &fullName) { @@ -252,10 +191,10 @@ std::string GetPath(std::string &fullName) return(fullName); } -/////////////////////////////////////////////////////////////////////////// /** + * \ingroup Globals * \brief Get the (last) name of a full path file name - * @param fullName file/directory name to extract end name from + * @param fullName file/directory name to extract end name from */ std::string GetName(std::string &fullName) { diff --git a/src/gdcmUtil.h b/src/gdcmUtil.h index 4dcbc4fb..7683ed4f 100644 --- a/src/gdcmUtil.h +++ b/src/gdcmUtil.h @@ -8,45 +8,9 @@ #include "gdcmTS.h" #include "gdcmDictSet.h" #include "gdcmDicomDirElement.h" -#include #include #include -//----------------------------------------------------------------------------- -/* - * gdcmDebug is an object for debugging in program. - * It has 2 debugging modes : - * - error : for bad library use - * - debug : for debugging messages - * - * A debugging message has a level of priority and is - * Shown only when the debug level is higher than the - * message level. - */ -class gdcmDebug { -public: - gdcmDebug(int level = GDCM_DEBUG); - - /** - * \ingroup gdcmDebug - * \brief sets the debug level - * @param i debug level to be set - */ - void SetDebug (int i) - {DebugLevel = i;} - - void Verbose(int, const char*, const char* =""); - 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); - -private: -/// warning message level to be displayed - int DebugLevel; -}; - //----------------------------------------------------------------------------- /* * This class contains all globals elements that might be @@ -72,18 +36,14 @@ private: //----------------------------------------------------------------------------- std::istream & eatwhite(std::istream & is); - void Tokenize (const std::string& str, - std::vector& tokens, - const std::string& delimiters = " "); +void Tokenize (const std::string& str, + std::vector& tokens, + const std::string& delimiters = " "); - extern gdcmDebug dbg; +char *_cleanString(char *v); +std::string _CreateCleanString(std::string s); - char *_cleanString(char *v); - std::string _CreateCleanString(std::string s); - - void NormalizePath (std::string &name); - std::string GetPath(std::string &fullName); - std::string GetName(std::string &fullName); -//----------------------------------------------------------------------------- +void NormalizePath (std::string &name); +std::string GetPath(std::string &fullName); +std::string GetName(std::string &fullName); #endif - diff --git a/src/gdcmVR.cxx b/src/gdcmVR.cxx index 3732f2bd..fd4f9858 100644 --- a/src/gdcmVR.cxx +++ b/src/gdcmVR.cxx @@ -1,13 +1,6 @@ // gdcmVR.cxx -#include //----------------------------------------------------------------------------- -#include "gdcmVR.h" -#include "gdcmUtil.h" - -#ifndef PUB_DICT_PATH -# define PUB_DICT_PATH "../Dicts/" -#endif -#define DICT_VR "dicomVR.dic" +#include #include #ifdef GDCM_NO_ANSI_STRING_STREAM @@ -17,6 +10,15 @@ # include #endif +#include "gdcmVR.h" +#include "gdcmUtil.h" +#include "gdcmDebug.h" + +#ifndef PUB_DICT_PATH +# define PUB_DICT_PATH "../Dicts/" +#endif +#define DICT_VR "dicomVR.dic" + //----------------------------------------------------------------------------- // Constructor / Destructor gdcmVR::gdcmVR(void) diff --git a/src/win32/gdcmdll.dsp b/src/win32/gdcmdll.dsp index 707bd8e6..2afbd82e 100644 --- a/src/win32/gdcmdll.dsp +++ b/src/win32/gdcmdll.dsp @@ -104,6 +104,10 @@ PostBuild_Cmds=copy ..\..\lib\gdcmdll.dll # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File +SOURCE=..\gdcmDebug.cxx +# End Source File +# Begin Source File + SOURCE=..\gdcmDicomDir.cxx # End Source File # Begin Source File @@ -216,6 +220,10 @@ SOURCE=..\gdcm.h # End Source File # Begin Source File +SOURCE=..\gdcmDebug.h +# End Source File +# Begin Source File + SOURCE=..\gdcmCommon.h # End Source File # Begin Source File -- 2.48.1