GDCM  2.2.6
gdcmDirectory.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: GDCM (Grassroots DICOM). A DICOM library
4 
5  Copyright (c) 2006-2011 Mathieu Malaterre
6  All rights reserved.
7  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 #ifndef GDCMDIRECTORY_H
15 #define GDCMDIRECTORY_H
16 
17 #include "gdcmTypes.h"
18 
19 #include <string>
20 #include <vector>
21 #include <iostream>
22 #include <assert.h>
23 
24 namespace gdcm
25 {
41 //-----------------------------------------------------------------------------
43 {
44  friend std::ostream& operator<<(std::ostream &_os, const Directory &d);
45 public :
46  Directory() {}
48  typedef std::string FilenameType;
49  typedef std::vector<FilenameType> FilenamesType;
50 
52  void Print(std::ostream &os = std::cout) const;
53 
55  FilenameType const &GetToplevel() const { return Toplevel; }
56 
58  FilenamesType const &GetFilenames() const {
59  assert( !(Toplevel.empty()) && "Need to call Explore first" );
60  return Filenames; }
61 
63  FilenamesType const &GetDirectories() const { return Directories; }
64 
67  unsigned int Load(FilenameType const &name, bool recursive = false) {
68  Filenames.clear(); // clear previous
69  Directories.clear(); // clear previous
70  Toplevel = name;
71  return Explore( Toplevel, recursive );
72  }
73  // \todo later: GLOB
74  // The glob() function searches for all the pathnames matching pattern according to
75  // the rules used by the shell (see glob(7)). No tilde expansion or parameter
76  // substitution is done; if you want these, use wordexp(3).
77  // int Glob(...);
78 
79 protected:
81  unsigned int Explore(FilenameType const &name, bool recursive);
82 
83 private :
85  FilenamesType Filenames;
86  FilenamesType Directories;
87 
89  FilenameType Toplevel;
90 };
91 //-----------------------------------------------------------------------------
92 inline std::ostream& operator<<(std::ostream &os, const Directory &d)
93 {
94  d.Print( os );
95  return os;
96 }
97 
98 } // end namespace gdcm
99 //-----------------------------------------------------------------------------
100 #endif //GDCMDIRECTORY_H
FilenamesType const & GetFilenames() const
Set/Get the file names within the directory.
Definition: gdcmDirectory.h:58
Class for manipulation directories.
Definition: gdcmDirectory.h:42
#define GDCM_EXPORT
Definition: gdcmWin32.h:34
std::ostream & operator<<(std::ostream &os, const Directory &d)
Definition: gdcmDirectory.h:92
std::vector< FilenameType > FilenamesType
Definition: gdcmDirectory.h:49
Directory()
Definition: gdcmDirectory.h:46
unsigned int Load(FilenameType const &name, bool recursive=false)
Definition: gdcmDirectory.h:67
FilenamesType const & GetDirectories() const
Return the Directories traversed.
Definition: gdcmDirectory.h:63
void Print(std::ostream &os=std::cout) const
Print.
std::string FilenameType
Definition: gdcmDirectory.h:48
FilenameType const & GetToplevel() const
Get the name of the toplevel directory.
Definition: gdcmDirectory.h:55
~Directory()
Definition: gdcmDirectory.h:47

Generated on Sat Dec 21 2013 05:56:17 for GDCM by doxygen 1.8.5
SourceForge.net Logo