joachim99@75: /* joachim99@75: * Copyright (c) 2003, Sergey Zorin. All rights reserved. joachim99@75: * joachim99@75: * This software is distributable under the BSD license. See the terms of the joachim99@75: * BSD license in the LICENSE file provided with this software. joachim99@75: * joachim99@75: */ joachim99@75: joachim99@75: #ifndef __string_h__ joachim99@75: #define __string_h__ joachim99@75: joachim99@75: #include joachim99@75: #include joachim99@75: joachim99@75: #include joachim99@75: #include joachim99@75: joachim99@75: class STRING; joachim99@75: inline STRING operator+( const STRING& s1, const STRING& s2); joachim99@75: joachim99@75: class STRING { joachim99@75: public: joachim99@75: static const int begin = 0; joachim99@75: static const int end = -1; joachim99@75: joachim99@75: public: joachim99@75: STRING(const STRING& s) { joachim99@75: _str = new TCHAR[s.length()+1]; joachim99@75: lstrcpy(_str, s); joachim99@75: } joachim99@75: joachim99@75: STRING(const TCHAR* str = TEXT("")) { joachim99@75: _str = new TCHAR[lstrlen(str)+1]; joachim99@75: lstrcpy(_str, str); joachim99@75: } joachim99@75: joachim99@75: ~STRING() { joachim99@75: delete[] _str; joachim99@75: } joachim99@75: joachim99@75: void resize( size_t newLength ) joachim99@75: { joachim99@75: size_t oldLength = length(); joachim99@75: if ( newLength < oldLength ) { joachim99@75: _str[newLength] = 0; // Just truncate the string joachim99@75: } else if( newLength>oldLength) { joachim99@75: TCHAR* p = new TCHAR[ newLength + 1 ]; joachim99@75: lstrcpy(p, _str); joachim99@75: for( size_t i=oldLength; i