GDCM: gdcmDirectory.h Source File

GDCM 3.2.5

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
24namespace gdcm
25{
41//-----------------------------------------------------------------------------
42 class GDCM_EXPORT Directory
43{
44 friend std::ostream& operator<<(std::ostream &_os, const Directory &d);
45public :
46 Directory() = default;
47 ~Directory() = default;
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 gdcm_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
69 // \todo later: GLOB
70 // The glob() function searches for all the pathnames matching pattern according to
71 // the rules used by the shell (see glob(7)). No tilde expansion or parameter
72 // substitution is done; if you want these, use wordexp(3).
73 // int Glob(...);
74
75protected:
77 unsigned int Explore(FilenameType const &name, bool recursive);
78
79private :
81 FilenamesType Filenames;
82 FilenamesType Directories;
83
85 FilenameType Toplevel;
86};
87//-----------------------------------------------------------------------------
88 inline std::ostream& operator<<(std::ostream &os, const Directory &d)
89{
90 d.Print( os );
91 return os;
92}
93
94} // end namespace gdcm
95//-----------------------------------------------------------------------------
96#endif //GDCMDIRECTORY_H
gdcm::Directory::FilenamesType
std::vector< FilenameType > FilenamesType
Definition gdcmDirectory.h:49
gdcm::Directory::Load
unsigned int Load(FilenameType const &name, bool recursive=false)
gdcm::Directory::FilenameType
std::string FilenameType
Definition gdcmDirectory.h:48
gdcm::Directory::operator<<
friend std::ostream & operator<<(std::ostream &_os, const Directory &d)
Definition gdcmDirectory.h:88
gdcm::Directory::GetDirectories
FilenamesType const & GetDirectories() const
Return the Directories traversed.
Definition gdcmDirectory.h:63
gdcm::Directory::GetFilenames
FilenamesType const & GetFilenames() const
Set/Get the file names within the directory.
Definition gdcmDirectory.h:58
gdcm::Directory::~Directory
~Directory()=default
gdcm::Directory::Explore
unsigned int Explore(FilenameType const &name, bool recursive)
Return number of file found when 'recursive'ly exploring directory name.
gdcm::Directory::Print
void Print(std::ostream &os=std::cout) const
Print.
gdcm::Directory::Directory
Directory()=default
gdcm::Directory::GetToplevel
FilenameType const & GetToplevel() const
Get the name of the toplevel directory.
Definition gdcmDirectory.h:55
gdcm_assert
#define gdcm_assert(cond)
Definition gdcmException.h:104
gdcmTypes.h
GDCM_EXPORT
#define GDCM_EXPORT
Definition gdcmWin32.h:34
gdcm
Definition gdcmASN1.h:21
gdcm::operator<<
std::ostream & operator<<(std::ostream &os, const Directory &d)
Definition gdcmDirectory.h:88