Class tTidyBus

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type tTidyBus = class(TObject)

Description

Class to facilitate minor editing operations on a TidyDoc.

Since the TidyDoc's tree structure is effectively read-only, the tTidyBus object is designed to emulate the ability to move, copy, edit and delete the nodes of a TidyDoc tree.

Instead of modifying the tree itself, tTidyBus recreates a new text document in its ResultBuf, based on the behavior defined by the InsertMode and CopyMode properties, and the elements pointed to in the SourceNode and TargetNode properties, and the text contained in the Cargo buffer.

For a basic example of how to use this object, see the \tidypas\demo\tidymove.pas demo program.

Modifying a document using a tTidyBus is really not very efficient, since the entire document must be parsed, reparsed, recreated, and reparsed again each time a change is made. It is intended only to make small "one-shot" changes to the document. If you need a more fluid-like DOM, you would probably be better off exporting tidylib's output to a more suitable writer.

Hierarchy

Overview

Methods

Public constructor Create;
Public destructor Destroy; override;
Public procedure Clear;
Public procedure Execute(doc:pTidyDoc;PickupProc:tNodeCallback);
Public procedure AddCargo(p:pChar);

Properties

Public property TargetNode: pTidyNode (read/write);
Public property SourceNode: pTidyNode (read/write);
Public property InsertMode: tTidyBusInsertMode (read/write);
Public property CopyMode: tTidyBusCopyMode (read/write);
Public property ResultBuf: tTidyBuffer (read-only);
Public property Cargo: pChar (read-only);

Description

Methods

Public constructor Create;

Creates a new instance of tTidyBus.

Public destructor Destroy; override;

Destroys this instance of tTidyBus.

Public procedure Clear;

Frees the memory allocated to the Cargo and Result buffers.

( Called automatically on Destroy, and at the beginning of Execute )

Public procedure Execute(doc:pTidyDoc;PickupProc:tNodeCallback);

The Execute method will first invoke the ForEachNode procedure on the root node of the TidyDoc, using your PickupProc as the callback, and passing the tTidyBus object itself as the user_data parameter to the callback.

The purpose of your PickupProc is to search the document tree, and set the desired values of the tTidyBus's SourceNode, TargetNode, and Cargo properties. The PickupProc is also responsible for calling itself to recurse any child nodes.

If you have some other means of initializing the SourceNode, TargetNode, and Cargo fields, you can safely set the PickupProc argument to Nil;

After the PickupProc has completed, tTidyBus will traverse the document tree again, and generate a new textual document in the ResultBuffer, based on the criteria established by your property settings.

Note that the original TidyDoc is not actually modified, and no validation is performed on the text of the newly-created ResultBuffer.

Public procedure AddCargo(p:pChar);

Appends text to the tTidyBus Cargo buffer

Properties

Public property TargetNode: pTidyNode (read/write);

Reference node for where the Cargo text is to be written. Can be NIL if CopyMode is cmEdit or cmDelete

Public property SourceNode: pTidyNode (read/write);

Reference node for where the Cargo text was obtained.

Public property InsertMode: tTidyBusInsertMode (read/write);

This property controls where the Cargo is to be written, relative to the TargetNode ( see tTidyBusInsertMode )

Public property CopyMode: tTidyBusCopyMode (read/write);

This property controls how the SourceNode is to be updated ( see tTidyBusCopyMode )

Public property ResultBuf: tTidyBuffer (read-only);

The resulting buffer where the new document is written.

Public property Cargo: pChar (read-only);

Provides access to the text of the tTidyBus Cargo buffer


Generated by PasDoc 0.10.0 on 2005-12-23 21:07:56

Support This Project  
Get CurlPas and TidyPas at SourceForge.net. Fast, secure and Free Open Source software downloads