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

  1.  
  2. #include <string.h>
  3.  
  4. #define KEEP_ALPHABET_DEFINES
  5.  
  6. #if NSTRING_DEBUG > 0
  7.     #include <stdio.h>
  8. #endif
  9.  
  10. #include "NString.h"
  11. #include "Alphabet.h"
  12. #include "Alphabet_Private.h"
  13.  
  14. //________________________________________________________________________
  15.  
  16. Alphabet::Alphabet (const char *source)
  17. {
  18.     
  19. #if (NSTRING_DEBUG & 1) != 0
  20.     printf("Creating alphabet from string \"%s\".\n", source);
  21. #endif
  22.  
  23.     clear();
  24.     *this += source;
  25. }
  26.  
  27. //________________________________________________________________________
  28.  
  29. Alphabet::Alphabet (const char source)
  30. {
  31.     
  32. #if (NSTRING_DEBUG & 1) != 0
  33.     printf("Creating alphabet from a letter ('%c').\n", source);
  34. #endif
  35.  
  36.     clear();        
  37.     SET_ELT(source);
  38. }
  39.  
  40. //________________________________________________________________________
  41.  
  42. Alphabet::Alphabet (const Alphabet& source)
  43. {
  44.     int i;
  45.     
  46. #if (NSTRING_DEBUG & 1) != 0
  47.     printf("Creating alphabet from another alphabet.\n");
  48. #endif
  49.  
  50.     for (i=0; i < BUFSIZE; i++)
  51.         buffer[i] = source.buffer[i];                    // copy buffer bits
  52. }
  53.  
  54. //________________________________________________________________________
  55.  
  56. Alphabet::Alphabet (const NString& source)
  57. {
  58.     
  59. #if (NSTRING_DEBUG & 1) != 0
  60.     printf("Creating alphabet from NString \"%s\".\n", source.sb->str);
  61. #endif
  62.  
  63.     clear();
  64.     *this += source;
  65. }
  66.  
  67. //________________________________________________________________________
  68.  
  69. Alphabet::Alphabet (const char start, const char end)
  70. {
  71.     char c;
  72.  
  73. #if (NSTRING_DEBUG & 1) != 0
  74.     printf("Creating alphabet from letter range '%c' to '%c'.\n", start, end);
  75. #endif
  76.     
  77.     clear();
  78.     
  79.     for (c=start; c <= end; c++)
  80.         SET_ELT(c);
  81. }
  82.  
  83. //________________________________________________________________________
  84.  
  85. Alphabet& Alphabet::operator= (const char *source)
  86. {
  87.     clear();
  88.     *this += source;
  89.     
  90.     return *this;
  91. }
  92.  
  93. //________________________________________________________________________
  94.  
  95. Alphabet& Alphabet::operator= (const NString& source)
  96. {
  97.     clear();
  98.     *this += source;
  99.     
  100.     return *this;
  101. }
  102.  
  103. //________________________________________________________________________
  104.  
  105. Alphabet& Alphabet::operator= (const char source)
  106. {
  107.     clear();        
  108.     SET_ELT(source);
  109.     
  110.     return *this;
  111. }
  112.  
  113. //________________________________________________________________________
  114.  
  115. Alphabet& Alphabet::operator= (const Alphabet& source)
  116. {
  117.     int i;
  118.     
  119.     for (i=0; i < BUFSIZE; i++)
  120.         buffer[i] = source.buffer[i];                    // copy buffer bits
  121.     
  122.     return *this;
  123. }
  124.