home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 February / macformat-047.iso / Shareware Plus / Developers / DLOGManager 1.02 / Source Code / Cstring_P_v32.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-30  |  2.9 KB  |  158 lines  |  [TEXT/KAHL]

  1. /*** File: "Cstring_P_v30.cp"
  2.  *
  3.  *    String Manager. It manages the sting in
  4.  *    PASCAL and C formats.
  5.  *
  6.  *    The string always must be in the right C format.
  7.  *
  8.  ****/
  9. #ifndef __Cstring_P__
  10. #define __Cstring_P__
  11.  
  12. typedef struct
  13. {
  14.     long    len;
  15.     char    *str;
  16. } strDescRec;
  17. typedef strDescRec *strDescPtr, **strDescHdl;
  18.  
  19. #include "memoryHandle.h"
  20. class Cstring_P
  21. {
  22.     private:
  23.         Ptr             str;                //    the string pointer.
  24.         unsigned short maxCh;                //    max caracter number it can store.
  25.         strDescHdl        altStrDesc;            //    descrittore alternativo delle stringhe
  26.     
  27.     public:
  28.         static unsigned char maxPascalCh;    //    the maximun char in a Pascal string.
  29.  
  30.         /*** constructor.
  31.          *
  32.          ***/
  33.         Cstring_P(void);
  34.  
  35.         /*** Delete the object.
  36.          *
  37.          ****/
  38.         ~Cstring_P(void);
  39.  
  40.         /*** Set the string Lenght
  41.          *
  42.          *    INPUT par:    'maxCh' the number of char.
  43.          *                        if 0 'maxCh' is eq to the 
  44.          *                        longest PASCAL string.
  45.          *    Val OUTPUT:    true/false se ha allocato o meno la stringa.
  46.          *
  47.          ***/
  48.         Boolean Istring_P(unsigned short maxCh = 255);
  49.  
  50.         /*** Destroy the string.
  51.          *
  52.          ***/
  53.         void dispose(void);
  54.  
  55.         /*** Read the string Lenght
  56.          *
  57.          *    OUTPUL val:    the maximus number of char.
  58.          *
  59.          ***/
  60.         unsigned short rMaxCh(void);
  61.  
  62.         /*** Return the string pointer:
  63.          *
  64.          *    OUTPUT val:    the string pointer.
  65.          *
  66.          ***/
  67.         Ptr    rStr(void);
  68.  
  69.         /*** Return the C string pointer:
  70.          *
  71.          *    OUTPUT val:    the string pointer.
  72.          *
  73.          ****/
  74.         char *C(void);
  75.  
  76.         /*** Reurn the string descriptor
  77.          *
  78.          ****/
  79.         strDescHdl readStr();
  80.  
  81.         /***
  82.          *
  83.          *    Copy_from(pos, str);
  84.          *
  85.          ***/
  86.         Boolean writeStr(Handle str);
  87.  
  88.         /***
  89.          *
  90.          *    rHandle();
  91.          *
  92.          ***/
  93.         Handle rHandle(void);
  94.  
  95.         /*** Read the string 'str' in PASCAL format:
  96.          *
  97.          *    OUTPUT val:    the string pointer.
  98.          *
  99.          ***/
  100.         unsigned char *P(Boolean Cstring = true);
  101.  
  102.         /*** Convert the internal string in C format
  103.          *
  104.          *    To use only if the sting has been modified in PASCAL format.
  105.          *
  106.          ***/
  107.         void Cvalidate(void);
  108.  
  109.         /*** Copy a string object:
  110.          *
  111.          *    Copy the string char until the first NULL char.
  112.          *
  113.          *    INPUT par:    '*str' the string object.
  114.          *    OUTPUT val:    true if the string is too long, false otherwise.
  115.          *
  116.          ***/
  117.         Boolean transfer(Cstring_P *str);
  118.  
  119.         /*** Transfer a C string:
  120.          *
  121.          *    INPUT par:    '*str' the string point in C format.
  122.          *    OUTPUT val:    true if the C string is too long, false otherwise.
  123.          *
  124.          ***/
  125.         Boolean Ctransfer(char *str);
  126.  
  127.         /*** Transfer a Pascal string:
  128.          *
  129.          *    INPUT par:    '*str' the string point in C format.
  130.          *    OUTPUT val:    true if the C string is too long, false otherwise.
  131.          *
  132.          ***/
  133.         Boolean Ptransfer(unsigned char *str);
  134.  
  135.         /*** Add a C string:
  136.          *
  137.          *    INPUT par:    '*str' the string point in C format.
  138.          *    OUTPUT val:    true if the C string is too long, false otherwise.
  139.          *
  140.          ***/
  141.         Boolean Add(char *str);
  142.     
  143.         /***
  144.          *
  145.          *    Copy_from(pos, str);
  146.          *
  147.          ***/
  148.         Boolean Copy(int begin, int end, char *str);
  149.  
  150.     private:
  151.         /***
  152.          *
  153.          *    Copy_from(pos, str);
  154.          *
  155.          ***/
  156.         Boolean Copy_from(int pos, char *str);
  157. };
  158. #endif