home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mandelc.zip / string.h < prev    next >
C/C++ Source or Header  |  1993-06-24  |  1KB  |  46 lines

  1. #include "object.h"
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <mem.h>
  5.  
  6.  
  7. class string:public virtual object
  8. {       public:
  9.     char *pString;
  10.     unsigned int iStrLen;
  11.     string(char *pStringNew)
  12.     {       iStrLen = strlen(pStringNew);
  13.         if (!(pString = (char*)malloc(iStrLen + 1)))
  14.             setNoSuccess();
  15.         else
  16.             memcpy(pString, pStringNew, iStrLen + 1);
  17.     }
  18.     virtual ~string(void)
  19.     {       if (pString)
  20.             free(pString);
  21.     }
  22.     Boolean concat(char *pStringNew)
  23.     {       unsigned int iStrLenNew = strlen(pStringNew);
  24.         char *pHelp;
  25.  
  26.         if (!(pHelp = (char*)realloc(pString, iStrLen + iStrLenNew + 1)))
  27.             return FALSE;
  28.         else
  29.         {       pString = pHelp;
  30.             memcpy(pString + iStrLen, pStringNew, iStrLenNew + 1);
  31.             iStrLen += iStrLenNew;
  32.             return TRUE;
  33.         }
  34.     }
  35. };
  36.  
  37.  
  38. #define idForeachStringChainElementLast idForeachChainElementLast
  39. class stringChainElement:public chainElement, public string
  40. {    public:
  41.     stringChainElement(char *pString, chain *pParent)
  42.         :chainElement(pParent), string(pString)
  43.     {
  44.     }
  45. };
  46.