Home Libraries Author Links

stm::filefind< PathContainerT > Class Template Reference
[FilesysAids: File System Aids]

List of all members.


Detailed Description

template<class PathContainerT = std::set<numpstring>>
class stm::filefind< PathContainerT >

Container class representing existing file system elements defined by a file spec using pattern matching based file name expansion.

The file system elements in the conatiner are represented by their paths. As the implementation of filefind uses regular expressions (see Abstract Data Type StmRe), for its error control the macro StmRectrlTry can be used.

Examples:

filesystest.cpp.

Definition at line 1271 of file filesysaids.hpp.


With filespec flags bitwise orable flags

static const dword NoFlags = 0
static const dword NoDirectories = impl::NoDirectories
static const dword NoPlainFiles = impl::NoPlainFiles
static const dword StoreRelative = impl::StoreRelative

Public Types

typedef PathContainerT pathcontainer_type
 Container type.
typedef
pathcontainer_type::value_type 
path_type
 Container element type.

Public Member Functions

 filefind (dword flags=NoFlags, const std::string &stem=std::string())
 Construct an empty container with default flags.
 filefind (const std::string &spec, dword flags=NoFlags, const std::string &stem=std::string())
 Constructs a container with flags as default flags and the absolute stem containing the existing file system elements as if insert (spec) was executed after constructing the container with filefind (flags, stem).
int insert (const std::string &spec)
 Inserts existing file system elements into this container as if the method insert (spec, flags) with the containers's default flags was executed and returns the number of actually inserted items.
int insert (const std::string &spec, dword flags)
 Inserts all existing file system elements defined by spec according to flags into the container.
dword getFlags () const
 Returns the default flags of this filefind container.
path_type getStem () const
 Returns the absolute stem of this filefind container, if defined, else path_type ().

Member Typedef Documentation

template<class PathContainerT = std::set<numpstring>>
typedef PathContainerT stm::filefind< PathContainerT >::pathcontainer_type

Container type.

Sequence containers as well as associative containers may be used.

Definition at line 1289 of file filesysaids.hpp.

template<class PathContainerT = std::set<numpstring>>
typedef pathcontainer_type::value_type stm::filefind< PathContainerT >::path_type

Container element type.

It shall be default constructable and copyable. Moreover, it shall have a constructor with a single const std::string & argument. A path_type object constructed with this constructor shall represent the file system object's name.

Definition at line 1295 of file filesysaids.hpp.


Constructor & Destructor Documentation

template<class PathContainerT = std::set<numpstring>>
stm::filefind< PathContainerT >::filefind ( dword  flags = NoFlags,
const std::string &  stem = std::string() 
)

Construct an empty container with default flags.

A non-empty stem argument defines the absolute stem relative to which the file finding operations of this filefind container are performed. It is an error, if a non-empty stem represents no absolute path.

template<class PathContainerT = std::set<numpstring>>
stm::filefind< PathContainerT >::filefind ( const std::string &  spec,
dword  flags = NoFlags,
const std::string &  stem = std::string() 
) [explicit]

Constructs a container with flags as default flags and the absolute stem containing the existing file system elements as if insert (spec) was executed after constructing the container with filefind (flags, stem).


Member Function Documentation

template<class PathContainerT = std::set<numpstring>>
int stm::filefind< PathContainerT >::insert ( const std::string &  spec  ) 

Inserts existing file system elements into this container as if the method insert (spec, flags) with the containers's default flags was executed and returns the number of actually inserted items.

template<class PathContainerT = std::set<numpstring>>
int stm::filefind< PathContainerT >::insert ( const std::string &  spec,
dword  flags 
)

Inserts all existing file system elements defined by spec according to flags into the container.

Spec may contain white space. If the flag StoreRelative is reset, the file system elements stored are made absolute using the function boost::filesystem::initial_path(), if necessary. Else spec shall not begin with a root name and the file system elements stored are relative as follows. If an absolute stem is defined, they are searched and stored relative to this absolute stem. If no absolute stem is defined, they are searched and stored relative to boost::filesystem::initial_path(). Even if the flag StoreRelative is reset and an absolute stem is defined, spec must not begin with a root name. In this case the file system elements are searched relative to this absolute stem, but stored as absolute paths.

If the flag NoDirectories is set, directories are not inserted into the container, if the flag NoPlainFiles is set, plain files are not inserted into the container.

If the flag filespec::UseExtRegularExpr is set or if spec contains one of the unescaped extended regular expression operators '(' or '|', spec is interpreted as extended regular expression as defined in the Open System Group Base Specification Issue 6, IEEE Std 1003.1-2004 (XBD: 9.4).

Otherwise if the flag filespeclist::SingleSpec is set, or if the flag filespeclist::NoBraceExpansion is set, or if spec contains no unescaped '{', spec is interpreted as filename expansion pattern as defined in IEEE Std 1003.1-2004 (XCU: 2.13.3). Else spec is brace expanded as in the bash shell, each of the resulting words is interpreted as filename expansion pattern and is handled separately. As mandated by IEEE std 1003.1-2004 the filename expansion pattern based operations occur for each path separator separated part of spec independently. To circumvent this, if the flag filespec::UseMultipleDirOperator is set and the flag filespec::NoPathSeparators is not set, the operator '**' as such a spec part matches a sequence of zero or more pairs each consisting of a file system element name component designating a directory and a path separator.

The bracket expressions used in the regular expressions and in the filename expansion patterns conform to IEEE Std 1003.1-2004 (XBD: 9.3.5) with the exception that equivalence classes [=x=] of collating elements are not supported. If filename expansion patterns are used and the flag filespec::NoCharClass is set, also collating symbols [.x.] and character classes [:x:] are not allowed inside bracket expressions. If the flag filespec::NoBracketExpr is set, bracket expressions are not allowed at all in filename expansion patterns.

The method returns the number of items actually inserted.

template<class PathContainerT = std::set<numpstring>>
dword stm::filefind< PathContainerT >::getFlags (  )  const

Returns the default flags of this filefind container.

template<class PathContainerT = std::set<numpstring>>
path_type stm::filefind< PathContainerT >::getStem (  )  const

Returns the absolute stem of this filefind container, if defined, else path_type ().


© Copyright Tom Michaelis 2002-2007

Distributed under the SysToMath Software License (See the accompanying file license.txt or a copy at www.SysToMath.com).