/* ************************************************************************* ArmageTron -- Just another Tron Lightcycle Game in 3D. Copyright (C) 2000 Manuel Moos (manuel@moosnet.de) ************************************************************************** This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *************************************************************************** */ #ifndef ArmageTron_STRING_H #define ArmageTron_STRING_H #include "tArray.h" #include "tMemStack.h" #include #include #include //typedef tArray string; class tOutput; class tString:public tArray{ private: public: tString(); tString(const char *); tString(const tString &); tString(const tOutput &); void ReadLine(std::istream &s); tString & operator+=(const char *c); tString & operator=(const char *c); tString & operator<<(const char *c); tString operator+(const char *c) const; tString & operator<<(char c); tString & operator+=(char c); tString operator+(char c) const; // comparison operators int Compare( const char* other ) const; // wrapper for strcmp bool operator==( const char* other ) const; bool operator!=( const char* other ) const; bool operator<( const char* other ) const; bool operator>( const char* other ) const; bool operator<=( const char* other ) const; bool operator>=( const char* other ) const; operator const char*() const; tString & operator =(const tString &s); tString & operator =(const tOutput &s); tString & operator+=(const tString &s); // Z-Man: stupid, stupid disambiguation for Visual C++. // not harmful to GCC, but not required. #ifdef _MSC_VER template char& operator[](I i) { return tArray::operator [](i); }; #endif // bool operator==(const tString &other) const; // bool operator>=(const tString &other) const; // static char * ReserveTempString(); // static int TempStringLength(); // static void MakeTempStringLonger(); // static void FreeTempString(); void Clear(){tArray::Clear(); } void SetPos( int len, bool cut ); //removed in favor of searching whole string... // void RemoveStartColor(); void RemoveHex(); bool ge2(tString str2); static int CompareAlphaNumerical( const tString& a, const tString &b); int GetInt( int& pos ) const ; // exctact the integer at position pos plus 2^16 ( or the character ) }; std::ostream & operator<< (std::ostream &s,const tString &x); std::istream & operator>> (std::istream &s,tString &x); //#define tMAX_STRING_OUTPUT 1000 //extern char st_stringOutputBuffer[tMAX_STRING_OUTPUT]; /* tString & operator <<(tString &s,const char* c){ return s+=c; } tString & operator <<(tString &s,char c){ return s+=c; } */ template tString & operator <<(tString &s,const T &c) { std::ostringstream S; S << c << '\0'; return s+=S.str().c_str(); } std::stringstream& operator<<(std::stringstream& s,const tString &t); //std::stringstream& operator<<(std::stringstream& s, const int &t); //std::stringstream& operator<<(std::stringstream& s, const float &t); //std::stringstream& operator<<(std::stringstream& s, const short unsigned int &t); //std::stringstream& operator<<(std::stringstream& s, const short int &t); //std::stringstream& operator<<(std::stringstream& s, const unsigned int &t); //std::stringstream& operator<<(std::stringstream& s, const unsigned long &t); //std::stringstream& operator<<(std::stringstream& s, char t); //std::stringstream& operator<<(std::stringstream& s, bool t); //std::stringstream& operator<<(std::stringstream& s, const char * const &t); bool operator==( const char* first, const tString& second ); bool operator!=( const char* first, const tString& second ); bool operator<( const char* first, const tString& second ); bool operator>( const char* first, const tString& second ); bool operator<=( const char* first, const tString& second ); bool operator>=( const char* first, const tString& second ); bool operator==( const tString& first, const tString& second ); bool operator!=( const tString& first, const tString& second ); bool operator<( const tString& first, const tString& second ); bool operator>( const tString& first, const tString& second ); bool operator<=( const tString& first, const tString& second ); bool operator>=( const tString& first, const tString& second ); /* void operator <<(tString &s,const char * c); void operator <<(tString &s,const unsigned char * c); void operator <<(tString &s,int c); void operator <<(tString &s,float c); */ #endif