//this is ben's stringB.h file.
//designed to replace std::string

#ifndef BEN_STRINGB_H
#define BEN_STRINGB_H


#include <iostream.h>

#include <string.h>

class stringB{

	private:
		char * theString;
		
	public:
		
		stringB() {
			theString = new char[80];
			for(int i=0; i < 80; i++) {
				theString[i] = '\0';
			}
		}
		
		stringB(int size) {
		
			theString = new char[size];
			for(int i=0; i < size; i++) {
				theString[i] = '\0';
			}
		}
		
		stringB(const char *c){
		
			theString = new char[strlen(c)+1];
			
			strcpy(theString, c);
		
		}
		
		stringB(const stringB &s) {
		
			theString = new char[strlen(s.theString)+1];
			
			strcpy(theString, s.theString);
		
		}
		
		~stringB(){
		
			delete [] theString;
		
		}

		//use to be able to type cast to a char* 
		operator const char * const () const {
		  return theString;
		}

		stringB & operator=(const stringB &s);
		stringB & operator=(const char *c);
		stringB & operator+=(const char *c); //concatenate a char* on the end of a stringB
		int readUntil(istream &is, int maxsize, char until_this);
		char & operator[](unsigned int whichChar) const; //access a particular character.
		void setString(const char *str); //copy str to the string.
		int length();      //return the length of the string.
		stringB chopFront(int howMany);  //chop off the front of the string.
		stringB chopFront(char chopBefore);  //chop off the front of the string.

		friend bool operator<(const stringB &a, const stringB &b);
		friend bool operator>(const stringB &a, const stringB &b);
		friend bool operator==(const stringB &a, const stringB &b);
		friend bool operator==(const stringB &a, const char *b);
		friend bool operator!=(const stringB &a, const stringB &b);
		friend bool operator!=(const stringB &a, const char *b);
		friend ostream & operator<<(ostream &os, const stringB &b);
		friend istream & operator>>(istream &is, stringB &b);
};

#endif
