// File: bstring2.h // // Header file for buffered string. Version 2. #ifndef _bstring_h #define _bstring_h #include class BString { friend ostream& operator <<(ostream&, const BString&) ; public: // Constructors // BString() ; // Default constructor BString(int) ; // Constructor with initial buffer size BString(char *s, int n=0); // Initialize with string & opt buffer size BString(const BString&) ; // Copy Constructor // Destructor // ~BString() ; // Add char(s) to the end of this string // void append(char) ; void append(const char *) ; void append(const BString&) ; // Remove char(s) at the end of the string // void chop(int n=1) ; // Reduce buffer size if possible // void trim() ; void force_trim() ; // Overloaded Operators // BString& operator =(const BString&) ; // assignment BString operator +(const BString&) ; // + is concatenate char& operator [](int) ; // Synonyms for append // BString& operator +=(char c) { append(c) ; return *this ;} BString& operator +=(const char *s) { append(s) ; return *this ; } BString& operator +=(const BString& bs) { append(bs) ; return *this ; } bool operator <(const BString&) ; // comparisons bool operator <=(const BString&) ; bool operator ==(const BString&) ; bool operator >=(const BString&) ; bool operator >(const BString&) ; // Type conversion // operator char *() { return str ; } void GetLine(istream&) ; inline int length() { return len ;} char *str ; void debug() ; private: int len ; int bufsize ; } ; istream& operator >>(istream&, BString&) ; ostream& operator <<(ostream&, const BString&) ; #endif