/MEng/Formattable

ClassPath:MEng.
Parent ClassPath:MEng.Object
Copyable:Yes
Final:No

MEng.Formattable is a special class from which any class can derive if it wants to be formattable as text by passing it to a text output stream. It provides a single, required method, FormatTo(), that the derived classes must override. The derived class' implementation must format the contents of the current instance in whatever was is applicable. For instance, a Point class might output something like {0,1} if it's x and y values are 0 and 1.

The MEng.System.Runtime.TextOutStream class provides a Format() method which will accept any class derived from this class. It will then call the FormatTo() method on that target object. This allows you to write code that accepts any formattable object and format them polymophically.

Since both copyable and non-copyable classes might derive from this class, it is copyable, though it has no real state to copy. And of course since it is designed to be derived from, it is non-final.

 

Constructors:

Constructor();

This is the only constructor for this class. It takes no parameters and, as all constructors do, returns no value. It is just there to allow all of the classes that derive from it to get a default call to their parent constructor.

 

Required Methods:

FormatTo
(
    [InOut] MEng.System.Runtime.TextOutStream TargetStream
);

The derived class must override this method and format it's contents appropriately to the target text output stream.