BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Protected Attributes | List of all members
BALL::TransformationManager Class Reference

#include <BALL/SYSTEM/file.h>

Public Member Functions

 TransformationManager ()
 Default constructor. More...
 
 ~TransformationManager ()
 Destructor. More...
 
void registerTransformation (const String &pattern, const String &command)
 Add a new transformation. More...
 
void unregisterTransformation (const String &pattern)
 Delete a transformation. More...
 
String findTransformation (const String &name) const
 Find a transformation matching a given file name. More...
 
String transform (const String &name)
 

Protected Attributes

std::map< String, Stringtransformation_methods_
 The map containing all transformation methods. More...
 

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 80 of file file.h.

Constructor & Destructor Documentation

BALL::TransformationManager::TransformationManager ( )

Default constructor.

Constructors and Destructors

BALL::TransformationManager::~TransformationManager ( )

Destructor.

Member Function Documentation

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

Find a transformation matching a given file name.

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

Add a new transformation.

Accessors

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)
void BALL::TransformationManager::unregisterTransformation ( const String pattern)

Delete a transformation.

Member Data Documentation

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

The map containing all transformation methods.

Definition at line 131 of file file.h.