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 >
C/C++ Source or Header  |  1996-05-08  |  1KB  |  50 lines

  1. #include "strClass.h"
  2. #include <stdlib.h>
  3.     void
  4. pause(){
  5.     cerr << Pause::programName << ":  press [Enter] to continue...";
  6.     cin.unsetf(ios::skipws);
  7.     char x;
  8.     cin >> &x;
  9.     cin.clear();
  10.     cin.setf(ios::skipws);
  11.     }
  12. //************************ Pause messages *****************************
  13. int     Pause::noPause = -1;
  14. char* Pause::programName ="";
  15.   void Pause ::
  16. init(int argc, char *argv[]){
  17.     programName = *argv++;
  18.     if(noPause == -1){
  19.         noPause = 1;
  20.         while( --argc && noPause )
  21.             if( !strcmp( *argv++, "-pause") ){
  22.                 noPause =0;
  23.                 atexit(pause);
  24.                 }
  25.         }
  26.     }
  27. //************************ String messages *****************************
  28.     String :: operator
  29. char*  (void){
  30.     streampos pos =tellp();
  31.     (ostrstream&)*this << ends;    // append a null byte to the buffer
  32.     char *s =str();                    // get a pointer to the buffer
  33.     rdbuf()->freeze(0);                // unfreeze the buffer
  34.     seekp(pos);                            // backup over the terminal null byte
  35.     ASSERT((ios&)*this);          // test for inability to allocate buffer
  36.     return s;
  37.     }
  38.       String& String ::
  39. setNull(){
  40.     seekp(0);                // rewind the buffer
  41.     rdbuf()->freeze(0);    // unfreeze the buffer
  42.     return *this;
  43.     }
  44.       String& String ::
  45. replace(const char * const str){
  46.     return setNull() << str;    // put the new string in the buffer
  47.     }
  48.  
  49.  
  50.