gdcmDirectory.h
Go to the documentation of this file.
/*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.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 notice for more information.
=========================================================================*/
#ifndef GDCMDIRECTORY_H
#define GDCMDIRECTORY_H
#include "gdcmTypes.h"
#include <string>
#include <vector>
#include <iostream>
#include <assert.h>
namespace gdcm
{
//-----------------------------------------------------------------------------
class GDCM_EXPORT Directory
{
friend std::ostream& operator<<(std::ostream &_os, const Directory &d);
public :
Directory() = default;
~Directory() = default;
typedef std::string FilenameType;
typedef std::vector<FilenameType> FilenamesType;
void Print(std::ostream &os = std::cout) const;
FilenameType const &GetToplevel() const { return Toplevel; }
FilenamesType const &GetFilenames() const {
assert( !(Toplevel.empty()) && "Need to call Explore first" );
return Filenames; }
FilenamesType const &GetDirectories() const { return Directories; }
unsigned int Load(FilenameType const &name, bool recursive = false);
// \todo later: GLOB
// The glob() function searches for all the pathnames matching pattern according to
// the rules used by the shell (see glob(7)). No tilde expansion or parameter
// substitution is done; if you want these, use wordexp(3).
// int Glob(...);
protected:
unsigned int Explore(FilenameType const &name, bool recursive);
private :
FilenamesType Filenames;
FilenamesType Directories;
FilenameType Toplevel;
};
//-----------------------------------------------------------------------------
inline std::ostream& operator<<(std::ostream &os, const Directory &d)
{
d.Print( os );
return os;
}
} // end namespace gdcm
//-----------------------------------------------------------------------------
#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
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