![[index]](../icons/index.gif)
Next: Snip Classes
Up: File Format
Previous: File Format
The generalized notion of a snip allows new snip types to be defined
and immediately used in any editor class. Also, when two applications
support the same kinds of snips, snip data can easily be cut and
pasted between them, and the same data files will be readable by each
program. This interoperability is due to a consistent encoding
mechanism that is built into the snip system.
Graceful and extensible encoding of snips requires that
two issues are addressed:
- In order to convert a snip from an encoded representation
(e.g., as bytes in a file) to a memory object, a decoding function
must be provided for each type of snip. Furthermore, a list of such
decoders must be available to the high-level decoding process. This
decoding mapping is defined by associating a snip class
object to every snip. A snip class is an instance of the
snip-class% class.
- Some editors may require additional information to be stored
about a snip; this information is orthogonal to the type-specific
information stored by the snip itself. For example, a pasteboard
needs to remember a snip's position, while a text editor does not
need this information. If data is being cut and pasted from one
pasteboard to another, then information about relative positions
needs to be maintained, but this information should not inhibit
pasting into an editor. Extra data is associated with a snip through
editor data objects, instances of the
editor-data% class; decoding requires that each editor data
object has a editor data class, an instance of the
editor-data-class% class.
Snip classes, snip data, and snip data classes solve problems related
to encoding and decoding snips. In an application that has no need
for saving files or cut-and-paste, these issues can be safely
ignored.
![[index]](../icons/index.gif)
Next: Snip Classes
Up: File Format
Previous: File Format
PLT