home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / SNPD9404.ZIP / STR.DOC < prev    next >
Text File  |  1994-04-03  |  2KB  |  48 lines

  1. Bear in mind that this is an intentionally simple and plain string class,
  2. devoid of many features which might be found in a more complete
  3. implementation. 
  4.  
  5. The reason I say 'intentionally' is purely because it was written for a
  6. specific set of uses than to be the be-all and everything-including-your-
  7. kitchen-sink-string-class.  In particular, the aims I had in mind were:
  8.  
  9.   1.  Portable,
  10.  
  11.   2.  Small but efficient - where sizeof(str) == sizeof(char *) in
  12.       almost all C++ implementations,
  13.  
  14.   3.  Doesn't rely upon, but allows for, NUL terminators, so avoids
  15.       lots of redundant length calculations as is common in C. The
  16.       library attempts to use memory operations rather than C string
  17.       operations where possible,
  18.  
  19.   4.  As much as possible is implemented in-line for speed. All common
  20.       operations are centralised into a 'core' set of private functions.
  21.  
  22.   5.  Copy constructors and assignment are cheap operations by use of
  23.       reference counting. This makes passing objects by value very cheap
  24.       (requires no as few as possible memory allocations / copying of
  25.       string data), and is conservative with memory.
  26.  
  27.   6.  Should be easily exchanged with char*.
  28.  
  29.   7.  Memory management of strings made possible by use of a single
  30.       memory allocation function for string data (easily replaced or
  31.       enhanced)
  32.  
  33.   8.  Uses absolutely no third party classes, so is stand-alone, making
  34.       it highly reusable,
  35.  
  36.   9.  Requires no additional include files from the standard library.
  37.  
  38.   10. Avoids use of cast operators for char const * and therefore 
  39.       prevents problems caused by creation of temporaries (these can
  40.       also occur with member c_str(), but at least you have to explicitly
  41.       invoke it rather than causing a temporary to be used in a dangerous
  42.       manner without notification).
  43.  
  44.  
  45.   cheers,
  46.   David Nugent
  47.   Moderator ('93-'94) of the FidoNet C++ international EchoMail conference
  48.