Class String


      1. class
        1. String
    1. Programmer: Ryan Davis
    1. Description:

    1. Define a "plug & play" string class in order to catch any and all improper // use of a string type such as non terminated strings, range checking, etc.
      1. Public Methods:

          1. String
        1. (const char * aString = "");
        2. I am the default and standard constructor for string. I
  1. have a default value of "" so that I may be used with arrays
  2. and other situations needing it. I create a copy of the
  3. string passed to me.
  4. CAUTION: I will bomb if aString is a NULL pointer.


      1. String
    1. (const char * aString, const UInteger & aSize);
    2. I am a conversion constructor. I am used in the case of
  5. not having a NULL terminated string or when you have the
  6. need to pull out a substring of known size.
  7. CAUTION: I will bomb if aString is a NULL pointer.


      1. String
    1. (const String & aString);
    2. I am the copy constructor. I will create a copy of the
  8. string object passed to me.


      1. ~String
    1. ();
    2. I am the destructor. I deallocate the memory used and
  9. sets everything back to a safe state.


    1. String &
      1. operator =
    2. (const char * aString);
    3. I am a conversion = operator. It will copy a low level
  10. string's contents into the current string, deleting the
  11. current contents if necessary.
  12. CAUTION: I will bomb if aString is a NULL pointer.


    1. String &
      1. operator =
    2. (const String & aString);
    3. I am the standard operator =(). I will create a copy
  13. of aString, deleting my current contents if necessary.


    1. char *
      1. asCString
    2. ();
    3. I am an explicit conversion constructor. I am used when you
  14. absolutely have to use me as a char *.


    1. char &
      1. operator[]
    2. (const UInteger & index);
    3. I am the subindexing operator. I will allow you to
  15. access my individual characters by their array index.
  16. As always C/++ arrays are zero based.
  17. CAUTION: I will bomb if index > mySize


    1. UInteger
      1. length
    2. ();


    3. Boolean operator
      1. <
    4. (const String & aString);


    5. Boolean operator
      1. >
    6. (const String & aString);


    7. Boolean operator
      1. <=
    8. (const String & aString);


    9. Boolean operator
      1. >=
    10. (const String & aString);


    11. Boolean operator
      1. =
    12. (const String & aString);


    13. Boolean operator
      1. !=
    14. (const String & aString);


    15. String &
      1. operator +=
    16. (const String & aString);


    17. String operator
    18. (const String & aString);
    19. services
  18. I am an internal utility used by the default constructor
  19. and assignment operator. I do all the work of copying a
  20. low level string. I was created for safety and maintenance
  21. reasons.
  22. CAUTION: I will bomb if aString is NULL _OR_ if aString == myString
  23. data


      1. Protected Methods:

      1. Protected Members:


        1. UInteger
          1. mySize;



        2. char *
          1. myString;