UtilString
A UtilString is a simple, non-mutable string object.
class UtilString {
public:
const int length;
UtilString();
UtilString(const char*);
~UtilString();
bool operator==(const UtilString&) const;
bool operator==(const char*) const;
char operator[](int) const;
operator const char*() const;
};
const int length
- This member is the length of the string, as would be returned by
strlen (does not include the terminating null character).
UtilString()
- This constructor creates an empty UtilString. Note that this is not
particularly useful, since UtilStrings are not mutable.
UtilString(const char* x)
- This construcor creates a UtilString from x. Note that x is copied
when the UtilString is made, so x can be freed or modified or whatever
without hurting the UtilString.
~UtilString()
- The destructor destroys the UtilString.
bool operator==(const UtilString& x)
- This operator compares the string with x.
bool operator==(const char* x)
- This operator compares the string with x.
char operator[](int x)
- This operator allows accessing elements of the string, just as you
would expect. Accessing elements less than zero or greater than
length
is guaranteed not to crash, but otherwise not defined.
operator const char*()
- This conversion operator allows converting a UtilString into a const char*.
Modified 21 October 1995 pepellet@mit.edu