PUMA Library Reference Manual
|
#include <Puma/PathManager.h>
Source and destination path and file management.
Source paths are mapped to their destination paths. The source tree can be iterated and new files can be added.
Public Member Functions | |
PathManager (ErrorStream &err) | |
Constructor. | |
PathManager (PathManager &other) | |
Copy-constructor. | |
virtual | ~PathManager () |
Destructor. | |
void | glob (char *filenamePattern=0) |
Search files in the managed path matching the given filename pattern or every file if no pattern is given. | |
bool | iterate (PathIterator &iterator) const |
Iterate the contents of the managed paths. | |
virtual void | addPath (const char *srcPath, const char *destPath=0) |
Add a source and destination paths pair. | |
ProjectFile::MapConstIter | addFile (Filename filename) |
Add a new file to the project file list. | |
ProjectFile::MapConstIter | addFile (Filename filename, Filename destPath) |
Add a new file to the project file list. | |
void | setDest (const char *srcPath, const char *destPath) |
Set the destination path of the given source path. | |
void | protect (const char *pathPattern) |
Add a pattern for a write-protected path. | |
long | numPaths () const |
Get the number of managed paths. | |
long | numProts () const |
Get the number of managed write-protected paths. | |
const char * | src (long n) const |
Get the n-th managed source path. | |
const char * | src_canon (long n) const |
Get canonical version of the n-th managed source path. | |
const char * | dest (long n) const |
Get the n-th managed destination path. | |
RegComp * | prot (long n) const |
Get the n-th managed write-protected path pattern. | |
bool | isProtected (const char *path) const |
Check if the given path is write-protected. | |
bool | isBelow (const char *filename, ProjectFile::MapConstIter &iterator) const |
Check if a given file is directly managed by this path manager or is found below any of the managed paths. | |
virtual bool | isBelow (const char *filename) const |
Check if a given file is directly managed by this path manager or is found below any of the managed paths. | |
virtual void | configure (const Config &config) |
Configure the path manager. | |
virtual void | join (PathManager &other) |
Join the paths of the given manager with the paths of this path manager. | |
ErrorStream & | err () const |
Get the error stream used by this path manager. | |
bool | getDestinationPath (const char *sourcePath, std::ostream &out) const |
Get the destination path of a given source path and write it on the given output stream. | |
Protected Member Functions | |
const char * | getDestination (Filename sourcePath, std::ostream *destinationPath=0) const |
Get the destination path for a given source path. | |
virtual void | action (PathIterator &iterator) |
Called for every matched file when traversing a source path. | |
char * | addSeparator (const char *path) const |
Add the separator '/' to the end of the given path. | |
char * | addSeparator (const char *path, char *buffer) const |
Add the separator '/' to the end of the given path and store the resulting path in the given buffer. | |
|
inline |
Constructor.
err | Error stream used to report errors. |
|
inline |
Copy-constructor.
other | The other path manager to copy. |
|
virtual |
Destructor.
|
inlineprotectedvirtual |
Called for every matched file when traversing a source path.
iterator | The path iterator pointing to the current file. |
ProjectFile::MapConstIter Puma::PathManager::addFile | ( | Filename | filename | ) |
Add a new file to the project file list.
filename | The filename. |
ProjectFile::MapConstIter Puma::PathManager::addFile | ( | Filename | filename, |
Filename | destPath ) |
Add a new file to the project file list.
filename | The filename. |
destPath | The corresponding destination path. |
|
virtual |
Add a source and destination paths pair.
srcPath | The source path. |
destPath | The corresponding destination path. |
|
protected |
Add the separator '/' to the end of the given path.
path | The path. |
|
protected |
Add the separator '/' to the end of the given path and store the resulting path in the given buffer.
path | The path. |
buffer | The buffer. |
|
virtual |
|
inline |
Get the n-th managed destination path.
n | The position of the path in the path list. |
|
inline |
Get the error stream used by this path manager.
|
protected |
Get the destination path for a given source path.
sourcePath | The source path. |
destinationPath | Optional output stream for the destination path. |
bool Puma::PathManager::getDestinationPath | ( | const char * | sourcePath, |
std::ostream & | out ) const |
Get the destination path of a given source path and write it on the given output stream.
sourcePath | The source path. |
out | The output stream. |
void Puma::PathManager::glob | ( | char * | filenamePattern = 0 | ) |
Search files in the managed path matching the given filename pattern or every file if no pattern is given.
Calls action() for every match.
filenamePattern | Optional regular expression for the filenames to match. |
|
inlinevirtual |
Check if a given file is directly managed by this path manager or is found below any of the managed paths.
filename | The filename. |
Reimplemented in Puma::Project.
bool Puma::PathManager::isBelow | ( | const char * | filename, |
ProjectFile::MapConstIter & | iterator ) const |
Check if a given file is directly managed by this path manager or is found below any of the managed paths.
If the file is found then its position is stored in the given iterator.
filename | The filename. |
iterator | The iterator to store the position of the file. |
bool Puma::PathManager::isProtected | ( | const char * | path | ) | const |
Check if the given path is write-protected.
path | The path. |
bool Puma::PathManager::iterate | ( | PathIterator & | iterator | ) | const |
Iterate the contents of the managed paths.
Calls action() for every file found.
iterator | The path iterator to use. |
|
virtual |
Join the paths of the given manager with the paths of this path manager.
other | The other path manager. |
|
inline |
Get the number of managed paths.
|
inline |
Get the number of managed write-protected paths.
|
inline |
Get the n-th managed write-protected path pattern.
n | The position of the path pattern in the path pattern list. |
void Puma::PathManager::protect | ( | const char * | pathPattern | ) |
Add a pattern for a write-protected path.
pathPattern | Regular expression for a path to write-protect. |
void Puma::PathManager::setDest | ( | const char * | srcPath, |
const char * | destPath ) |
Set the destination path of the given source path.
srcPath | The source path. |
destPath | The destination path. |
|
inline |
Get the n-th managed source path.
n | The position of the path in the path list. |
|
inline |
Get canonical version of the n-th managed source path.
n | The position of the path in the path list. |