Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

dsStrstream Class Reference

This is alternative implementation of std::strstream. More...

#include <dsStrstream.h>

Inheritance diagram for dsStrstream:

iostream List of all members.

Public Methods

 dsStrstream ()
 dsStrstream (const dsStrstream &s)
 dsStrstream (char *s, int n, std::ios::openmode mode=std::ios::out|std::ios::in)
virtual ~dsStrstream ()
dsStrstreambufrdbuf () const
size_t pcount ()
char * str ()
void freeze (bool n=true)
void clear ()

Detailed Description

This class is designed to provide fast, convenient and not depricated implementation of strstream. I belive removing strstream from standard library is not a good idea because lots of code already use it and most of system and database APIs require c-string as parameters. I tried to compensate weakness of standard implementation:

str() always return zero terminated string, but terminating zero is out of egptr(). It allows code like for(int i=0; i < 26; ++i) { dstr << '/' << (char) i + 'A'; mkdir( dstr.str(), 0666 ); }

str() function doesn't call freeze() IMHO, returning pointer to dynamic string is bad programming parctice, from other side invalid pointer can be located easier, then memory leaks caused by freezed stream.

clear() Clear function returns dynamic stream to initial state and reset get and put pointers for static stream.

setseg(size_t newSize) Allow manage buffer increment at runtime, larger value increase speed, small value decrease memory consumption

seekp(n,ios::end) do the same as ios::cur. IMHO, there is now such thing as end of strstream.

Stream configuration section (change it with care because most of libdms4 internals require _DS_AUTOTERMINATE is turned on and _DS_ENABLE_AUTOFREEZE turned off)

Stream configuration contains a number of defines controlling behavioure of stream. _DS_AUTOTERMINATE - initialize allocated buffer by zero, it can slow down overflow, but keppi buffer always terminated. _DS_ENABLE_AUTOFREEZE - str() will call freeze(), the same way as std:strstream does _DS_USE_SGI_SEEK_ROUTINE - use strstreambuf::seekoff() written by SGI, and used in libstdc++

_DS_ADAPTIVE_INCREMENT - add N*_DS_SEGMENT_SIZE on each overflow instead of _DS_SEGMENT_SIZE where N is number of expansions. _DS_SEGMENT_SIZE - default value of buffer increment segment.

Constructor & Destructor Documentation


dsStrstream::dsStrstream const dsStrstream &    s

dsStrstream::dsStrstream char *    s,
int    n,
std::ios::openmode    mode = std::ios::out|std::ios::in

dsStrstream::~dsStrstream   [virtual]

Member Function Documentation

void dsStrstream::clear  

void dsStrstream::freeze bool    n = true

size_t dsStrstream::pcount  

dsStrstreambuf * dsStrstream::rdbuf   const

char * dsStrstream::str  

The documentation for this class was generated from the following files:
Generated on Mon May 16 18:27:00 2005 for libdms4 by doxygen1.3-rc2