// File: mystring.cpp // Author: Matt Small // Description: Implementation of the MyString Class #include "mystring.h" #include /* outputs c-string mstr to screen (Nothing else! No newline, etc.) */ ostream& operator<< (ostream& os, const MyString& Mstr) { } /* inputs string from the keyboard into MyString mstr object, input ends with newline (which is not stored) */ istream& operator>> (istream& is, MyString& Mstr) { } /* returns a MyString object that is a concatination of Mstr2 to the end of Mstr1 */ MyString operator+ (const MyString& Mstr1, const MyString& Mstr2) { } /***************************************************************/ /* A Note About the Comparison Functions: */ /* Use the exact same semantics as strcmp function (hint). You */ /* can find additional information about strcmp(char*,char*) */ /* by viewing its man page (type 'man strcmp') on unix/linux. */ /* Essentially, the functions compares the first */ /* MIN( Mstr1.length, Mstr2.length ) chars of Mstr1 and */ /* Mstr2, lexicographically. (Examples: aaab == aaa, */ /* aaabd < aaaca, bbcd < ccaa, x > aaaa aab != aac */ /***************************************************************/ /* Checks if Mstr1 is lexicographically less than Mstr2. */ bool operator< (const MyString& Mstr1, const MyString& Mstr2) { } /* Checks if Mstr1 is lexicographically greater than Mstr2. */ bool operator> (const MyString& Mstr1, const MyString& Mstr2) { } /* Checks if Mstr1 is lexicographically less than or equal to Mstr2. */ bool operator<= (const MyString& Mstr1, const MyString& Mstr2) { } /* Checks if Mstr1 is lexicographically greater than or equal to Mstr2. */ bool operator>= (const MyString& Mstr1, const MyString& Mstr2) { } /* Checks if Mstr1 is lexicographically equal to Mstr2. */ bool operator== (const MyString& Mstr1, const MyString& Mstr2) { } /* Checks if Mstr1 is lexicographically not equal to Mstr2. */ bool operator!= (const MyString& Mstr1, const MyString& Mstr2) { } // default constructor -- inits str to "" MyString::MyString() { } /* copy constructor, INITIALIZE this NEW calling object to be a copy of Mstr */ MyString::MyString(const MyString& Mstr) { } // conversion constructor from c-string to object MyString::MyString(const char* str_param) { } // destructor for cleanup of DMA MyString::~MyString() { } /* assignment overload, make ALREADY INITIALIZED calling a copy of Mstr */ const MyString& MyString::operator=(const MyString& Mstr) { } /* assigns the calling object to the concatenation of Mstr1 to the end of the calling object. Can be used in cascading calls (ie. S0 = S1 += S2 += S3; ) */ const MyString& MyString::operator+=(const MyString& Mstr) { } /* const safe [] overload, used to read a char from a const MyString. Returns the 'index' char in string. If index is not in the valid range (0 - MAX), prints error to screen and returns char at lowest or highest valid index if index was lower or higher than the valid range respectively. If string is empty, return 0. */ char MyString::operator[] (int index) const { } /* overload of [] used to read or write char to non-const MyString. Same as const safe version, but returns char reference */ char& MyString::operator[](int index) { } // returns a pointer to the begining of the cstring char* MyString::cstring() { } // return length of the stored string int MyString::GetLength() const { } /* resize the allocation for the stored string to allow a string of size n, not counting NULL char */ void MyString::Resize(int n) { }