home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 31
/
CDASC_31_1996_juillet_aout.iso
/
vrac
/
cuj0796.zip
/
COLNER.ZIP
/
STRCLASS.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-05-08
|
1KB
|
50 lines
#include "strClass.h"
#include <stdlib.h>
void
pause(){
cerr << Pause::programName << ": press [Enter] to continue...";
cin.unsetf(ios::skipws);
char x;
cin >> &x;
cin.clear();
cin.setf(ios::skipws);
}
//************************ Pause messages *****************************
int Pause::noPause = -1;
char* Pause::programName ="";
void Pause ::
init(int argc, char *argv[]){
programName = *argv++;
if(noPause == -1){
noPause = 1;
while( --argc && noPause )
if( !strcmp( *argv++, "-pause") ){
noPause =0;
atexit(pause);
}
}
}
//************************ String messages *****************************
String :: operator
char* (void){
streampos pos =tellp();
(ostrstream&)*this << ends; // append a null byte to the buffer
char *s =str(); // get a pointer to the buffer
rdbuf()->freeze(0); // unfreeze the buffer
seekp(pos); // backup over the terminal null byte
ASSERT((ios&)*this); // test for inability to allocate buffer
return s;
}
String& String ::
setNull(){
seekp(0); // rewind the buffer
rdbuf()->freeze(0); // unfreeze the buffer
return *this;
}
String& String ::
replace(const char * const str){
return setNull() << str; // put the new string in the buffer
}