#include <BALL/SYSTEM/file.h>
Public Member Functions | |
TransformationManager () | |
Default constructor. | |
~TransformationManager () | |
Destructor. | |
void | registerTransformation (const String &pattern, const String &command) |
Add a new transformation. | |
void | unregisterTransformation (const String &pattern) |
Delete a transformation. | |
String | findTransformation (const String &name) const |
Find a transformation matching a given file name. | |
String | transform (const String &name) |
Protected Attributes | |
std::map< String, String > | transformation_methods_ |
The map containing all transformation methods. |
This class handles automatic file transformation methods. File provides the ability to transform files on the fly using predefined transformation commands (e.g. unix-style filters). For example, compressed files can be automatically decompressed by calling the unic compress
command. The respective commands are selected via a suitable regular expression, usually matching the file suffix. A frequent application for this transformation is the compressed storage of PDB files in the unix compressed format (*.Z
). Transformation manager basically contains a map consisting of two strings. Using findTransformationCommand , File can determine whether there is a suitable transformation command available for a given file name. User-defined transformation may be defined at any time using the registerTransformation method of the static instance of TransformationManager accessible through File::getTransformationManager .
BALL::TransformationManager::TransformationManager | ( | ) |
Default constructor.
Constructors and Destructors
BALL::TransformationManager::~TransformationManager | ( | ) |
Destructor.
Find a transformation matching a given file name.
void BALL::TransformationManager::registerTransformation | ( | const String & | pattern, | |
const String & | command | |||
) |
Add a new transformation.
Accessors
Apply a suitable transformation to the string. This first calls findTransformation to determine the command string that should be applied. The name
argument is then replaced with the contents of the matching command in the TransformationManager's map. The following rules apply (in that order):
s
is replaced by the full content of name
f
is replaced by the full content of name
, without any file type suffix (i.e. anything after the last dot in the filename is removed)f[suffix]
is replaced by the previous content of name
without the suffix
b
and b[suffix]
like f
and f[suffix]
, except that the path is removed as well, so it is only the base name of the filep
the path to the filet
a temporary file name (all occurences of t
are replace with the same file name for the same invocation of transform , but different file names on subsequent invocations) void BALL::TransformationManager::unregisterTransformation | ( | const String & | pattern | ) |
Delete a transformation.
std::map<String, String> BALL::TransformationManager::transformation_methods_ [protected] |
The map containing all transformation methods.