GDCM 2.2.1

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

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 //-----------------------------------------------------------------------------
42 class GDCM_EXPORT Directory
43 {
44 friend std::ostream& operator<<(std::ostream &_os, const Directory &d);
45 public :
46 Directory() {}
47 ~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