home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 July / macformat-026.iso / mac / Shareware City / Developers / NString 1.0 beta / Sources / Alphabet_String.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-12  |  1.6 KB  |  83 lines  |  [TEXT/KAHL]

  1.  
  2. #include <string.h>
  3.  
  4. #define KEEP_ALPHABET_DEFINES
  5.  
  6. #include "NString.h"
  7. #include "Alphabet.h"
  8. #include "Alphabet_Private.h"
  9.  
  10. //________________________________________________________________________
  11.  
  12. Alphabet& Alphabet::operator+= (const char *source)
  13. {
  14.     unsigned long int i;
  15.     
  16.     for (i = 0; i < strlen(source); i++)
  17.         SET_ELT(source[i]);
  18.         
  19.     return *this;
  20. }
  21.  
  22. //________________________________________________________________________
  23.  
  24. Alphabet& Alphabet::operator+= (const NString& source)
  25. {
  26.     unsigned long int i;
  27.     
  28.     for (i = 0; i < source.sb->len; i++)
  29.         SET_ELT(source.sb->str[i]);
  30.         
  31.     return *this;
  32. }
  33.  
  34. //________________________________________________________________________
  35.  
  36. Alphabet& Alphabet::operator-= (const char *source)
  37. {
  38.     unsigned long int i;
  39.     
  40.     for (i = 0; i < strlen(source); i++)
  41.         CLR_ELT(source[i]);
  42.  
  43.     return *this;
  44. }
  45.  
  46. //________________________________________________________________________
  47.  
  48. Alphabet& Alphabet::operator-= (const NString& source)
  49. {
  50.     unsigned long int i;
  51.     
  52.     for (i = 0; i < source.sb->len; i++)
  53.         CLR_ELT(source.sb->str[i]);
  54.  
  55.     return *this;
  56. }
  57.  
  58. //________________________________________________________________________
  59.  
  60. int Alphabet::contains (const char *elements) const
  61. {
  62.     unsigned long int i;
  63.     
  64.     for (i = 0; i < strlen(elements); i++)
  65.         if (! ELT(elements[i]))
  66.             return 0;
  67.  
  68.     return 1;    
  69. }
  70.  
  71. //________________________________________________________________________
  72.  
  73. int Alphabet::contains (const NString& elements) const
  74. {
  75.     unsigned long int i;
  76.     
  77.     for (i = 0; i < elements.sb->len; i++)
  78.         if (! ELT(elements.sb->str[i]))
  79.             return 0;
  80.  
  81.     return 1;    
  82. }
  83.