home *** CD-ROM | disk | FTP | other *** search
- //
- // MiscTree.h -- a generic class to build tree data structures
- // Written by Don Yacktman Copyright (c) 1993 by Don Yacktman.
- // Version 1.0. All rights reserved.
- //
- // This notice may not be removed from this source code.
- //
- // This is a free object! Contact the author for the latest version.
- // Don Yacktman, 4279 N. Ivy Lane, Provo, UT, 84604
- // e-mail: Don_Yacktman@byu.edu
- //
- // This object is included in the MiscKit by permission from the author
- // and its use is governed by the MiscKit license, found in the file
- // "LICENSE.rtf" in the MiscKit distribution. Please refer to that file
- // for a list of all applicable permissions and restrictions.
- //
-
- #import <appkit/appkit.h> // superclass is in there
-
- @interface MiscTree:Object
- {
- id branches; // an instance of the list class
- id label; // node name
- id value; // must be a MiscString
- BOOL notCollapsed; // print children when dumping if true.
- }
-
-
- // init with null label
- - init;
-
- // designated initializer
- - initLabel:(const char *)newLabel; // send a char* string
- - initLabelString:string; // send a String object
-
- // access to the label of this node
- - setLabel:(const char *)newLabel; // send a char* string
- - (const char *)label;
-
- // access to the value of this node
- - setValue:newValue; // send a String object
- - (const char *)value;
-
- // clean up our mess
- - free;
-
- // add a new child node
- - addBranch:child;
-
- // Print the tree to a stream (file, whatever). Call the root with level
- // set to zero, and set the indent string however you like; the indent
- // string should be something like " " or "\t" to show how to indent to
- // the next level. This method recursively traverses the tree's children.
- - dumpTree:(NXStream *)file level:(int)lev indent:(const char *)ind;
-
- // set whether or not we print the children (we don't if collapsed)
- // when dumping. This does NOT affect the tree's width or depth!
- - collapse;
- - uncollapse;
- - (BOOL)collapsed;
-
- // when dumping the tree, if you want to add extra data to the output
- // before the newline and before children are printed, add it here. If
- // you return NO, then the children won't be printed; this is how the
- // collapse stuff works. Be sure to call super and honor a NO return value!
- - (BOOL)moreData:(NXStream *)file level:(int)lev indent:(const char *)ind;
-
- // How deep or wide is the tree?
- - (int) width;
- - (int) depth;
-
- // Return the List object that contains ids of all the kids.
- - branches;
-
- @end
-