Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members

TransformationManager Class Reference
[Operating system support]

This class handles automatic file transformation methods. More...

#include <file.h>

List of all members.

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)
 Apply a suitable transformation to the string.

Protected Attributes

std::map< String, Stringtransformation_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 selectedvia 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 .


Member Function Documentation

String 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)