From: malaterre Date: Fri, 14 Jan 2005 21:52:05 +0000 (+0000) Subject: ENH: add a test for DirList. Add a method Print on DirList. Remove useless NormalizeP... X-Git-Tag: Version1.0.bp~326 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=aa74099d3b9e6bf860806305891414f048b7e9a0;p=gdcm.git ENH: add a test for DirList. Add a method Print on DirList. Remove useless NormalizePath (output wasnt taken anyway) --- diff --git a/Testing/CMakeLists.txt b/Testing/CMakeLists.txt index 125cf5ac..eb0c544f 100644 --- a/Testing/CMakeLists.txt +++ b/Testing/CMakeLists.txt @@ -15,6 +15,7 @@ SET(TEST_SOURCES TestUtil.cxx TestDicomString.cxx TestDict.cxx + TestDirList.cxx ) # add tests that require data diff --git a/Testing/TestDirList.cxx b/Testing/TestDirList.cxx new file mode 100644 index 00000000..6d109a73 --- /dev/null +++ b/Testing/TestDirList.cxx @@ -0,0 +1,29 @@ +/*========================================================================= + + Program: gdcm + Module: $RCSfile: TestDirList.cxx,v $ + Language: C++ + Date: $Date: 2005/01/14 21:52:05 $ + Version: $Revision: 1.1 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "gdcmDirList.h" + +int TestDirList(int , char* []) +{ + std::string path = GDCM_DATA_ROOT; + std::cerr << path << std::endl; + + gdcm::DirList list(path); + list.Print(); + + return 0; +} diff --git a/src/gdcmDirList.cxx b/src/gdcmDirList.cxx index 615d0b4d..65c6b358 100644 --- a/src/gdcmDirList.cxx +++ b/src/gdcmDirList.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDirList.cxx,v $ Language: C++ - Date: $Date: 2005/01/12 22:09:55 $ - Version: $Revision: 1.32 $ + Date: $Date: 2005/01/14 21:52:06 $ + Version: $Revision: 1.33 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -19,7 +19,7 @@ #include "gdcmDirList.h" #include "gdcmUtil.h" -#include +#include #ifdef _MSC_VER #include @@ -42,8 +42,7 @@ namespace gdcm DirList::DirList(std::string const &dirName, bool recursive) { DirName = dirName; - Util::NormalizePath(DirName); - Explore(DirName, recursive); + Explore(dirName, recursive); } /** @@ -69,6 +68,11 @@ std::string const &DirList::GetDirName() const return DirName; } +void DirList::Print(std::ostream &os) +{ + copy(begin(), end(), std::ostream_iterator(os, "\n")); +} + //----------------------------------------------------------------------------- // Protected diff --git a/src/gdcmDirList.h b/src/gdcmDirList.h index 526f94ac..8361a808 100644 --- a/src/gdcmDirList.h +++ b/src/gdcmDirList.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDirList.h,v $ Language: C++ - Date: $Date: 2005/01/12 22:09:55 $ - Version: $Revision: 1.16 $ + Date: $Date: 2005/01/14 21:52:06 $ + Version: $Revision: 1.17 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -22,7 +22,8 @@ #include "gdcmCommon.h" #include -#include +#include +#include namespace gdcm { @@ -36,7 +37,7 @@ namespace gdcm // NOTE: Due to a VC6 'feature' we can not export a std::list in a dll, // so GDCM_EXPORT keyword was removed for this class only -class DirList: public std::list +class DirList : public std::vector { public : DirList(std::string const &dirName, bool recursive=false); @@ -44,6 +45,8 @@ public : std::string const &GetDirName() const; + void Print(std::ostream &os = std::cout); + /// Character '\' static const char SEPARATOR_X; /// Character '/'