OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [insight/] [tcl/] [doc/] [StringObj.3] - Blame information for rev 1765

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
'\"
2
'\" Copyright (c) 1994-1997 Sun Microsystems, Inc.
3
'\"
4
'\" See the file "license.terms" for information on usage and redistribution
5
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6
'\"
7
'\" RCS: @(#) $Id: StringObj.3,v 1.1.1.1 2002-01-16 10:25:24 markom Exp $
8
'\"
9
.so man.macros
10
.TH Tcl_StringObj 3 8.0 Tcl "Tcl Library Procedures"
11
.BS
12
.SH NAME
13
Tcl_NewStringObj, Tcl_SetStringObj, Tcl_GetStringFromObj, Tcl_AppendToObj, Tcl_AppendStringsToObj, Tcl_SetObjLength, TclConcatObj \- manipulate Tcl objects as strings
14
.SH SYNOPSIS
15
.nf
16
\fB#include \fR
17
.sp
18
Tcl_Obj *
19
\fBTcl_NewStringObj\fR(\fIbytes, length\fR)
20
.sp
21
\fBTcl_SetStringObj\fR(\fIobjPtr, bytes, length\fR)
22
.sp
23
char *
24
\fBTcl_GetStringFromObj\fR(\fIobjPtr, lengthPtr\fR)
25
.sp
26
\fBTcl_AppendToObj\fR(\fIobjPtr, bytes, length\fR)
27
.sp
28
\fBTcl_AppendStringsToObj\fR(\fIobjPtr, string, string, ... \fB(char *) NULL\fR)
29
.sp
30
\fBTcl_SetObjLength\fR(\fIobjPtr, newLength\fR)
31
.sp
32
Tcl_Obj *
33
\fBTcl_ConcatObj\fR(\fIobjc, objv\fR)
34
.SH ARGUMENTS
35
.AS Tcl_Interp *lengthPtr out
36
.AP char *bytes in
37
Points to the first byte of an array of bytes
38
used to set or append to a string object.
39
This byte array may contain embedded null bytes
40
unless \fIlength\fR is negative.
41
.AP int length in
42
The number of bytes to copy from \fIbytes\fR when
43
initializing, setting, or appending to a string object.
44
If negative, all bytes up to the first null are used.
45
.AP Tcl_Obj *objPtr in/out
46
Points to an object to manipulate.
47
.AP int *lengthPtr out
48
If non-NULL, the location where \fBTcl_GetStringFromObj\fR will store
49
the the length of an object's string representation.
50
.AP char *string in
51
Null-terminated string value to append to \fIobjPtr\fR.
52
.AP int newLength in
53
New length for the string value of \fIobjPtr\fR, not including the
54
final NULL character.
55
.AP int objc in
56
The number of elements to concatenate.
57
.AP Tcl_Obj *objv[] in
58
The array of objects to concatenate.
59
.BE
60
 
61
.SH DESCRIPTION
62
.PP
63
The procedures described in this manual entry allow Tcl objects to
64
be manipulated as string values.  They use the internal representation
65
of the object to store additional information to make the string
66
manipulations more efficient.  In particular, they make a series of
67
append operations efficient by allocating extra storage space for the
68
string so that it doesn't have to be copied for each append.
69
.PP
70
\fBTcl_NewStringObj\fR and \fBTcl_SetStringObj\fR create a new object
71
or modify an existing object to hold a copy of
72
the string given by \fIbytes\fR and \fIlength\fR.
73
\fBTcl_NewStringObj\fR returns a pointer to a newly created object
74
with reference count zero.
75
Both procedures set the object to hold a copy of the specified string.
76
\fBTcl_SetStringObj\fR frees any old string representation
77
as well as any old internal representation of the object.
78
.PP
79
\fBTcl_GetStringFromObj\fR returns an object's string representation.
80
This is given by the returned byte pointer
81
and length, which is stored in \fIlengthPtr\fR if it is non-NULL.
82
If the object's string representation is invalid
83
(its byte pointer is NULL),
84
the string representation is regenerated from the
85
object's internal representation.
86
The storage referenced by the returned byte pointer
87
is owned by the object manager and should not be modified by the caller.
88
.PP
89
\fBTcl_AppendToObj\fR appends the data given by \fIbytes\fR and
90
\fIlength\fR to the object specified by \fIobjPtr\fR.  It does this
91
in a way that handles repeated calls relatively efficiently (it
92
overallocates the string space to avoid repeated reallocations
93
and copies of object's string value).
94
.PP
95
\fBTcl_AppendStringsToObj\fR is similar to \fBTcl_AppendToObj\fR
96
except that it can be passed more than one value to append and
97
each value must be a null-terminated string (i.e. none of the
98
values may contain internal null characters).  Any number of
99
\fIstring\fR arguments may be provided, but the last argument
100
must be a NULL pointer to indicate the end of the list.
101
.PP
102
The \fBTcl_SetObjLength\fR procedure changes the length of the
103
string value of its \fIobjPtr\fR argument.  If the \fInewLength\fR
104
argument is greater than the space allocated for the object's
105
string, then the string space is reallocated and the old value
106
is copied to the new space; the bytes between the old length of
107
the string and the new length may have arbitrary values.
108
If the \fInewLength\fR argument is less than the current length
109
of the object's string, with \fIobjPtr->length\fR is reduced without
110
reallocating the string space; the original allocated size for the
111
string is recorded in the object, so that the string length can be
112
enlarged in a subsequent call to \fBTcl_SetObjLength\fR without
113
reallocating storage.  In all cases \fBTcl_SetObjLength\fR leaves
114
a null character at \fIobjPtr->bytes[newLength]\fR.
115
.PP
116
The \fBTcl_ConcatObj\fR function returns a new string object whose
117
value is the space-separated concatenation of the string
118
representations of all of the objects in the \fIobjv\fR
119
array. \fBTcl_ConcatObj\fR eliminates leading and trailing white space
120
as it copies the string representations of the \fIobjv\fR array to the
121
result. If an element of the \fIobjv\fR array consists of nothing but
122
white space, then that object is ignored entirely. This white-space
123
removal was added to make the output of the \fBconcat\fR command
124
cleaner-looking. \fBTcl_ConcatObj\fR returns a pointer to a
125
newly-created object whose ref count is zero.
126
 
127
.SH "SEE ALSO"
128
Tcl_NewObj, Tcl_IncrRefCount, Tcl_DecrRefCount
129
 
130
.SH KEYWORDS
131
append, internal representation, object, object type, string object,
132
string type, string representation, concat, concatenate

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.