Loading...
Searching...
No Matches
BALL::TransformationManager Class Reference
Foundation Classes » Operating system support

`#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.

## Detailed Description

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 .

Definition at line 77 of file file.h.

## Constructor & Destructor Documentation

## TransformationManager()

BALL::TransformationManager::TransformationManager | ( |  | ) |

Default constructor.

Constructors and Destructors

## ~TransformationManager()

BALL::TransformationManager::~TransformationManager | ( |  | ) |

Destructor.

## Member Function Documentation

## findTransformation()

String BALL::TransformationManager::findTransformation | ( | const String & | name | ) | const

Find a transformation matching a given file name.

## registerTransformation()

void BALL::TransformationManager::registerTransformation | ( | const String & | pattern,
|  | const String & | command )

Add a new transformation.

Accessors

## transform()

String BALL::TransformationManager::transform | ( | const String & | name | ) |

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 file
- p the path to the file
- t 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)

## unregisterTransformation()

void BALL::TransformationManager::unregisterTransformation | ( | const String & | pattern | ) |

Delete a transformation.

## Member Data Documentation

## transformation_methods_

std::map<String, String> BALL::TransformationManager::transformation_methods_

protected

The map containing all transformation methods.

Definition at line 128 of file file.h.