//string.h
/*************************************************************************
@class: String
This is a first-pass implementation of a String class that uses only C
and basic C++ enhancements to C for its implementation. The purpose of
this class is to work out the basic functionality of the string class as
well as practice a few functional C++ enhancements prior to moving onto
more advanced concepts.
*************************************************************************/
#ifndef STRING_H
#define STRING_H
#include <iostream>

namespace enhance {

struct String {
   int size_;
   int len_;
   char* buf_;
};

String* String_ctor();
String* String_ctor(const char* cstr);
String* String_ctor(const String& str);
String& assign(String* theString, const String& str);
void dtor(String* theString);
int operator==(const String* theString, const String& str);
int saveOn(const String* theString, ostream& str);
int restoreFrom(String* theString, istream& str);

inline ostream& operator<<(ostream &str, const String& theString) {
   if (theString.len_)
      str << theString.buf_;
   return str;
}

inline unsigned int length(String* theString) {
   return (theString) ? theString->len_ : 0;
}

} //end of namespace enhance

#endif
//end of file

