From: malaterre Date: Sun, 10 Oct 2004 00:42:54 +0000 (+0000) Subject: ENH: Encapsulate global functions within gdcmUtil class as static functions. No diffe... X-Git-Tag: Version0.6.bp~92 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=c9dd24ae7aab3c9f32af740ebfce6dfb47bd855f;p=gdcm.git ENH: Encapsulate global functions within gdcmUtil class as static functions. No difference at all, just slightly cleaner --- diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index d9f71b67..a9fdca41 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDir.cxx,v $ Language: C++ - Date: $Date: 2004/10/09 03:21:55 $ - Version: $Revision: 1.71 $ + Date: $Date: 2004/10/10 00:42:54 $ + Version: $Revision: 1.72 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -602,7 +602,7 @@ void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type, if( tmpGr == 0x0004 && tmpEl == 0x1130 ) // File-set ID { // force to the *end* File Name - val = GetName( path ); + val = gdcmUtil::GetName( path ); } else if( tmpGr == 0x0004 && tmpEl == 0x1500 ) // Only used for image { diff --git a/src/gdcmDicomDirElement.cxx b/src/gdcmDicomDirElement.cxx index a645bc81..d4831c9b 100644 --- a/src/gdcmDicomDirElement.cxx +++ b/src/gdcmDicomDirElement.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirElement.cxx,v $ Language: C++ - Date: $Date: 2004/10/09 03:21:55 $ - Version: $Revision: 1.18 $ + Date: $Date: 2004/10/10 00:42:54 $ + Version: $Revision: 1.19 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -117,35 +117,35 @@ void gdcmDicomDirElement::Print(std::ostream &os) s << "Meta Elements :"<Group,it->Elem); + greltag = gdcmUtil::Format("%04x|%04x ",it->Group,it->Elem); s << " (" << greltag << ") = " << it->Value << std::endl; } s << "Patient Elements :"<Group,it->Elem); + greltag = gdcmUtil::Format("%04x|%04x ",it->Group,it->Elem); s << " (" << greltag << ") = " << it->Value << std::endl; } s << "Study Elements :"<Group, it->Elem); + greltag = gdcmUtil::Format("%04x|%04x ", it->Group, it->Elem); s << " (" << greltag << ") = " << it->Value << std::endl; } s << "Serie Elements :"<Group, it->Elem); + greltag = gdcmUtil::Format("%04x|%04x ", it->Group, it->Elem); s << " (" << greltag << ") = " << it->Value << std::endl; } s << "Image Elements :"<Group, it->Elem); + greltag = gdcmUtil::Format("%04x|%04x ", it->Group, it->Elem); s << " (" << greltag << ") = " << it->Value << std::endl; } diff --git a/src/gdcmDictEntry.cxx b/src/gdcmDictEntry.cxx index c37c7938..c11d0680 100644 --- a/src/gdcmDictEntry.cxx +++ b/src/gdcmDictEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictEntry.cxx,v $ Language: C++ - Date: $Date: 2004/10/09 02:57:11 $ - Version: $Revision: 1.24 $ + Date: $Date: 2004/10/10 00:42:54 $ + Version: $Revision: 1.25 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -59,7 +59,7 @@ gdcmDictEntry::gdcmDictEntry(uint16_t group, uint16_t element, */ gdcmTagKey gdcmDictEntry::TranslateToKey(uint16_t group, uint16_t element) { - gdcmTagKey key = Format("%04x|%04x", group , element); + gdcmTagKey key = gdcmUtil::Format("%04x|%04x", group , element); return key; } diff --git a/src/gdcmDirList.cxx b/src/gdcmDirList.cxx index 27fd7eae..d3a8b464 100644 --- a/src/gdcmDirList.cxx +++ b/src/gdcmDirList.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDirList.cxx,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:06 $ - Version: $Revision: 1.21 $ + Date: $Date: 2004/10/10 00:42:54 $ + Version: $Revision: 1.22 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -44,7 +44,7 @@ gdcmDirList::gdcmDirList(std::string dirName, bool recursive) { name = dirName; - NormalizePath(name); + gdcmUtil::NormalizePath(name); Explore(name, recursive); } @@ -88,7 +88,7 @@ int gdcmDirList::Explore(std::string dirName, bool recursive) { int numberOfFiles = 0; std::string fileName; - NormalizePath(dirName); + gdcmUtil::NormalizePath(dirName); #if defined(_MSC_VER) || (__CYGWIN__) WIN32_FIND_DATA fileData; HANDLE hFile=FindFirstFile((dirName+"*").c_str(),&fileData); diff --git a/src/gdcmDocEntry.cxx b/src/gdcmDocEntry.cxx index 5fcc597f..2d7cfa94 100644 --- a/src/gdcmDocEntry.cxx +++ b/src/gdcmDocEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.cxx,v $ Language: C++ - Date: $Date: 2004/10/09 03:31:26 $ - Version: $Revision: 1.25 $ + Date: $Date: 2004/10/10 00:42:54 $ + Version: $Revision: 1.26 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -73,7 +73,7 @@ void gdcmDocEntry::Print(std::ostream& os) lgth = GetReadLength(); // ReadLength, as opposed to UsableLength if (lgth == 0xffffffff) { - st = Format("x(ffff)"); // I said : "x(ffff)" ! + st = gdcmUtil::Format("x(ffff)"); // I said : "x(ffff)" ! s.setf(std::ios::left); s << std::setw(10-st.size()) << " "; s << st << " "; @@ -82,7 +82,7 @@ void gdcmDocEntry::Print(std::ostream& os) } else { - st = Format("x(%x)",lgth); + st = gdcmUtil::Format("x(%x)",lgth); s.setf(std::ios::left); s << std::setw(10-st.size()) << " "; s << st << " "; @@ -90,7 +90,7 @@ void gdcmDocEntry::Print(std::ostream& os) s << std::setw(8) << lgth; } s << " Off.: "; - st = Format("x(%x)",o); + st = gdcmUtil::Format("x(%x)",o); s << std::setw(10-st.size()) << " "; s << st << " "; s << std::setw(8) << o; diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 495b15b3..8426ac64 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2004/10/09 03:36:56 $ - Version: $Revision: 1.99 $ + Date: $Date: 2004/10/10 00:42:54 $ + Version: $Revision: 1.100 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -981,12 +981,12 @@ bool gdcmDocument::SetEntryByNumber(std::string const& content, gdcmVRKey vr = valEntry->GetVR(); if( vr == "US" || vr == "SS" ) { - c = CountSubstring(content, "\\") + 1; // for multivaluated items + c = gdcmUtil::CountSubstring(content, "\\") + 1; // for multivaluated items l = c*2; } else if( vr == "UL" || vr == "SL" ) { - c = CountSubstring(content, "\\") + 1; // for multivaluated items + c = gdcmUtil::CountSubstring(content, "\\") + 1; // for multivaluated items l = c*4;; } } @@ -1979,7 +1979,7 @@ bool gdcmDocument::CheckDocEntryVR(gdcmDocEntry *entry, gdcmVRKey vr) { // We thought this was explicit VR, but we end up with an // implicit VR tag. Let's backtrack. - msg = Format("Falsely explicit vr file (%04x,%04x)\n", + msg = gdcmUtil::Format("Falsely explicit vr file (%04x,%04x)\n", entry->GetGroup(), entry->GetElement()); dbg.Verbose(1, "gdcmDocument::FindVR: ", msg.c_str()); @@ -2119,7 +2119,7 @@ std::string gdcmDocument::GetDocEntryUnvalue(gdcmDocEntry* entry) uint16_t newInt16; tokens.erase( tokens.begin(), tokens.end()); // clean any previous value - Tokenize (((gdcmValEntry *)entry)->GetValue(), tokens, "\\"); + gdcmUtil::Tokenize (((gdcmValEntry *)entry)->GetValue(), tokens, "\\"); for (unsigned int i=0; iGetValue(), tokens, "\\"); + gdcmUtil::Tokenize (((gdcmValEntry *)entry)->GetValue(), tokens, "\\"); for (unsigned int i=0; iSetLength(ImageDataSize); ImageDataSize += 8; - car = Format("%d", ImageDataSize); + car = gdcmUtil::Format("%d", ImageDataSize); SetEntryByNumber(car, GrPixel, NumPixel); } diff --git a/src/gdcmJpeg12.cxx b/src/gdcmJpeg12.cxx index 1b8ae574..056afa39 100644 --- a/src/gdcmJpeg12.cxx +++ b/src/gdcmJpeg12.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJpeg12.cxx,v $ Language: C++ - Date: $Date: 2004/10/08 17:24:54 $ - Version: $Revision: 1.18 $ + Date: $Date: 2004/10/10 00:42:55 $ + Version: $Revision: 1.19 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -32,10 +32,8 @@ */ extern "C" { -//#include #include "src/jpeg/libijg12/jconfig.h" #include "src/jpeg/libijg12/jpeglib.h" -//#include "jconfig12.h" #include } /******************** JPEG COMPRESSION SAMPLE INTERFACE *******************/ diff --git a/src/gdcmJpeg8.cxx b/src/gdcmJpeg8.cxx index 8f0ad62f..cf623c2c 100644 --- a/src/gdcmJpeg8.cxx +++ b/src/gdcmJpeg8.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJpeg8.cxx,v $ Language: C++ - Date: $Date: 2004/10/08 17:24:54 $ - Version: $Revision: 1.3 $ + Date: $Date: 2004/10/10 00:42:55 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -85,7 +85,6 @@ of the uncompressed pixel data from which the compressed data is derived */ extern "C" { -//#include "stdio.h" #include "src/jpeg/libijg8/jconfig.h" #include "src/jpeg/libijg8/jpeglib.h" diff --git a/src/gdcmUtil.cxx b/src/gdcmUtil.cxx index 2fe6c7b0..b4907d91 100644 --- a/src/gdcmUtil.cxx +++ b/src/gdcmUtil.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmUtil.cxx,v $ Language: C++ - Date: $Date: 2004/10/09 02:57:12 $ - Version: $Revision: 1.52 $ + Date: $Date: 2004/10/10 00:42:55 $ + Version: $Revision: 1.53 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -36,7 +36,7 @@ #include //only included in implementation file #include //only included in implementation file -std::string Format(const char* format, ...) +std::string gdcmUtil::Format(const char* format, ...) { char buffer[2048]; va_list args; @@ -50,7 +50,7 @@ std::string Format(const char* format, ...) * \ingroup Globals * \brief Because not available in C++ (?) */ -void Tokenize (const std::string& str, +void gdcmUtil::Tokenize (const std::string& str, std::vector& tokens, const std::string& delimiters) { @@ -70,7 +70,7 @@ void Tokenize (const std::string& str, * Counts the number of occurences of a substring within a string */ -int CountSubstring (const std::string& str, +int gdcmUtil::CountSubstring (const std::string& str, const std::string& subStr) { int count = 0; // counts how many times it appears @@ -96,7 +96,7 @@ int CountSubstring (const std::string& str, * to avoid corrupting the terminal of invocation when printing) * @param s string to remove non printable characters from */ -std::string CreateCleanString(std::string s) +std::string gdcmUtil::CreateCleanString(std::string s) { std::string str = s; @@ -127,7 +127,7 @@ std::string CreateCleanString(std::string s) * \brief Add a SEPARATOR to the end of the name is necessary * @param name file/directory name to normalize */ -void NormalizePath(std::string &name) +void gdcmUtil::NormalizePath(std::string &name) { const char SEPARATOR_X = '/'; const char SEPARATOR_WIN = '\\'; @@ -145,7 +145,7 @@ void NormalizePath(std::string &name) * \brief Get the (directory) path from a full path file name * @param fullName file/directory name to extract Path from */ -std::string GetPath(std::string &fullName) +std::string gdcmUtil::GetPath(std::string &fullName) { int pos1 = fullName.rfind("/"); int pos2 = fullName.rfind("\\"); @@ -166,7 +166,7 @@ std::string GetPath(std::string &fullName) * \brief Get the (last) name of a full path file name * @param fullName file/directory name to extract end name from */ -std::string GetName(std::string &fullName) +std::string gdcmUtil::GetName(std::string &fullName) { int fin = fullName.length()-1; char a =fullName.c_str()[fin]; diff --git a/src/gdcmUtil.h b/src/gdcmUtil.h index 685b5c3d..3371cb3e 100644 --- a/src/gdcmUtil.h +++ b/src/gdcmUtil.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmUtil.h,v $ Language: C++ - Date: $Date: 2004/10/09 02:57:12 $ - Version: $Revision: 1.34 $ + Date: $Date: 2004/10/10 00:42:55 $ + Version: $Revision: 1.35 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -32,16 +32,21 @@ */ //----------------------------------------------------------------------------- -GDCM_EXPORT std::string Format(const char* format, ...); -GDCM_EXPORT void Tokenize (const std::string& str, - std::vector& tokens, - const std::string& delimiters = " "); -GDCM_EXPORT int CountSubstring (const std::string& str, - const std::string& subStr); -GDCM_EXPORT std::string CreateCleanString(std::string s); -GDCM_EXPORT void NormalizePath(std::string &name); -GDCM_EXPORT std::string GetPath(std::string &fullName); -GDCM_EXPORT std::string GetName(std::string &fullName); +class GDCM_EXPORT gdcmUtil +{ +public: + static std::string Format(const char* format, ...); + static void Tokenize (const std::string& str, + std::vector& tokens, + const std::string& delimiters = " "); + static int CountSubstring (const std::string& str, + const std::string& subStr); + + static std::string CreateCleanString(std::string s); + static void NormalizePath(std::string &name); + static std::string GetPath(std::string &fullName); + static std::string GetName(std::string &fullName); +}; //----------------------------------------------------------------------------- #endif diff --git a/src/gdcmValEntry.cxx b/src/gdcmValEntry.cxx index c5028a8c..9160b21a 100644 --- a/src/gdcmValEntry.cxx +++ b/src/gdcmValEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmValEntry.cxx,v $ Language: C++ - Date: $Date: 2004/10/09 03:48:25 $ - Version: $Revision: 1.28 $ + Date: $Date: 2004/10/10 00:42:55 $ + Version: $Revision: 1.29 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -82,7 +82,7 @@ void gdcmValEntry::Print(std::ostream & os) gdcmTS * ts = gdcmGlobal::GetTS(); v = GetValue(); // not applicable for SQ ... - d2 = CreateCleanString(v); // replace non printable characters by '.' + d2 = gdcmUtil::CreateCleanString(v); // replace non printable characters by '.' if( (GetLength()<=MAX_SIZE_PRINT_ELEMENT_VALUE) || //(PrintLevel>=3) || (d2.find("gdcm::NotLoaded.") < d2.length()) ) (PrintLevel>=3) || (d2.find(GDCM_NOTLOADED) < d2.length()) ) @@ -150,17 +150,17 @@ void gdcmValEntry::Print(std::ostream & os) { if (v == "4294967295") // to avoid troubles in convertion { - st = Format(" x(ffffffff)"); + st = gdcmUtil::Format(" x(ffffffff)"); } else { if ( GetLength() !=0 ) { - st = Format(" x(%x)", atoi(v.c_str()));//FIXME + st = gdcmUtil::Format(" x(%x)", atoi(v.c_str()));//FIXME } else { - st = Format(" "); + st = gdcmUtil::Format(" "); } } s << st; @@ -191,7 +191,7 @@ void gdcmValEntry::Write(FILE* fp, FileType filetype) // we split the string and write each value as a short int std::vector tokens; tokens.erase(tokens.begin(),tokens.end()); // clean any previous value - Tokenize (GetValue(), tokens, "\\"); + gdcmUtil::Tokenize (GetValue(), tokens, "\\"); for (unsigned int i=0; i tokens; tokens.erase(tokens.begin(),tokens.end()); // clean any previous value - Tokenize (GetValue(), tokens, "\\"); + gdcmUtil::Tokenize (GetValue(), tokens, "\\"); for (unsigned int i=0; i