| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
<HTML> |
| 6 |
<HEAD> |
| 7 |
<TITLE>Blt_TreeCreate(3) manual page</TITLE> |
| 8 |
</HEAD> |
| 9 |
<BODY bgcolor=white> |
| 10 |
<A HREF="#toc">Table of Contents</A><P> |
| 11 |
|
| 12 |
<H2><A NAME="sect0" HREF="#toc0">Name</A></H2> |
| 13 |
Blt_TreeCreate - Create tree data |
| 14 |
object. |
| 15 |
<H2><A NAME="sect1" HREF="#toc1">Synopsis</A></H2> |
| 16 |
<BR> |
| 17 |
<PRE>#include <bltTree.h> |
| 18 |
|
| 19 |
int |
| 20 |
Blt_TreeCreate(interp, name, tokenPtr) |
| 21 |
</PRE> |
| 22 |
<H2><A NAME="sect2" HREF="#toc2">Arguments</A></H2> |
| 23 |
<P> |
| 24 |
Tcl_Interp <I>*interp</I><tt> </tt> <tt> </tt> (in)<BR> |
| 25 |
<tt> </tt> <tt> </tt> Interpreter to report results back to. <P> |
| 26 |
const char <I>*name</I><tt> </tt> <tt> </tt> (in)<BR> |
| 27 |
<tt> </tt> <tt> </tt> Name of the new tree. Can be qualified by a namespace. <P> |
| 28 |
Blt_Tree <I>*tokenPtr</I><tt> </tt> <tt> </tt> (out)<BR> |
| 29 |
<tt> </tt> <tt> </tt> If not NULL, points to location to store the client tree token. |
| 30 |
<H2><A NAME="sect3" HREF="#toc3">Description</A></H2> |
| 31 |
<P> |
| 32 |
This |
| 33 |
procedure creates a C-based tree data object and optionally returns a token |
| 34 |
to it. The arguments are as follows: |
| 35 |
<DL> |
| 36 |
|
| 37 |
<DT><I>interp</I> </DT> |
| 38 |
<DD>Interpreter to report results |
| 39 |
back to. If an error occurs, then interp->result will contain an error message. |
| 40 |
</DD> |
| 41 |
|
| 42 |
<DT><I>name</I> </DT> |
| 43 |
<DD>Name of the new tree object. You can think of <I>name</I> as the memory address |
| 44 |
of the object. It's a unique name that identifies the tree object. No tree |
| 45 |
object <I>name</I> can already exist. <I>Name</I> can be qualified by a namespace such |
| 46 |
as fred::myTree. If no namespace qualifier is used, the tree will be |
| 47 |
created in the current namespace, not the global namespace. If a qualifier |
| 48 |
is present, the namespace must already exist. </DD> |
| 49 |
|
| 50 |
<DT><I>tokenPtr</I> </DT> |
| 51 |
<DD>Holds the returned |
| 52 |
token. <I>TokenPtr</I> points to a location where it is stored. Tree tokens are |
| 53 |
used to work with the tree object. If NULL, no token is allocated. You |
| 54 |
can later use <B>Tcl_TreeGetToken</B> to obtain a token. </DD> |
| 55 |
</DL> |
| 56 |
<P> |
| 57 |
The new tree data object |
| 58 |
created will initially contain only a root node. You can add new nodes |
| 59 |
with <B>Blt_TreeCreateNode</B>. <P> |
| 60 |
Optionally a token for the tree data object is |
| 61 |
returned. Tree data objects can be shared. For example, the <B>tree</B> and <B>hiertable</B> |
| 62 |
commands may be accessing the same tree data object. Each client grabs a |
| 63 |
token that is associated with the tree. When all tokens are released (see |
| 64 |
<B>Blt_TreeReleaseToken</B>) the tree data object is automatically destroyed. <P> |
| 65 |
|
| 66 |
<H2><A NAME="sect4" HREF="#toc4">Returns</A></H2> |
| 67 |
A |
| 68 |
standard Tcl result is returned. If TCL_ERROR is returned, then <I>interp->result</I> |
| 69 |
will contain an error message. The following errors may occur: |
| 70 |
<UL> |
| 71 |
<LI>There already |
| 72 |
exists a tree by the same name as <I>name</I>. You can use <B>Tcl_TreeExists</B> to determine |
| 73 |
if a tree exists beforehand. </LI><LI>The tree name is prefixed by a namespace that |
| 74 |
doesn't exist. If you qualified the tree name with a namespace, the namespace |
| 75 |
must exist. Unlike Tcl procs and variables, the namespace is not automatically |
| 76 |
created for you. </LI><LI>Memory can't be allocated for the tree or token. </LI> |
| 77 |
</UL> |
| 78 |
|
| 79 |
<H2><A NAME="sect5" HREF="#toc5">Example</A></H2> |
| 80 |
The |
| 81 |
following example creates a new <BR> |
| 82 |
<CODE>Blt_Tree token;<BR> |
| 83 |
<P> |
| 84 |
if (Blt_TreeCreate(interp, "myTree", &token) != TCL_OK) {<BR> |
| 85 |
return TCL_ERROR;<BR> |
| 86 |
}<BR> |
| 87 |
printf("tree is %s\n", Blt_TreeName(token));<BR> |
| 88 |
|
| 89 |
<H2><A NAME="sect6" HREF="#toc6"></CODE>Keywords</A></H2> |
| 90 |
Tcl_TreeGetToken, Tcl_TreeExists, Tcl_TreeReleaseToken <P> |
| 91 |
|
| 92 |
<HR><P> |
| 93 |
<A NAME="toc"><B>Table of Contents</B></A><P> |
| 94 |
<UL> |
| 95 |
<LI><A NAME="toc0" HREF="#sect0">Name</A></LI> |
| 96 |
<LI><A NAME="toc1" HREF="#sect1">Synopsis</A></LI> |
| 97 |
<LI><A NAME="toc2" HREF="#sect2">Arguments</A></LI> |
| 98 |
<LI><A NAME="toc3" HREF="#sect3">Description</A></LI> |
| 99 |
<LI><A NAME="toc4" HREF="#sect4">Returns</A></LI> |
| 100 |
<LI><A NAME="toc5" HREF="#sect5">Example</A></LI> |
| 101 |
<LI><A NAME="toc6" HREF="#sect6">Keywords</A></LI> |
| 102 |
</UL> |
| 103 |
</BODY></HTML> |