]> Creatis software - gdcm.git/commitdiff
ENH: add a test for DirList. Add a method Print on DirList. Remove useless NormalizeP...
authormalaterre <malaterre>
Fri, 14 Jan 2005 21:52:05 +0000 (21:52 +0000)
committermalaterre <malaterre>
Fri, 14 Jan 2005 21:52:05 +0000 (21:52 +0000)
Testing/CMakeLists.txt
Testing/TestDirList.cxx [new file with mode: 0644]
src/gdcmDirList.cxx
src/gdcmDirList.h

index 125cf5acc1fbcce1dc0aeb190188a117d01f206f..eb0c544f225d16fb316a5424b3a49c1cc68c9dfb 100644 (file)
@@ -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 (file)
index 0000000..6d109a7
--- /dev/null
@@ -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;
+}
index 615d0b4deced7612782941982df26cb9c0c80d02..65c6b358355bff5f991ffdcc131fc616983dd96f 100644 (file)
@@ -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 <iostream>
+#include <iterator>
 
 #ifdef _MSC_VER
    #include <windows.h> 
@@ -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<std::string>(os, "\n"));
+}
+
 //-----------------------------------------------------------------------------
 // Protected
 
index 526f94acb9bb5833b68231cf68b262dc59d4f0d0..8361a808811906c55f64ad6075228e88d06b64f3 100644 (file)
@@ -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 <string>
-#include <list>
+#include <vector>
+#include <iostream>
 
 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<std::string>
+class DirList : public std::vector<std::string>
 {
 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 '/'