PUMA Library Reference Manual
Loading...
Searching...
No Matches
Puma::PathManager Class Reference

#include <Puma/PathManager.h>

+ Inheritance diagram for Puma::PathManager:

Description

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. More...
 
 PathManager (PathManager &other)
 Copy-constructor. More...
 
virtual ~PathManager ()
 Destructor. More...
 
void glob (char *filenamePattern=0)
 Search files in the managed path matching the given filename pattern or every file if no pattern is given. More...
 
bool iterate (PathIterator &iterator) const
 Iterate the contents of the managed paths. More...
 
virtual void addPath (const char *srcPath, const char *destPath=0)
 Add a source and destination paths pair. More...
 
ProjectFile::MapConstIter addFile (Filename filename)
 Add a new file to the project file list. More...
 
ProjectFile::MapConstIter addFile (Filename filename, Filename destPath)
 Add a new file to the project file list. More...
 
void setDest (const char *srcPath, const char *destPath)
 Set the destination path of the given source path. More...
 
void protect (const char *pathPattern)
 Add a pattern for a write-protected path. More...
 
long numPaths () const
 Get the number of managed paths. More...
 
long numProts () const
 Get the number of managed write-protected paths. More...
 
const char * src (long n) const
 Get the n-th managed source path. More...
 
const char * src_canon (long n) const
 Get canonical version of the n-th managed source path. More...
 
const char * dest (long n) const
 Get the n-th managed destination path. More...
 
RegCompprot (long n) const
 Get the n-th managed write-protected path pattern. More...
 
bool isProtected (const char *path) const
 Check if the given path is write-protected. More...
 
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. More...
 
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. More...
 
virtual void configure (const Config &config)
 Configure the path manager. More...
 
virtual void join (PathManager &other)
 Join the paths of the given manager with the paths of this path manager. More...
 
ErrorStreamerr () const
 Get the error stream used by this path manager. More...
 
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. More...
 

Protected Member Functions

const char * getDestination (Filename sourcePath, std::ostream *destinationPath=0) const
 Get the destination path for a given source path. More...
 
virtual void action (PathIterator &iterator)
 Called for every matched file when traversing a source path. More...
 
char * addSeparator (const char *path) const
 Add the separator '/' to the end of the given path. More...
 
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. More...
 

Constructor & Destructor Documentation

◆ PathManager() [1/2]

Puma::PathManager::PathManager ( ErrorStream err)
inline

Constructor.

Parameters
errError stream used to report errors.

◆ PathManager() [2/2]

Puma::PathManager::PathManager ( PathManager other)
inline

Copy-constructor.

Parameters
otherThe other path manager to copy.

◆ ~PathManager()

virtual Puma::PathManager::~PathManager ( )
virtual

Destructor.

Member Function Documentation

◆ action()

virtual void Puma::PathManager::action ( PathIterator iterator)
inlineprotectedvirtual

Called for every matched file when traversing a source path.

Parameters
iteratorThe path iterator pointing to the current file.

◆ addFile() [1/2]

ProjectFile::MapConstIter Puma::PathManager::addFile ( Filename  filename)

Add a new file to the project file list.

Parameters
filenameThe filename.
Returns
An iterator pointing to the file added.

◆ addFile() [2/2]

ProjectFile::MapConstIter Puma::PathManager::addFile ( Filename  filename,
Filename  destPath 
)

Add a new file to the project file list.

Parameters
filenameThe filename.
destPathThe corresponding destination path.
Returns
An iterator pointing to the file added.

◆ addPath()

virtual void Puma::PathManager::addPath ( const char *  srcPath,
const char *  destPath = 0 
)
virtual

Add a source and destination paths pair.

Parameters
srcPathThe source path.
destPathThe corresponding destination path.

◆ addSeparator() [1/2]

char * Puma::PathManager::addSeparator ( const char *  path) const
protected

Add the separator '/' to the end of the given path.

Parameters
pathThe path.
Returns
A copy of the path followed by the separator.

◆ addSeparator() [2/2]

char * Puma::PathManager::addSeparator ( const char *  path,
char *  buffer 
) const
protected

Add the separator '/' to the end of the given path and store the resulting path in the given buffer.

Parameters
pathThe path.
bufferThe buffer.
Returns
The buffer containing the path followed by the separator.

◆ configure()

virtual void Puma::PathManager::configure ( const Config config)
virtual

Configure the path manager.

Parameters
configThe configuration.

Reimplemented in Puma::Project.

◆ dest()

const char * Puma::PathManager::dest ( long  n) const
inline

Get the n-th managed destination path.

Parameters
nThe position of the path in the path list.
Returns
The destination path.

◆ err()

ErrorStream & Puma::PathManager::err ( ) const
inline

Get the error stream used by this path manager.

Returns
A reference to the error stream.

◆ getDestination()

const char * Puma::PathManager::getDestination ( Filename  sourcePath,
std::ostream *  destinationPath = 0 
) const
protected

Get the destination path for a given source path.

Parameters
sourcePathThe source path.
destinationPathOptional output stream for the destination path.
Returns
The destination path.

◆ getDestinationPath()

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.

Parameters
sourcePathThe source path.
outThe output stream.
Returns
True if the destination path was found.

◆ glob()

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.

Parameters
filenamePatternOptional regular expression for the filenames to match.

◆ isBelow() [1/2]

bool Puma::PathManager::isBelow ( const char *  filename) const
inlinevirtual

Check if a given file is directly managed by this path manager or is found below any of the managed paths.

Parameters
filenameThe filename.
Returns
True if the file was found.

Reimplemented in Puma::Project.

◆ isBelow() [2/2]

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.

Parameters
filenameThe filename.
iteratorThe iterator to store the position of the file.
Returns
True if the file was found.

◆ isProtected()

bool Puma::PathManager::isProtected ( const char *  path) const

Check if the given path is write-protected.

Parameters
pathThe path.
Returns
True if the path is write-protected.

◆ iterate()

bool Puma::PathManager::iterate ( PathIterator iterator) const

Iterate the contents of the managed paths.

Calls action() for every file found.

Parameters
iteratorThe path iterator to use.

◆ join()

virtual void Puma::PathManager::join ( PathManager other)
virtual

Join the paths of the given manager with the paths of this path manager.

Parameters
otherThe other path manager.

◆ numPaths()

long Puma::PathManager::numPaths ( ) const
inline

Get the number of managed paths.

Returns
The number of managed paths.

◆ numProts()

long Puma::PathManager::numProts ( ) const
inline

Get the number of managed write-protected paths.

Returns
The number of write-protected paths.

◆ prot()

RegComp * Puma::PathManager::prot ( long  n) const
inline

Get the n-th managed write-protected path pattern.

Parameters
nThe position of the path pattern in the path pattern list.
Returns
The write-protected path pattern.

◆ protect()

void Puma::PathManager::protect ( const char *  pathPattern)

Add a pattern for a write-protected path.

Parameters
pathPatternRegular expression for a path to write-protect.

◆ setDest()

void Puma::PathManager::setDest ( const char *  srcPath,
const char *  destPath 
)

Set the destination path of the given source path.

Parameters
srcPathThe source path.
destPathThe destination path.

◆ src()

const char * Puma::PathManager::src ( long  n) const
inline

Get the n-th managed source path.

Parameters
nThe position of the path in the path list.
Returns
The source path.

◆ src_canon()

const char * Puma::PathManager::src_canon ( long  n) const
inline

Get canonical version of the n-th managed source path.

Parameters
nThe position of the path in the path list.
Returns
The canonical source path.