The general-purpose classes are useful both with and without Windows. All classes are grouped in the same library because most of them share a common base class, CObject. The general-purpose classes offer support for the following:
Collections
The library provides efficient collection classes for ordered lists, indexed arrays, and keyed maps (dictionaries). Sixteen collection variations accommodate strings, void pointers, object pointers, bytes, words, and double words. A template expansion tool, provided in the sample code, permits creation of customized collection classes.
Strings
The CString class adds dynamically allocated strings to C++. These strings can be manipulated with a Basic-like syntax that includes concatenation operators and functions such as Mid, Left, and Right. They can be printed to diagnostic output and written to (and read from) disk.
Time and date
A time class, together with a companion time-difference class, offers date-time arithmetic and automatic formatting of binary time values into human-readable dates and times.
Files
File classes offer a C++ interface to both the low-level and “stdio” input/output files. In-memory files are also supported. The file class hierarchy allows all three file types to be accessed polymorphically through the CFile base class.
Exception processing
Errors can be systematically trapped using a syntax that models the proposed ANSI C++ exception processing standard. This feature eliminates the need for error check logic after every function call.
Persistent objects
The object archiving feature allows objects of specified CObject-derived classes to be stored to and loaded from a “persistent” storage medium such as a disk. If a collection is archived, then all the members of the collection will, in turn, be archived.
Debugging support and diagnostics
Individual objects of selected CObject-derived classes may be printed in human-readable form. Memory allocation statistics are available, and it is possible to print the contents of a range of memory. Such a memory dump will display not only object information but also the line number and source module name where each memory block was allocated. Special “guard bytes”, inserted before and after allocated memory, allow corruption to be detected. All these diagnostic features are disabled in the Release versions of the library.