The STring Class

The STring Class

The STring class represents character strings. It includes the routines that construct and manage strings in C++. It include arithmetic operations for concatenation, relational operators, substring generation, indexing, and conversion. This class was generated to simplify the use of strings in C++ programs, especially the use of concatenation.

To Obtain the Class

To obtain the STring class you need both the include file STring.h and the source code file STring.C.

Make Sure to Also Include...

Be sure to include the following lines in your source code file, as these routines utilize them.

            #include <stdlib.h>
            #include <math.h>
            #include <stream.h>
            #include <strings.h>
Also, if you wish to use UNIX commands (exevlp, system, sleep, etc.) in your program, you should also have
            #include <unistd.h>

How to Overload Operators to take STrings...

One can overload the usual UNIX commands to take string types. For example, the ``system'' command, which usually takes a character string, can be modified to accept STrings by defining

      int system ( const STring & s )

	    char * p = s.string() ;
	    int success = system ( p ) ;
	    delete [] p ;

	    return ( success ) ;
which implements this unix command, with a STring parameter instead of a character string parameter.

Notice the capitalization of the first two letters of the class. This was done to avoid name conflicts with libraries and other classes that are currently utilized in various subsystems (e.g. X, gl) of the workstation environment that we utilize.

This class does not keep a linked list of characters, but maintains an array of characters, which is set at a certain size initially, and then expanded in chunks when it is necessary. Externally this is not visible to the user of the class, but when modifying the class, this fact must be taken into consideration.

This class was generated for a research system at UC Davis and has worked in a variety of situations. Unfortunately, this is not a guarantee that it will work in your situation. You may use it ``as is'' or can modify it. If you find errors, and can correct them, please send mail to the address below, as we would also like to know about them.

This document maintained by Ken Joy.
Comments to the author :

All contents copyright (c) 1998
Computer Science Department, University of California, Davis
All rights reserved.

Ken Joy
Wed Jan 7 14:58:59 PST 1998