diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2008-01-27 11:37:44 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@xenon.tklauser.home> | 2008-01-27 11:37:44 +0100 |
commit | 7e0f021a9aec35fd8e6725e87e3313b101d26f5e (patch) | |
tree | b1cacc4b24393f517aeb4610e9e1021f954307a8 /reference/C/CONTRIB/SNIP/str.doc |
Initial import (2.0.2-6)2.0.2-6
Diffstat (limited to 'reference/C/CONTRIB/SNIP/str.doc')
-rwxr-xr-x | reference/C/CONTRIB/SNIP/str.doc | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/reference/C/CONTRIB/SNIP/str.doc b/reference/C/CONTRIB/SNIP/str.doc new file mode 100755 index 0000000..c2a54c1 --- /dev/null +++ b/reference/C/CONTRIB/SNIP/str.doc @@ -0,0 +1,47 @@ +Bear in mind that this is an intentionally simple and plain string class,
+devoid of many features which might be found in a more complete
+implementation.
+
+The reason I say 'intentionally' is purely because it was written for a
+specific set of uses than to be the be-all and everything-including-your-
+kitchen-sink-string-class. In particular, the aims I had in mind were:
+
+ 1. Portable,
+
+ 2. Small but efficient - where sizeof(str) == sizeof(char *) in
+ almost all C++ implementations,
+
+ 3. Doesn't rely upon, but allows for, NUL terminators, so avoids
+ lots of redundant length calculations as is common in C. The
+ library attempts to use memory operations rather than C string
+ operations where possible,
+
+ 4. As much as possible is implemented in-line for speed. All common
+ operations are centralised into a 'core' set of private functions.
+
+ 5. Copy constructors and assignment are cheap operations by use of
+ reference counting. This makes passing objects by value very cheap
+ (requires no as few as possible memory allocations / copying of
+ string data), and is conservative with memory.
+
+ 6. Should be easily exchanged with char*.
+
+ 7. Memory management of strings made possible by use of a single
+ memory allocation function for string data (easily replaced or
+ enhanced)
+
+ 8. Uses absolutely no third party classes, so is stand-alone, making
+ it highly reusable,
+
+ 9. Requires no additional include files from the standard library.
+
+ 10. Avoids use of cast operators for char const * and therefore
+ prevents problems caused by creation of temporaries (these can
+ also occur with member c_str(), but at least you have to explicitly
+ invoke it rather than causing a temporary to be used in a dangerous
+ manner without notification).
+
+
+ cheers,
+ David Nugent
+ Moderator ('93-'94) of the FidoNet C++ international EchoMail conference
|