home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / SourceCode / Classes / RCString / RCString.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-19  |  2.6 KB  |  111 lines

  1. #import <objc/objc.h>
  2. #import <objc/Object.h>
  3. #import <string.h>
  4. #import <stdlib.h>
  5. #import <libc.h>
  6.  
  7. //
  8. // Reference Counting String Class
  9. //
  10. /*
  11.     Copyright (C) 1992. Bruce Ediger.
  12.  
  13.       This program is free software; you can redistribute it and/or modify
  14.     it under the terms of the GNU Library General Public License.
  15. */
  16.  
  17. // internal string representation
  18. struct srep {
  19.     char *s;  // pointer to ASCIIZ data
  20.     int   n;  // reference count
  21.     int   l;  // string length
  22. };
  23.  
  24. // basic object
  25. @interface RCString : Object
  26. {
  27.     struct srep *p;
  28.     BOOL yCaseSensitive;
  29. }
  30.  
  31. + new;
  32. + newFromString: (char *) anAsciiString;
  33. + newFromObject: (RCString *) aStringObject;
  34. - newFromObject;
  35. + newFilledWith: (int) aCharacter size: (int) number;
  36. - free;
  37.  
  38. - init;
  39.  
  40. // force a copy of the internal string rep
  41. - copyReference;
  42.  
  43. // methods for obtaining info about String object
  44. - (unsigned)length;
  45. - (char *)data;
  46. - (int)references;
  47. - (struct srep *)internal;
  48. - (BOOL) isNull;
  49.  
  50. @end
  51.  
  52. // categories - mostly for organizational convenience
  53.  
  54. @interface RCString (Misc)
  55. - empty;
  56. - toUpper;
  57. - toLower;
  58. - replaceWithAsciiString: (char *)aString;
  59. - replaceWithObject: (RCString *)anObject;
  60. - performArbitraryFunction:(int (*)())someFunction;
  61. @end
  62.  
  63. @interface RCString (Comparison)
  64. - (int)compareWithObject: (RCString *)anotherObject;
  65. - (int)compareWithString: (char *)anAsciiString;
  66. - caseSensitive: (BOOL)isOrNot;
  67. @end
  68.  
  69. @interface RCString (Insertion)
  70. - appendObject:  (RCString *)anotherObject;
  71. - prependObject: (RCString *)anotherObject;
  72. - insertObject:  (RCString *)anotherObject at:(int)index;
  73.  
  74. - replaceStringAt:(int)index extent:(int)length with:(char *)aString;
  75. - replaceStringAt:(int)index extent:(int)length with:(char *)aString extent:(int)length;
  76.  
  77. - appendString:  (char *)anAsciiString;
  78. - prependString: (char *)anAsciiString;
  79. - insertString:  (char *)anAsciiString at:(int)index;
  80. @end
  81.  
  82. @interface RCString (Retrieval)
  83. - (char *)subStringAt:(int)index extent:(int)length;
  84. - subObjectAt:(int)index extent:(int)length;
  85. @end
  86.  
  87. @interface RCString (Characters)
  88. - (int)retrieveCharacterAt:(int)index;
  89. - substituteCharacter:(int)aChar at:(int)index;
  90. - insertCharacter:(int)aChar at:(int)index;
  91. - (int)indexOfCharacter:(int)aChar;
  92. - (int)lastIndexOfCharacter:(int)aChar;
  93. @end
  94.  
  95. @interface RCString (Regex)
  96. - (char *)subStringMatching:(char *)aRegex;
  97. - replaceSubStringMatching:(char *)aRegex with:(char *)aString;
  98. - objectMatching:(char *)aRegex;
  99. - (BOOL)matches:(char *)aRegex;
  100. @end
  101.  
  102. @interface RCString (Archiving)
  103. // From John Hassey's String class: should be compatible.
  104. - storeOn:(int)aFD;
  105. - readFrom:(int)aFD;
  106. #ifdef NeXT
  107. - read:(NXTypedStream *)aStream;
  108. - write:(NXTypedStream *)aStream;
  109. #endif
  110. @end
  111.