|
|
1.1 ! root 1: . \"ident "%W%" ! 2: . \"Copyright (c) 1984 AT&T ! 3: . \"All Rights Reserved ! 4: . \"THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T ! 5: . \"The copyright notice above does not evidence any ! 6: . \"actual or intended publication of such source code. ! 7: .TH SSBUF 3I+ "C++ Stream Library" " " ! 8: .SH NAME ! 9: strstreambuf \- streambuf specialized to arrays ! 10: .SH SYNOPSIS ! 11: .ta1i 2i 4i ! 12: .ft B ! 13: .nf ! 14: #include <iostream.h> ! 15: #include <strstream.h> ! 16: ! 17: class strstreambuf : streambuf { ! 18: public: ! 19: strstreambuf() ; ! 20: strstreambuf(char*,int,char*); ! 21: strstreambuf(int); ! 22: strstreambuf(unsigned char*, int, unsigned char*); ! 23: strstreambuf(void* (*a)(long), void(*f)(void*)); ! 24: ! 25: void freeze(int n=1) ; ! 26: char* str(); ! 27: streambuf* setbuf(char*,int) ! 28: }; ! 29: .fi ! 30: .ft R ! 31: .SH DESCRIPTION ! 32: A \f(CWstrstreambuf\fR ! 33: is a \f(CWstreambuf\fR that uses an array of bytes (a string) to hold ! 34: the sequence of characters. ! 35: Given the convention that a \f(CWchar*\fR should be interpreted as ! 36: pointing just before the \f(CWchar\fR it really points at, the mapping ! 37: between the abstract get/put pointers and \f(CWchar*\fR pointers ! 38: is direct. Moving the pointers corresponds exactly to incrementing ! 39: and decrementing the \f(CWchar*\fR values. ! 40: .PP ! 41: To accommodate the need for arbitrary length strings ! 42: \f(CWstrstreambuf\fRs ! 43: supports an automatic mode. ! 44: When a \fBstrstreambuf\fR is in automatic mode, space for ! 45: the character sequence is ! 46: allocated as needed. ! 47: When the sequence is extended too far, it will be copied ! 48: to a new array. ! 49: .PP ! 50: Assume ! 51: .br ! 52: \(em \fBssb\fR is a \f(CWstrstreambuf*\fR. ! 53: .br ! 54: \(em \fBn\fR is an \f(CWint\fR. ! 55: .br ! 56: \(em \fBptr\fR and \fBpstart\fR are \f(CWchar*\fR or \f(CWunsigned char*\fR. ! 57: .br ! 58: \(em \fBa\fR is \f(CWvoid* (*)(long)\fR. ! 59: .br ! 60: \(em \fBf\fR is \f(CWvoid* (*)(void*)\fR. ! 61: .PP ! 62: The constructors: ! 63: .TP ! 64: \fBstrstreambuf()\fR ! 65: Constructs an empty buffer in dynamic mode. This means that ! 66: space will be automatically allocated to accomodate the ! 67: characters that are put into the buffer (using operators \f(CWnew\fR ! 68: and \f(CWdelete\fR). Because this may require copying the ! 69: original characters, it is recommended that when large strings ! 70: will be used that \fBsetbuf\fR be used (as described below) to ! 71: inform the \f(CWstrstreambuf\fR. ! 72: .TP ! 73: \fBstrstreambuf(a,f)\fR ! 74: Constructs an empty buffer in dynamic mode. ! 75: \fBa\fR is used as the allocator function ! 76: in dynamic mode. If it is null, \f(CWoperator new\fR will be used. ! 77: \fBf\fR is used to free (or delete) areas returned by \fBa\fR. ! 78: If it is null \f(CWoperator delete\fR is used. ! 79: .TP ! 80: \fBstrstreambuf(n)\fR ! 81: Constructs an empty buffer in dynamic mode. The initial allocation ! 82: of space will be at least \fBn\fR bytes. ! 83: .TP ! 84: \fBstrstreambuf(ptr,n,pstart)\fR ! 85: Constructs a buffer to use the bytes starting at ! 86: \fBptr\fR. If \fBn\fR is positive and the \fBn\fR bytes starting ! 87: at \fBptr\fR are used. If \fBn\fR is zero, \fBptr\fR is assumed ! 88: to point to the beginning of a null terminated strings and ! 89: the bytes of that string (not including the terminating null character) ! 90: will constitute the buffer. If \fBn\fR is negative the buffer is ! 91: assumed to continue indefinitely. ! 92: The get pointer is initialized to \fBptr\fR. The ! 93: put pointer is initialized to \fBpstart\fR. If \fBpstart\fR is ! 94: null then stores will be treated as errors. If \fBpstart\fR ! 95: is non null then the initial sequence (for fetching) consists ! 96: of the bytes between \fBptr\fR and \fBpstart\fR. If \fBpstart\fR ! 97: is null then the initial sequence consists of the entire array. ! 98: .PP ! 99: Member functions: ! 100: .TP ! 101: \fBssb->freeze(n)\fR ! 102: Inhibits (\fBn\fR nonzero) or permits (\fBn\fR zero) automatic ! 103: deletion ! 104: of the current array. ! 105: Deletion normally occurs when more space is needed ! 106: or when \fBssb\fR is being destroyed. Only ! 107: space obtained dynamic allocation is ever freed. ! 108: It is an error (and the effect is undefined) to store characters ! 109: into a buffer that was in automatic allocation mode and is now ! 110: frozen. ! 111: It is possible, however, to thaw (unfreeze) such a buffer and ! 112: resume storing characters. ! 113: .TP ! 114: \fBptr=ssb->str()\fR ! 115: Returns a pointer to the first char of the current array and freezes ! 116: \fBssb\fR. If \fBssb\fR was constructed with an explicit array ! 117: \fBinit\fR, ! 118: \fBptr\fR will point to that array. ! 119: If \fBssb\fR is in automatic ! 120: allocation mode, but nothing has yet been stored, \fBptr\fR may ! 121: be null. ! 122: \fBstr\fR freezes \fBssb\fR. ! 123: .TP ! 124: \Bssb->setbuf(0,n)\fR ! 125: \fBssb\fR remembers \fBn\fR and the next time it does a dynamic ! 126: mode allocation, it makes sure that at least \fBn\fR bytes ! 127: are allocated. ! 128: .SH SEE ALSO ! 129: sbuf.pub(3C++) ! 130: strstream(3C++)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.