home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / vrac / cuj0796.zip / COLNER.ZIP / STRCLASS.H < prev    next >
C/C++ Source or Header  |  1996-05-08  |  2KB  |  68 lines

  1. #if !defined(STRINGCLASS_DEFINED)
  2. #define STRINGCLASS_DEFINED
  3. #include <strstrea.h>
  4. #include <string.h>
  5. /************************ Pause *****************************
  6. To force a pause() at exit, include:
  7.     Pause::init(argc, argv);
  8. at the beginning of main(), and include "-pause"
  9. as a command line arguement.
  10. */
  11.     class
  12. Pause{
  13.     static char *programName;
  14.     static int noPause;
  15.     friend ostream& operator<<(ostream& out, Pause& pause);
  16.     friend void pause();
  17.   public:
  18.     static void init(int argc, char *argv[]);
  19.  
  20.   };
  21. //************************ String *****************************
  22. //    ostream& operator <<(ostream& out, Pause& pause);
  23.  
  24. #define MESSAGE(s) message(#s,__LINE__,__FILE__,__DATE__)
  25. #define ASSERT(s) if((s)==NULL){ \
  26.     MESSAGE(s); \
  27.     exit(1); \
  28.     }
  29. extern void message( char* code, unsigned long line, char* file, char* date);
  30. #define CAST_INJECTORS(CLASS) \
  31.     CLASS& operator<< (char _c) { \
  32.         (ostrstream&)*this << _c;    return *this; } \
  33.     CLASS& operator<< (signed char _c) { \
  34.         (ostrstream&)*this << _c;    return *this; } \
  35.     CLASS& operator<< (unsigned char _c) { \
  36.         (ostrstream&)*this << _c;    return *this; } \
  37.     CLASS& operator<< (const char * s){ \
  38.         (ostrstream&)*this << s;    return *this; } \
  39.     CLASS& operator<< (const signed char * s){ \
  40.         (ostrstream&)*this << s;    return *this; } \
  41.     CLASS& operator<< (const unsigned char * s){ \
  42.         (ostrstream&)*this << s;    return *this; } \
  43.     CLASS& operator<< (short _i){ \
  44.         (ostrstream&)*this << _i;    return *this; } \
  45.     CLASS& operator<< (unsigned short _i){ \
  46.         (ostrstream&)*this << _i;    return *this; } \
  47.     CLASS& operator<< (int _i){ \
  48.         (ostrstream&)*this << _i;    return *this; } \
  49.     CLASS& operator<< (unsigned int _i){ \
  50.         (ostrstream&)*this << _i;    return *this; } \
  51.     CLASS& operator<< (long _i){ \
  52.         (ostrstream&)*this << _i;    return *this; } \
  53.     CLASS& operator<< (unsigned long _i){ \
  54.         (ostrstream&)*this << _i;    return *this; } \
  55.     CLASS& operator<< (float _i){ \
  56.         (ostrstream&)*this << _i;    return *this; } \
  57.     CLASS& operator<< (double _i){ \
  58.         (ostrstream&)*this << _i;    return *this; } \
  59.     CLASS& endl(){ \
  60.         ::endl((ostream&)*this);    return *this; } \
  61.     CLASS& operator<< (ostream& (*_f)(ostream&)){ \
  62.         (*_f)((ostream&)*this);     return *this; } \
  63.     CLASS& operator<< (ios& (*_f)(ios&)) { \
  64.         (*_f)((ios&)*this);     return *this; } \
  65.     CLASS& operator << ( String& s ){ \
  66.         (ostrstream&)*this << s; return *this;    }
  67.  
  68.