home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / vtcl / doc / DString.3 < prev    next >
Encoding:
Text File  |  1995-07-10  |  6.1 KB  |  149 lines

  1. '\"
  2. '\" Copyright (c) 1993 The Regents of the University of California.
  3. '\" All rights reserved.
  4. '\"
  5. '\" Permission is hereby granted, without written agreement and without
  6. '\" license or royalty fees, to use, copy, modify, and distribute this
  7. '\" documentation for any purpose, provided that the above copyright
  8. '\" notice and the following two paragraphs appear in all copies.
  9. '\"
  10. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  11. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  12. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. '\"
  15. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. '\" 
  21. '\" $Header: /user6/ouster/tcl/man/RCS/DString.3,v 1.11 93/11/08 08:19:17 ouster Exp $ SPRITE (Berkeley)
  22. '\" 
  23. '\"----------------------------------------------------------------------------
  24. '\"    @(#) DString.3 27.1 93/11/16 SCOINC
  25. '\"
  26. '\"     Copyright (C) The Santa Cruz Operation, 1992-1993.
  27. '\"     This Module contains Proprietary Information of
  28. '\"    The Santa Cruz Operation, and should be treated as Confidential.
  29. '\"----------------------------------------------------------------------------
  30. .so ../man.macros
  31. .HS Tcl_DStringInit tclc 7.0
  32. .BS
  33. .SH NAME
  34. .na
  35. Tcl_DStringInit, Tcl_DStringAppend, Tcl_DStringAppendElement, Tcl_DStringStartSublist, Tcl_DStringEndSublist, Tcl_DStringLength, Tcl_DStringValue, Tcl_DStringTrunc, Tcl_DStringFree, Tcl_DStringResult \- manipulate dynamic strings
  36. .ad
  37. .SH SYNOPSIS
  38. .nf
  39. \fB#include <tcl.h>\fR
  40. .sp
  41. \fBTcl_DStringInit\fR(\fIdsPtr\fR)
  42. .sp
  43. char *
  44. \fBTcl_DStringAppend\fR(\fIdsPtr, string, length\fR)
  45. .sp
  46. char *
  47. \fBTcl_DStringAppendElement\fR(\fIdsPtr, string\fR)
  48. .sp
  49. \fBTcl_DStringStartSublist\fR(\fIdsPtr\fR)
  50. .sp
  51. \fBTcl_DStringEndSublist\fR(\fIdsPtr\fR)
  52. .sp
  53. int
  54. \fBTcl_DStringLength\fR(\fIdsPtr\fR)
  55. .sp
  56. char *
  57. \fBTcl_DStringValue\fR(\fIdsPtr\fR)
  58. .sp
  59. \fBTcl_DStringTrunc\fR(\fIdsPtr, newLength\fR)
  60. .sp
  61. \fBTcl_DStringFree\fR(\fIdsPtr\fR)
  62. .sp
  63. \fBTcl_DStringResult\fR(\fIinterp, dsPtr\fR)
  64. .SH ARGUMENTS
  65. .AS Tcl_DString newLength
  66. .AP Tcl_DString *dsPtr in/out
  67. Pointer to structure that is used to manage a dynamic string.
  68. .AP char *string in
  69. Pointer to characters to add to dynamic string.
  70. .AP int length in
  71. Number of characters from string to add to dynamic string.  If -1,
  72. add all characters up to null terminating character.
  73. .AP int newLength in
  74. New length for dynamic string, not including null terminating
  75. character.
  76. .BE
  77.  
  78. .SH DESCRIPTION
  79. .PP
  80. Dynamic strings provide a mechanism for building up arbitrarily long
  81. strings by gradually appending information.  If the dynamic string is
  82. short then there will be no memory allocation overhead;  as the string
  83. gets larger, additional space will be allocated as needed.
  84. .PP
  85. \fBTcl_DStringInit\fR initializes a dynamic string to zero length.
  86. The Tcl_DString structure must have been allocated by the caller.
  87. No assumptions are made about the current state of the structure;
  88. anything already in it is discarded.
  89. If the structure has been used previously, \fBTcl_DStringFree\fR should
  90. be called first to free up any memory allocated for the old
  91. string.
  92. .PP
  93. \fBTcl_DStringAppend\fR adds new information to a dynamic string,
  94. allocating more memory for the string if needed.
  95. If \fIlength\fR is less than zero then everything in \fIstring\fR
  96. is appended to the dynamic string;  otherwise \fIlength\fR
  97. specifies the number of bytes to append.
  98. \fBTcl_DStringAppend\fR returns a pointer to the characters of
  99. the new string.  The string can also be retrieved from the
  100. \fIstring\fR field of the Tcl_DString structure.
  101. .PP
  102. \fBTcl_DStringAppendElement\fR is similar to \fBTcl_DStringAppend\fR
  103. except that it doesn't take a \fIlength\fR argument (it appends
  104. all of \fIstring\fR) and it converts the string to a proper list element
  105. before appending.
  106. \fBTcl_DStringAppendElement\fR adds a separator space before the
  107. new list element unless the new list element is the first in a
  108. list or sub-list (i.e. either the current string is empty, or it
  109. contains the single character ``{'', or the last two characters of
  110. the current string are `` {'').
  111. \fBTcl_DStringAppendElement\fR returns a pointer to the
  112. characters of the new string.
  113. .PP
  114. \fBTcl_DStringStartSublist\fR and \fBTcl_DStringEndSublist\fR can be
  115. used to create nested lists.
  116. To append a list element that is itself a sublist, first
  117. call \fBTcl_DStringStartSublist\fR, then call \fBTcl_DStringAppendElement\fR
  118. for each of the elements in the sublist, then call
  119. \fBTcl_DStringEndSublist\fR to end the sublist.
  120. \fBTcl_DStringStartSublist\fR appends a space character if needed,
  121. followed by an open brace;  \fBTcl_DStringEndSublist\fR appends
  122. a close brace.
  123. Lists can be nested to any depth.
  124. .PP
  125. \fBTcl_DStringLength\fR is a macro that returns the current length
  126. of a dynamic string (not including the terminating null character).
  127. \fBTcl_DStringValue\fR is a  macro that returns a pointer to the
  128. current contents of a dynamic string.
  129. .PP
  130. \fBTcl_DStringTrunc\fR truncates a dynamic string to a given length.
  131. It has no effect if the string was already smaller than \fInewLength\fR.
  132. This procedure does not free up the string's storage space, even
  133. if the string is truncated to zero length, so \fBTcl_DStringFree\fR
  134. will still need to be called.
  135. .PP
  136. \fBTcl_DStringFree\fR should be called when you're finished using
  137. the string.  It frees up any memory that was allocated for the string
  138. and reinitializes the string's value to an empty string.
  139. .PP
  140. \fBTcl_DStringResult\fR sets the result of \fIinterp\fR to the value of
  141. the dynamic string given by \fIdsPtr\fR.  It does this by moving
  142. a pointer from \fIdsPtr\fR to \fIinterp->result\fR.
  143. This saves the cost of allocating new memory and copying the string.
  144. \fBTcl_DStringResult\fR also reinitializes the dynamic string to
  145. an empty string.
  146.  
  147. .SH KEYWORDS
  148. append, dynamic string, free, result
  149.